Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select vlaue in a string after a waitfor

Status
Not open for further replies.

Catoal

Technical User
Feb 15, 2005
13
BE
Hi all,

For a script I need to take a value in a string received from my meridian to use it afterwards as a variable.

Exemple
DCH : XX RLS NO RESPONSE

while 1
waitfor "rls no repsonse"
define/store XX as a variable
...
transmit "LD96^M"
waitfor "."
transmit "rls dch XX^M"
...

Can anyone help?
 
Is "DCH" a unique string you can key off of and will always be present? If so, you could use the waitfor command (may need to add the FOREVER flag or a suitable timeout value in seconds, depending on how long it takes for the message to appear) to search for DCH. You can then use the three lines below to get the value (XX in your case) into the string variable called sValue:

rget sMsg
strextract sValue sMsg ":" 1
strextract sValue sValue " " 1

 
TERMGETS is useful for extracting specific info from the screen.
Also, WHENTARGET might be better to use than WAITFOR


integer cursrow = 0
integer curscol = 0
string TmpStrAA
string TmpStrBB


while 1
waitfor "RLS NO RESPONSE"

;define/store XX as a variable
;the following line may be needed if the cursor moves DN
cursrow -- ;go back up one line from current position

getcur cursrow curscol ;get current cursor co-ordinates
termgets cursrow 6 TmpStrBB 2 ;get XX value from that line

transmit "LD96^M"
waitfor "."

string TmpStrAA = "rls dch "
strcat TmpStrAA TmpStrBB
TmpStrBB = "^M"
strcat TmpStrAA TmpStrBB
transmit TmpStrAA

yield
endwhile
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top