Active Fixture - Field 889

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

Active Fixture - Field 889

Postby Robertspark » Fri Sep 23, 2016 3:39 pm

This is a bit of a stange question, but I was wondering if: AS3.Getfield(899) , which is suppose to return the field value as a string could be changed from
"Active Fixture: G54" / "Active Fixture: G55" / "Active Fixture: G56" / "Active Fixture: G57" / "Active Fixture: G58" / "Active Fixture: G59"

to just return "G54", "G55", "G56", "G57", "G58" & "G59"

I have been failing to run a switch statement within a macro, and I'm guessing its because the switch statement is not happy with the "Active fixture:" part of the string returned?

I know on the Offsets tab the "Active fixture: G5x" is displayed, but is it required / can it be changed?

Thanks,

Rob

(i could probably use if /if else statements instead of switch)
Robertspark
 
Posts: 1892
Joined: Sat Sep 03, 2016 4:27 pm

Re: Active Fixture - Field 889

Postby cncdrive » Fri Sep 23, 2016 5:03 pm

Hi Rob,

Terry asked the same a week or so ago and I see 2 ways to get this info,
one is to check the 889 field the way you mentioned, but that contains a string with some text as you mentioned.
So, if you want to check it this string then do it with string.contains or string.indexof to see if G54 or G55 etc. is part of that string,
then you can decide which fixture is active even with the string contains more text not only the G54 or G55 etc.

Or you can read the buttonstate of the G54, G55 etc. buttons to get the information about which fixture is active.
cncdrive
Site Admin
 
Posts: 4887
Joined: Tue Aug 12, 2014 11:17 pm

Re: Active Fixture - Field 889

Postby Robertspark » Fri Sep 23, 2016 6:06 pm

Balazs, many thanks I tried using trim() but wasn't successful to truncate the string.

I'll have a go at either one of your solutions.
Robertspark
 
Posts: 1892
Joined: Sat Sep 03, 2016 4:27 pm

Re: Active Fixture - Field 889

Postby CNC22369 » Fri Sep 23, 2016 8:40 pm

I needed to do something similar in some macros and ended up with this alternate 4-line approach.
The following code displayed (2nd box) just the G5x part of the 899 string.

char[] delimiters = { ' ' }; //delimiter(s) used for string split (a space)
string actfix899 = AS3.Getfield(899); //read text field 899
MessageBox.Show(actfix899); //display field before split (for test purposes)
string[] actfixtemp = actfix899.Split(delimiters); //split string by delimiter(s)
string actfix = actfixtemp[2]; //grab G5x segment of split string array
MessageBox.Show(actfix); //display G5x string segment after split (for test purposes)

Frank
CNC22369
 
Posts: 35
Joined: Mon Sep 19, 2016 4:05 pm

Re: Active Fixture - Field 889

Postby Robertspark » Fri Sep 23, 2016 8:42 pm

Blimey, thanks Frank, much appreciated
Robertspark
 
Posts: 1892
Joined: Sat Sep 03, 2016 4:27 pm


Return to Macros

Who is online

Users browsing this forum: Google [Bot] and 7 guests

cron