How to reset a User-String-Variable #300 - #399?
Moderator: cnckeith
-
- Posts: 603
- Joined: Wed Aug 29, 2018 11:15 am
- Acorn CNC Controller: Yes
- Allin1DC CNC Controller: No
- Oak CNC controller: No
- CNC Control System Serial Number: 985DADEB24D5-0309180716
- DC3IOB: No
- CNC11: No
- CPU10 or CPU7: No
How to reset a User-String-Variable #300 - #399?
As the title says, I'm struggling to find a way to reset user-string-variables #300 - #399. These variables keep their value until you quit CNC12, so good practice would be to reset them when you no longer need them.
I tried the usual way #300 = "" to assign a zero-length string but CNC12 does not like that and gives an error "501 Invalid character".
The only way I found is to set the variable to #300 = " " but that assigns a single blank to the variable and messes up my output strings if the variable is not getting filled and should output a zero length string.
Does anybody know how to reset these variables without closing CNC12 and restart it?
-swissi
I tried the usual way #300 = "" to assign a zero-length string but CNC12 does not like that and gives an error "501 Invalid character".
The only way I found is to set the variable to #300 = " " but that assigns a single blank to the variable and messes up my output strings if the variable is not getting filled and should output a zero length string.
Does anybody know how to reset these variables without closing CNC12 and restart it?
-swissi
If you are using any Probing Device, a Rack ATC or want a more efficient Work Flow, check out CHIPS
Contact me at swissi2000@gmail.com
Contact me at swissi2000@gmail.com
(Note: Liking will "up vote" a post in the search results helping others find good information faster)
-
- Posts: 78
- Joined: Tue Apr 17, 2018 8:58 am
- Acorn CNC Controller: Yes
- Allin1DC CNC Controller: No
- Oak CNC controller: No
- CNC Control System Serial Number: none
- DC3IOB: No
- CNC11: No
- CPU10 or CPU7: No
Re: How to reset a User-String-Variable #300 - #399?
I assume your are trying to modify your PLC? Could you please post a report and explain what you are trying to do?
(Note: Liking will "up vote" a post in the search results helping others find good information faster)
-
- Posts: 603
- Joined: Wed Aug 29, 2018 11:15 am
- Acorn CNC Controller: Yes
- Allin1DC CNC Controller: No
- Oak CNC controller: No
- CNC Control System Serial Number: 985DADEB24D5-0309180716
- DC3IOB: No
- CNC11: No
- CPU10 or CPU7: No
Re: How to reset a User-String-Variable #300 - #399?
Not trying to modify the PLC. Just trying to reset a user-string-variable back to zero-length.
Here's an example:
The first message displays as expected:
and the second message has that space between string 1 and string 3.
So the question is: How to I reset variable #302 back to zero-length so it doesn't print a space between string 1 and string 3?
-swissi
Here's an example:
Code: Select all
;------------------------------------------------------------------------------
; Filename: test.cnc
; VARIABLES USED
; #301 - String Variable 1
; #302 - String Variable 2
; #303 - String Variable 3
#101 = 0 ; How many seconds a message should be displayed. 0 is indefinitely and needs to be confirmed with Cycle Start
;------------------------------------------------------------------------------
#301 = "ABCDE"
#302 = "FGHIJ"
#303 = "KLMNO"
M225 #101 "#)The combined string is: %s%s%s\n\n Press Cycle Start to continue\n" #301 #302 #303
#302 = " "
M225 #101 "#)The combined string is: %s%s%s\n\n Press Cycle Start to continue\n" #301 #302 #303
M99 ; Return to calling job/macro
and the second message has that space between string 1 and string 3.
So the question is: How to I reset variable #302 back to zero-length so it doesn't print a space between string 1 and string 3?
-swissi
If you are using any Probing Device, a Rack ATC or want a more efficient Work Flow, check out CHIPS
Contact me at swissi2000@gmail.com
Contact me at swissi2000@gmail.com
(Note: Liking will "up vote" a post in the search results helping others find good information faster)
-
- Posts: 109
- Joined: Mon Jan 15, 2018 1:11 am
- Acorn CNC Controller: Yes
- Allin1DC CNC Controller: No
- Oak CNC controller: Yes
- CNC Control System Serial Number: A900712
- DC3IOB: No
- CNC12: Yes
- CNC11: No
- CPU10 or CPU7: No
Re: How to reset a User-String-Variable #300 - #399?
Does setting them to zero (the number) work?
(Note: Liking will "up vote" a post in the search results helping others find good information faster)
-
- Posts: 15
- Joined: Sat Feb 09, 2019 10:13 pm
- Acorn CNC Controller: Yes
- Allin1DC CNC Controller: No
- Oak CNC controller: No
- CNC Control System Serial Number: none
- DC3IOB: No
- CNC12: Yes
- CNC11: No
- CPU10 or CPU7: No
- Location: Monroe Michigan USA
Re: How to reset a User-String-Variable #300 - #399?
Just don't call #302. Omit it until you want it. See the second to last line.swissi wrote: ↑Thu May 09, 2019 4:51 pm Not trying to modify the PLC. Just trying to reset a user-string-variable back to zero-length.
Here's an example:
The first message displays as expected:Code: Select all
;------------------------------------------------------------------------------ ; Filename: test.cnc ; VARIABLES USED ; #301 - String Variable 1 ; #302 - String Variable 2 ; #303 - String Variable 3 #101 = 0 ; How many seconds a message should be displayed. 0 is indefinitely and needs to be confirmed with Cycle Start ;------------------------------------------------------------------------------ #301 = "ABCDE" #302 = "FGHIJ" #303 = "KLMNO" M225 #101 "#)The combined string is: %s%s%s\n\n Press Cycle Start to continue\n" #301 #302 #303 #302 = " " M225 #101 "#)The combined string is: %s%s%s\n\n Press Cycle Start to continue\n" #301 #302 #303 M99 ; Return to calling job/macro
Cap1.JPG
and the second message has that space between string 1 and string 3.
Cap2.JPG
So the question is: How to I reset variable #302 back to zero-length so it doesn't print a space between string 1 and string 3?
-swissi
Code: Select all
;------------------------------------------------------------------------------
; Filename: test.cnc
; VARIABLES USED
; #301 - String Variable 1
; #302 - String Variable 2
; #303 - String Variable 3
#101 = 0 ; How many seconds a message should be displayed. 0 is indefinitely and needs to be confirmed with Cycle Start
;------------------------------------------------------------------------------
#301 = "ABCDE"
#302 = "FGHIJ"
#303 = "KLMNO"
M225 #101 "#)The combined string is: %s%s%s\n\n Press Cycle Start to continue\n" #301 #302 #303
#302 = " "
M225 #101 "#)The combined string is: %s%s\n\n Press Cycle Start to continue\n" #301 #303
M99 ; Return to calling job/macro
(Note: Liking will "up vote" a post in the search results helping others find good information faster)
-
- Community Expert
- Posts: 3539
- Joined: Tue Mar 22, 2016 10:03 am
- Acorn CNC Controller: Yes
- Allin1DC CNC Controller: Yes
- Oak CNC controller: Yes
- CNC Control System Serial Number: 100505
100327
102696
103432
7804732B977B-0624192192 - DC3IOB: No
- CNC12: Yes
- CNC11: No
- CPU10 or CPU7: No
- Location: Boston, MA
- Contact:
Re: How to reset a User-String-Variable #300 - #399?
My guess is they are using a null (\0) as the end of string character. You could try $0, but the manual specifically states only ASCII codes 65-90 are allowed.
The only other thing I could think of is to reserve one string variable that you never use and assign that to clear your variable.
The only other thing I could think of is to reserve one string variable that you never use and assign that to clear your variable.
Code: Select all
;------------------------------------------------------------------------------
; Filename: test.cnc
; VARIABLES USED
; #301 - String Variable 1
; #302 - String Variable 2
; #303 - String Variable 3
; #399 - Reserved String Variable (do not use)
#101 = 0 ; How many seconds a message should be displayed. 0 is indefinitely and needs to be confirmed with Cycle Start
;------------------------------------------------------------------------------
#301 = "ABCDE"
#302 = "FGHIJ"
#303 = "KLMNO"
M225 #101 "#)The combined string is: %s%s%s\n\n Press Cycle Start to continue\n" #301 #302 #303
#302 = #399
M225 #101 "#)The combined string is: %s%s%s\n\n Press Cycle Start to continue\n" #301 #302 #303
M99 ; Return to calling job/macro
Cheers,
Tom
Confidence is the feeling you have before you fully understand the situation.
I have CDO. It's like OCD, but the letters are where they should be.
Tom
Confidence is the feeling you have before you fully understand the situation.
I have CDO. It's like OCD, but the letters are where they should be.
(Note: Liking will "up vote" a post in the search results helping others find good information faster)
-
- Posts: 603
- Joined: Wed Aug 29, 2018 11:15 am
- Acorn CNC Controller: Yes
- Allin1DC CNC Controller: No
- Oak CNC controller: No
- CNC Control System Serial Number: 985DADEB24D5-0309180716
- DC3IOB: No
- CNC11: No
- CPU10 or CPU7: No
Re: How to reset a User-String-Variable #300 - #399?
Thanks guys for all the suggestions but none of them seems to work. Even assigning one string variable to another generates a "501 Invalid character" error.
I hope nobody will argue that resetting a variable is an essential and basic function in any programming language. Especially so when the variables are global and will only be reset when the program is exited.
So my guess is that the fact that CNC12 generates an error when trying to set a string variable = "" was an oversight of the programmer who wrote the "check string for legal character" function.
Centroid can you please fix that?
-swissi
I hope nobody will argue that resetting a variable is an essential and basic function in any programming language. Especially so when the variables are global and will only be reset when the program is exited.
So my guess is that the fact that CNC12 generates an error when trying to set a string variable = "" was an oversight of the programmer who wrote the "check string for legal character" function.
Centroid can you please fix that?
-swissi
If you are using any Probing Device, a Rack ATC or want a more efficient Work Flow, check out CHIPS
Contact me at swissi2000@gmail.com
Contact me at swissi2000@gmail.com
(Note: Liking will "up vote" a post in the search results helping others find good information faster)
-
- Posts: 809
- Joined: Mon Feb 19, 2018 2:52 pm
- Acorn CNC Controller: Yes
- Allin1DC CNC Controller: No
- Oak CNC controller: No
- CNC Control System Serial Number: 38D269594F9C-0110180512
- DC3IOB: No
- CNC12: Yes
- CNC11: No
- CPU10 or CPU7: No
- Location: UK
- Contact:
Re: How to reset a User-String-Variable #300 - #399?
That's damned annoying. I think this arises partly because macro variables are initially "null" ie they don't even have a zero or any other value when initialised. So if you can't ascribe a null value to them without power cycling, there is no way around it. I guess you would need to be able to set the variables to ASCII value 0 which is the null character.
(Note: Liking will "up vote" a post in the search results helping others find good information faster)
-
- Site Admin
- Posts: 8940
- Joined: Wed Mar 03, 2010 4:23 pm
- Acorn CNC Controller: Yes
- Allin1DC CNC Controller: Yes
- Oak CNC controller: Yes
- CNC Control System Serial Number: none
- DC3IOB: Yes
- CNC11: Yes
- CPU10 or CPU7: Yes
- Contact:
Re: How to reset a User-String-Variable #300 - #399?
please tell me the goal of project? we are trying to understand your application for this..thanks..Muzzer wrote: ↑Sun May 12, 2019 1:22 pm That's damned annoying. I think this arises partly because macro variables are initially "null" ie they don't even have a zero or any other value when initialised. So if you can't ascribe a null value to them without power cycling, there is no way around it. I guess you would need to be able to set the variables to ASCII value 0 which is the null character.
Need support? READ THIS POST first. http://centroidcncforum.com/viewtopic.php?f=60&t=1043
All Acorn Documentation is located here: viewtopic.php?f=60&t=3397
Answers to common questions: viewforum.php?f=63
and here viewforum.php?f=61
Gear we use but don't sell. https://www.centroidcnc.com/centroid_di ... _gear.html
All Acorn Documentation is located here: viewtopic.php?f=60&t=3397
Answers to common questions: viewforum.php?f=63
and here viewforum.php?f=61
Gear we use but don't sell. https://www.centroidcnc.com/centroid_di ... _gear.html
(Note: Liking will "up vote" a post in the search results helping others find good information faster)
-
- Community Expert
- Posts: 3539
- Joined: Tue Mar 22, 2016 10:03 am
- Acorn CNC Controller: Yes
- Allin1DC CNC Controller: Yes
- Oak CNC controller: Yes
- CNC Control System Serial Number: 100505
100327
102696
103432
7804732B977B-0624192192 - DC3IOB: No
- CNC12: Yes
- CNC11: No
- CPU10 or CPU7: No
- Location: Boston, MA
- Contact:
Re: How to reset a User-String-Variable #300 - #399?
Keith,
It looks like swissi is just trying to apply good programming practice to his macro files. Since string variables are global and only cleared on restart of the machine, he wants to clear them after he is done using them so that the next macro to use the variable (if it happens before the machine is restarted) does not potentially get bad data. Unlike the numerical variables, there currently is not a way to set a string variable to it's initial "empty" state.
It looks like swissi is just trying to apply good programming practice to his macro files. Since string variables are global and only cleared on restart of the machine, he wants to clear them after he is done using them so that the next macro to use the variable (if it happens before the machine is restarted) does not potentially get bad data. Unlike the numerical variables, there currently is not a way to set a string variable to it's initial "empty" state.
Cheers,
Tom
Confidence is the feeling you have before you fully understand the situation.
I have CDO. It's like OCD, but the letters are where they should be.
Tom
Confidence is the feeling you have before you fully understand the situation.
I have CDO. It's like OCD, but the letters are where they should be.
(Note: Liking will "up vote" a post in the search results helping others find good information faster)