HKJ,
Sorry to bother you but I am stuck.
I am trying to select some text in a comma separated list in a string. For example, I have the string:
PL.FB [Counts],VL.FB [rpm],il.fb [Arms],VBUS.VALUE [Vdc],fb1.mechpos [Counts],AIN.VALUE [V]
and I want to select one of them. Looking at the available commands I thought I could do:
getMatchGroup(value, "[^,]+", 2)
as an attempt to get the second matching group which is "VL.FB [rpm]". RegEx "[^,]+" seems to work giving 6 matches as expected. Unfortunately doing this getMatchGoup() yields Java errors like the partial list of errors below.
dk.hkj.script.ProgramExceptions$UnknownException:
getMatchGroup(value, "[^,]+",2)____<----____
at dk.hkj.script.Script.expression(Script.java:1193)
at dk.hkj.devices.DeviceAscii$TranslatingCommInterface.write(DeviceAscii.java:297)
at dk.hkj.comm.CommInterface.writeRead(CommInterface.java:106)
at dk.hkj.main.SCPICommand.writeReadDelay(SCPICommand.java:156)
at dk.hkj.main.SCPICommand.writeReadInternal(SCPICommand.java:199)
I then tried various combinations of RegEx espression and getMatchGroup command and could not get the second or third, etc. I could only ever get getMatchGroup(value, "RegEx", 1) to work giving the first match "PL.FB [Counts]".
Even more curious, on one of the variations to the :readmath: that I tried
getMatch(value, "([^,]+)(\[\w*\]+)")
I got no Java errors but a communications time out? Not sure how a change to a :readmath: after data is received can cause a Rx Timeout.
;; AKD2GS: Tx <getunitsch2?>
;; AKD2GS: Tx <txrxn? 3 REC.RETRIEVEHDR>
;; 192.168.1.193: Tx: <REC.RETRIEVEHDR..> 52 45 43 2E 52 45 54 52 49 45 56 45 48 44 52 0D 0A
;; 192.168.1.193: Rx: <Recording> 52 65 63 6F 72 64 69 6E 67 0D
;; 192.168.1.193: Rx: <1,1> 31 2C 31 0D
;; 192.168.1.193: Rx: <axis1.pl.fb [Counts16Bit],axis1.vl.fb [rpm],axis1.il.fb [Arms],vbus.value [Vdc],fb3.mechpos [Counts],ain1.value [V]> 61 78 69 73 31 2E 70 6C 2E 66 62 20 5B 43 6F 75 6E 74 73 31 36 42 69 74 5D 2C 61 78 69 73 31 2E 76 6C 2E 66 62 20 5B 72 70 6D 5D 2C 61 78 69 73 31 2E 69 6C 2E 66 62 20 5B 41 72 6D 73 5D 2C 76 62 75 73 2E 76 61 6C 75 65 20 5B 56 64 63 5D 2C 66 62 33 2E 6D 65 63 68 70 6F 73 20 5B 43 6F 75 6E 74 73 5D 2C 61 69 6E 31 2E 76 61 6C 75 65 20 5B 56 5D 0D
;; AKD2GS: Rx Timeout
Can you give some examples of how getMatchGroup should be working and/or suggest how to get the individual comma separated items in the string list?