Mach3 - use variables in Cyprus VB

http://www.machsupport.com/MachCustomizeWiki/index.php?title=Mach_specific_Subs/Funcs_-_deprecated#Interrogating_Mach3_internal_variables

Used to check parts counter macro, ie if > 32 then stop with dialog

 

Use GetParam & SetParam to access:

"ZMachine" = Z Mach Positions (G53 Coordinates)

"XMachine" = X Mach Positions (G53 Coordinates)

"YMachine" = Y Mach Positions (G53 Coordinates)

"XDRO" = current X position per current offset

"YDRO" = current Y position per current offset

http://www.machsupport.com/MachCustomizeWiki/index.php?title=Get/SetParam%28%29_Vars

 

Access to the machine G-code parameter block

Mach3 has a block of variables which can be used in part programs. They are identified by # followed by a number (the parameter address). The contents of the Tool and Fixture tables are in these parameters but there are many values that can be used by the writer of a part program. These machine variables can be accessed within macros by GetVar and SetVar.

Function GetVar (PVarNumber as Integer) as Double
Sub SetVar (PVarNumber as Integer, newVal as Double)

The predefined parameter variables are defined the manuals Using Mach3Mill and Using Mach3Turn.

Examples:

FixNumb = GetVar (5220)	' get current fixture number
Rem set X offset of fixture 2 to be same as fixture 1
Call SetVar (5241, GetVar (5221))
Rem increment a counter, say in a multiple part layout
Call SetVar (200, GetVar (200) + 1))

Interrogating Mach3 internal variables

The current value of Mach3 internal variables can be read using the GetParam function.

Function GetParam (name as String) as Double

This returns a numeric value corresponding to the name of the given variable which is provided as a string (constant or variable)

The corresponding routine SetParam sets the value of the variable to newVal.

Sub SetParam (name as String, newVal as Double)

Examples:

Rem interrogate drive arrangements
mechProp1 = GetParam ("StepsPerAxisX")
Rem make C acceleration be same as X for slaving
Call SetParam("AccelerationC", GetParam ("AccelerationX"))

Notice that the word "Param" is used here in a different sense to the Machine Parameters accessed by the # operator from within a part program and in accessing the Q, R & S word "parameters" to a macro call.

 

 

Access to the machine G-code parameter block

Mach3 has a block of variables which can be used in part programs. They are identified by # followed by a number (the parameter address). The contents of the Tool and Fixture tables are in these parameters but there are many values that can be used by the writer of a part program. These machine variables can be accessed within macros by GetVar and SetVar.

Function GetVar (PVarNumber as Integer) as Double
Sub SetVar (PVarNumber as Integer, newVal as Double)

The predefined parameter variables are defined the manuals Using Mach3Mill and Using Mach3Turn.

Examples:

FixNumb = GetVar (5220)	' get current fixture number
Rem set X offset of fixture 2 to be same as fixture 1
Call SetVar (5241, GetVar (5221))
Rem increment a counter, say in a multiple part layout
Call SetVar (200, GetVar (200) + 1))

 

Arguments of macro call

When a macro is called from the MDI line or within a part program then data can be passed to it by P, Q, and S words on the line. The values of these words are "read" in the macro using the Param functions.

Function Param1 () as Double ' gets P word
Function Param2 () as Double ' gets Q word
Function Param3 () as Double ' gets S word

 

 

Information to and from the user

Scripts can communicate with the operator by displaying a dialog box with a prompt into which the user can type numeric data. The Question function prompts for one item. The GetCoord routine prompts for the values of X, Y, Z and A coordinates.

Refer here to MsgBox etc built-in VB Script calls !!!

The other strategy, probably more suited to scripts attached to buttons, is to provide DROs of a screen into which data is set before running the macro. These can of course also display results from the script.

User Intelligent Labels and Tickers enable messages to be displayed.

 

 

Dialog boxes

 

Function Question (prompt as String) as Double

The string in prompt is displayed in a modal dialog titled "Answer this. The dialog contains an edit box. The value of the function is set to the number in this when OK is clicked.

Sub GetCoord (prompt as String)

As with Question, a modal dialog titled "Enter Coordinates" displays prompt. This has four edit boxes labelled X, Y, Z and A into which values can be typed. GetCoord itself does not return the values to the macro code. These must be fetched by GetXCoor, GetYCoor etc.

Function GetXCoor () as Double
Function GetYCoor () as Double
Function GetZCoor () as Double
Function GetACoor () as Double