Machsupport Forum

Mach Discussion => VB and the development of wizards => Topic started by: chessie on May 29, 2019, 03:05:16 PM

Title: vb script tutorial help
Post by: chessie on May 29, 2019, 03:05:16 PM
Hi
i have been getting some help from one of the forum members with Macro's for which I'm very grateful.  I would like to learn for myself instead of bothering other people.
Can anyone point me to books ,video tutorial etc .i just want to get the basics so i can make and alter macro's.

cheers
Title: Re: vb script tutorial help
Post by: Tweakie.CNC on May 30, 2019, 01:31:17 AM
There is a lot of information, including examples, in the Mach2 Customisation Manual and this may be a good tutorial to start with.

 https://www.machsupport.com/wp-content/uploads/2013/02/Mach2_6.11_Custom.pdf

Tweakie.

Title: Re: vb script tutorial help
Post by: TPS on May 30, 2019, 03:24:42 AM
https://www.machsupport.com/forum/index.php?action=dlattach;topic=12740.0;attach=17815
http://www.machsupport.com/wp-content/uploads/2013/02/VBScript_Commands.pdf
Title: Re: vb script tutorial help
Post by: TerryKurtz on July 17, 2019, 03:22:52 PM
Hi- 1st post ever on anything but I'm desperate!  To the point-I have what I'm sure is a simple problem in getting macros to run.  I programmed for a living and have looked up every reference to scripting in every Mach2&3 manual online and can't find any solution for what I am sure is a simple(but elusive) problem. The VB Script editior, final version of mach3, will run w/o error: setvar(100,Getvar(101)+3) M99 as a stand alone snippet of code in a macro I named M881.m1s.  Using the Operator/#var monitor, I can verify the read/write results.  First problem, which may bear on a second problem,  If I place M99 on the line following the set/get,

setvar(100,Getvar(101)+3)
M99

the change of placement  of m99 generates a compile error.  Why???  I want to adjust #vars in g code program using conditional logic in my macro but when I embed my working setvar/getvar  in a simple  IF- Then- End if, I get compile and syntax errors in the Msg bar on the mach3 screen - the script writer (debugger) provides no clue as to what is generating the errors. I have tried placing the m99 at every conceivable location/s but to know avail.   NFS help desk banished be to the forums for a solution.  I hope that stepping into this thread isn't violating forum etiquette. If so, please offer kindly guidance on where to start. Thanks!
Title: Re: vb script tutorial help
Post by: TPS on July 19, 2019, 02:12:29 AM
setvar(100,Getvar(101)+3)
Code "M99"

Title: Re: vb script tutorial help
Post by: BR549 on July 30, 2019, 06:28:34 PM
What exactly are you hoping to do with teh M99 call?? Teh M99 cal is  a Gcode call to return to teh M98 calling line. It does nothing in a macro as there is nothing to return to. IF you are trying to return to teh Gcode program you would use

Code"M98 Pnnn" where nnn is teh Oword marker you place in teh Gcode program as a return point which is placed on teh line after teh conditional macro call. OR where ever you want to return to in teh gcode

Hope that helps, (;-) TP