Machsupport Forum

Mach Discussion => VB and the development of wizards => Topic started by: rrc1962 on October 27, 2011, 09:19:44 AM

Title: User Label
Post by: rrc1962 on October 27, 2011, 09:19:44 AM
Guys...Is there any way to make a user label persistent?  If I set it's value then close and reopen Mach, the user label is blank.   Thanks
Title: Re: User Label
Post by: ger21 on October 27, 2011, 11:50:20 AM
Create a macro to fill it in and put the macro in your initialization string?? Not ideal, and maybe won't even work correctly.
Title: Re: User Label
Post by: rrc1962 on October 27, 2011, 12:19:52 PM
Create a macro to fill it in and put the macro in your initialization string?? Not ideal, and maybe won't even work correctly.

That probably won't work.  No way to know what to fill it with as the user can change the label any time.  I could write it to a text file, then open the text file to populate the label. 

How do I use the initialization string?  Is that something that fires when Mach opens?
Title: Re: User Label
Post by: Graham Waterworth on October 28, 2011, 03:37:44 AM
You could hard code it into the Macropump
Title: Re: User Label
Post by: BR549 on October 28, 2011, 12:07:47 PM
The init string runs anytime Mach3 resets such as startup and reset.

You create a Mcode (example M1099) then put in what CB code is required AND include that Mcode in the init string.

Mach will then apply what was in the code to mach if/when it resets.

I take it the lable info is NOT numeric and you cannot use a dro?

(;-) TP

Title: Re: User Label
Post by: rrc1962 on October 30, 2011, 09:12:58 PM
The init string runs anytime Mach3 resets such as startup and reset.

You create a Mcode (example M1099) then put in what CB code is required AND include that Mcode in the init string.

Mach will then apply what was in the code to mach if/when it resets.

I take it the lable info is NOT numeric and you cannot use a dro?

(;-) TP



Yes...It is non numeric...unfortunately.
Title: Re: User Label
Post by: zealous on November 02, 2011, 07:55:51 PM
Scott posted this awhile ago but the search function in Mach's forum is broken
Just change the location of "UserLabel.AGD" to store the Userlabels when you close Mach3, maybe make a Save button.
I dont rember if Mach3 has a Mcode that gets fired off when you shut it down, but if there is one you can put this script in there to store the userlabels.

Code: [Select]
UserLabels = 1
Open "C:\\Program Files\\AGD\\UserLabel.AGD" For Output As #6
For z = 1 To 250
LabelState = GetUserLabel(UserLabels)
Print  #6, LabelState
UserLabels = (UserLabels + 1)
Next z
Close #6
Code("SAVE_XML")


Put this in a Macro to load the stored labels:

Code: [Select]
Dim fich3 As String
fich3="C:\Program Files\AGD\UserLabel.AGD"
If Dir(fich3)<>""  Then
Call Dir("null")
UserLabels = 1
Open "C:\Program Files\AGD\UserLabel.AGD"  For Input As #5
Do While Not EOF(5)
Line Input #5, FileData
SetUserLabel(UserLabels, FileData)
UserLabels = UserLabels + 1
Loop
Close #5
Else
Call Dir("null")
MsgBox("no file to load:" & fich3)
End If

otherwise you'll have to request that Mach3 stores user/Labels in the XML.
Title: Re: User Label
Post by: JANE on November 09, 2014, 11:49:26 AM
Hi, everybody, I try to add label to my screen and will need to change the label dynamically , I learned from mach3 v3 programmer's manual, I should be able to do it in vb script( setuserlabel(number,"text"), but the problem is, in screen4,when I add the label to the screen, I do not get a label number and I can not give it a number either, can anyboby give me a hint? Thank you very much for your help!
Title: Re: User Label
Post by: leversole on March 13, 2016, 02:06:03 PM
Old post, but I learned the answer, maybe will help someone out....
When you create your label, the text should be "UserLabel" + some integer from 1 to 255...for example "UserLabel50"
Now your code and Mach3 have access to read and write, just like a DRO...

To write to it, simply call SetUserLabel(50, "some such text"), read it if someone entered into it, use GetUserLabel...

Leslie
Title: Re: User Label
Post by: zealous on March 13, 2016, 07:16:07 PM
you don't need to get the label value, if you put the text box var as _root.USERLABEL********* and you can use 0 - 3000.

also here are some more labels

VB Label:            Flash Label

"COSYS"            _root.Cosys
"TOOLDESC"         _root.ToolDesc
"UNITREVMIN"      _root.UnitRev
"UserLabel#"         _root.USERLABEL#
"Error"            _root.StatusLine
"RADDIA"         _root.RadDia
"Mode"            _root.Mode
"Profile"            _root.Profile
"File"            _root.FileName