Hello Guest it is March 28, 2024, 06:50:02 PM

Author Topic: VB syntax  (Read 14855 times)

0 Members and 1 Guest are viewing this topic.

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: VB syntax
« Reply #20 on: March 22, 2009, 10:14:56 AM »
Jusst another side note:

you have to set the vars before you can use them.

you have this:

'M79.m1s
GetVar (550)
Code"#551=[#550/2]"

You need this:

'M79.m1s
Var1 = GetVar (550)
SetVar (551, (Var1/2))

'When ever you use a "Get" something, you have to set it = to something, OR, put the Get as the parameter of another function.
'for example

SetVar (551, (GetVar (550)/2))

'scott



« Last Edit: March 22, 2009, 10:17:27 AM by poppabear »
fun times
Re: VB syntax
« Reply #21 on: March 22, 2009, 11:50:50 AM »
I think you may be missing the fact that

Code"#551=[#550/2]"

does set 551. In reality, I don't need

GetVar (550)

Variable 550 is set in the calling G-code and I could either set 551 as I am doing in the macro or with

#551=[#550/2]

in the G-code following the #550=  line.
Re: VB syntax
« Reply #22 on: March 22, 2009, 04:21:03 PM »
Hi

You appear to be confusing integers with strings and are showing a integer value within string quotes
The below is not strictly necessary but clearly shows the difference between the 2 types of data you are combining.
(   Str() converts an integer to a String and Val() does the reverse  )

Dim V As Double
Dim s1 As String

V= GetVar (550)

s1 = "G90 G00 X" &Str(V) & " Y" &Str(V)

Code s1

regards

Melee

Actually, when I first set V with

V= GetVar (550)

I am implicitly declaring V as Double. The same is true when I then set V1 with

V1=[V/2]

because the value being set is Double.

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: VB syntax
« Reply #23 on: March 22, 2009, 10:24:14 PM »
Well all righty then, you got it all figured out then
Good luck

scott
fun times