Problems using constructor and distructor to save current...

This is where you talk about Macros, show examples of your macro scripting and SHARE handy segments of script code as examples.

Re: Problems using constructor and distructor to save curren

Postby cncdrive » Wed Apr 25, 2018 10:16 am

If in the Default.pro file you have the code above, at UCCNC starup, when try to read the value of this key you'll get un exception.


Well, in that case still not the Readkey function will throw the exception, but your Int32 conversion.
If the key is defined but it's value is empty "", then the software will read the empty string value, the Readkey will not throw an exception,
but when you trying to convert the empty string to Int32 that will throw an exception.
For this scenario you can really use an exception handling or a TryParse, like:

Code: Select all
int variable = 0;
int.TryParse(stringValue, out variable);


If the string value can't be parsed to integer type then the value will be the value before the TryParse which is 0 in the above example.
cncdrive
Site Admin
 
Posts: 2000
Joined: Tue Aug 12, 2014 11:17 pm

Re: Problems using constructor and distructor to save curren

Postby kig23 » Wed Apr 25, 2018 10:47 am

Thanks for your replay.
kig23
 
Posts: 57
Joined: Sat Mar 31, 2018 6:58 am

Previous

Return to Macros

Who is online

Users browsing this forum: No registered users and 1 guest