Hello Guest it is December 13, 2019, 03:31:28 PM

Author Topic: V.B scripts problem in M6Start Macro M99999 file  (Read 2177 times)

0 Members and 1 Guest are viewing this topic.

V.B scripts problem in M6Start Macro M99999 file
« on: November 17, 2016, 11:02:07 PM »
Hi everybody,

The M99999 file is as below:

‘****************

Global Const t=50000

Sub Main

tool=GetSelectedTool()
SetCurrentTool(tool)
........
Call A
.........
End Sub

Sub A
.....
Sleep(t)
....
End Sub
‘****************

However, the value 5000 can't pass to subroutine A. It seems that it don't allow the scripts put at the very beginning and outside the Sub Main. Is this true? And, how can it be corrected?

Thanks in advance!
Re: V.B scripts problem in M6Start Macro M99999 file
« Reply #1 on: November 21, 2016, 04:50:27 AM »
First, you've made a classic mistake in that you do not need to use Sub Main... End Sub for the main part of the program.

Secondly and more to the question, when you "Call A" I think you need to pass the variable to the sub routine as follows:

Call A(t)

I'd have to dig back into my documents to see if there's anything more you need to do in the sub routine to accept the value, but this should help get you started in the right direction.

Hope this helps,

Stephen "Highspeed" Kruse
Re: V.B scripts problem in M6Start Macro M99999 file
« Reply #2 on: November 21, 2016, 10:57:58 PM »
Hi,

As the title mentioned, this M99999 is a program that was called by M6Start, actually i really don't understand how the mechanism it works thru'....
I tried to delete Sub Main.....End Sub, so the structure of program likes below, however, there is no response...??

With the Sub Main... End Sub added back,  there is response.

tool=GetSelectedTool()
SetCurrentTool(tool)
.....

Call A(10000)
.....

Sub A(t As Integer)
....
Sleep(t)
...
End Sub
Re: V.B scripts problem in M6Start Macro M99999 file
« Reply #3 on: November 22, 2016, 02:05:13 AM »
Ah, yes. Calling it from within another macro then that makes sense. Did the additional changes you made paying the variable make it work for you?

Highspeed
Re: V.B scripts problem in M6Start Macro M99999 file
« Reply #4 on: November 22, 2016, 09:15:54 AM »
It seems that in Mach3 V.B., each subroutine only works with its own constant variables. For small quantity of non-constant variables, they can be passed down to to other subroutines from the main subroutine by the said method of call(t)....,
Then, for a large amount of common constant variables (almost a page of them), i now need to write them down on Sub Main and also copy them to those corresponding subroutines. It ends up the making of changes goes difficult and also tedious...

I used to work in C language and has no problem in program structure. Am i making some mistakes here!