Machsupport Forum

Mach Discussion => Mach Screens => Screen designer tips and tutorials => Topic started by: AutomaticInvest-worker1 on August 31, 2022, 02:37:45 PM

Title: problem with RunFile() after LoadFile
Post by: AutomaticInvest-worker1 on August 31, 2022, 02:37:45 PM

Hello,

  I would have a question related to adding VB code to a button on a Mach3 screen

  If the code of the button is

LoadFile("C:\Mach3\GCode\code2.tap")
RunFile()

  then only the loading will be done, without running the code of the loaded file


  But if the code is

LoadFile("C:\Mach3\GCode\code2.tap")
Sleep(3000)
RunFile()

  the after the file is loaded, it is soon also run, after about 3 seconds

  which tells me that it is needed to wait for the loading to finish before it can be run

  So, with this in mind I modified the code to

LoadFile("C:\Mach3\GCode\code2.tap")
While (IsLoading())
   Sleep(100)
Wend
RunFile()

  where the while loop runs until loading is complete, but I get the same problem as with the 2 lines of code shown above, that is the same as with

LoadFile("C:\Mach3\GCode\code2.tap")
RunFile()

  Can somebody explain me how to get the file running after loading ?

  -- regards