Hello Guest it is March 28, 2024, 07:35:09 AM

Author Topic: VB syntax  (Read 14852 times)

0 Members and 1 Guest are viewing this topic.

VB syntax
« on: March 18, 2009, 01:28:18 PM »
OK, I'm new at this so I am askin for help. I printed out the Mach Script Language Reference, all 139 pages.
I now have a macro that I have written.

a = GetVar (500)
b = GetVar (501)
c = GetVar (502)
d = GetVar (503)

a= a+1
If a>9 Then b=b+1
If a>9 Then a=0

If b>9 Then c=c+1
If b>9 Then b=0

If c>9 Then d=d+1
If c>9 Then c=0   

Print " " &d &c &b &a
SetVar 500, a
SetVar 501, b
SetVar 502, c
SetVar 503, d
End

I had help writing it. The reason I am writing is this macro does what I need but no where in the 139 pages do I find
GetVar, SetVar or a reference to variables in the 500 - 600 range being persistent.
That leads me to think that the 139 pages that I printed are not what I should be studying.
Where do I find the REAL language reference?

Darrell

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: VB syntax
« Reply #2 on: March 18, 2009, 01:48:59 PM »
note you have to put a "End If" to follow your If statements. i.e.

if a<(a+1) then
your code here
end if

scott
fun times
Re: VB syntax
« Reply #3 on: March 18, 2009, 02:18:58 PM »
Scot,
Do you mean an End If after every If statement or an End If after the last If statement in my code?

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: VB syntax
« Reply #4 on: March 18, 2009, 02:28:00 PM »
after every if
fun times

Offline ger21

*
  • *
  •  6,295 6,295
    • View Profile
    • The CNC Woodworker
Re: VB syntax
« Reply #5 on: March 18, 2009, 03:29:15 PM »
If it's on one line, you shouldn't need an End If. At least you don't in regular VB.
Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html
Re: VB syntax
« Reply #6 on: March 18, 2009, 07:55:52 PM »
Thanks for all the replies. I am still looking for a good language reference. The Wiki page mentioned does have information not in the Mach Script Language Reference but there still seems to be a lot missing. Most needed for me are actual examples.
I am still not sure if I am supposed to be looking for VB Scripting or VB Programming or is there a difference?
Is VB something I need to buy or is there a free version?
Programming Macros interests me a lot as I have been using AHHA software's built in macro language for years and this looks to have even more possibilities.

vmax549

*
Re: VB syntax
« Reply #7 on: March 19, 2009, 09:59:54 PM »
Darrel there is NOT alot published on the EXTRAS that were added in .  THere is a little in the Customising Mach manual that gives the very basics.

You just have to ask if you need to know something and HOPEFULLY someone has already figured out a way.  OR collectively we work on it to come up with a solution or two. (;-)

Hopefully someone creative willl come along and take ALL the post and sort through them and put them in a search engine type arrangement, then we may have a decent library of functions .

Just a thought, (;-) TP
Re: VB syntax
« Reply #8 on: March 20, 2009, 03:11:31 PM »
I have been unable to find any where the syntax for using variables in G code in a Macro.
I can declare a variable
V= GetVar (550)
and Print V will print the value that I have stored in 550 but if I use

V= GetVar (550)
Code "G90 G00 XV YV" or
Code "G90 G00 X&V Y&V"

it runs ok in the script window but Mach gives the error

No digits found where real number should be

What am I doing wrong?

Offline ger21

*
  • *
  •  6,295 6,295
    • View Profile
    • The CNC Woodworker
Re: VB syntax
« Reply #9 on: March 20, 2009, 03:26:47 PM »
Try this:

Code "G90 G00 X " &V & " Y " &V
Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html