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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Capture Data from Screen to Variable

Status
Not open for further replies.

Peddlerty

IS-IT--Management
Feb 11, 2003
6
GB
Hi,

I am trying to automate some tasks with Aspect ... I need somehow capture(read) a string from my Procomm Terminal and store it in a variable. I would then need to reprint that string back into the terminal, once I navigate to certain location.

I included a screenshot of what I am looking to do, which you can find here:
I would really appreciate any advice or at least a nudge in the right direction.

Thanks,

Tim
 
Below is the way that I do it:
This pulls data from 3 different lines and puts the data into an array.
Use the locate for screen location I use y to locate the vertical of the screen and 3 for the horizontal so you have to find your placement. I do it by playing around with it using usermsg to display what I have in the array
use the termreads to capture the data and the number at end is amount of data to capture.

proc screen
integer getnum=0, y=9

clear
pause 1
for getnum = 0 upto 3
locate y, 3
termreads data[getnum] 19
y++
endfor
endproc

If you need any more help let me know. To go where no programmer has gone before.
 
That was easy ... thanks a lot dbsquared.

I have one more problem though, the part numbers that I use the termreads on, have varying number of characters. For instance, one will be 128-1231AL while another 300-123. The max number of characters in a part number is 12, so I currenty have termreads capture 12 characters to the string array. I need a way to edit each string captured so it only termwrites the actual characters and not the blank spaces that get picked up if the part number is less the 12 characters long.

Any suggestions

Tim
 
Nevermind on that last question ... I tried using SendkeyStr and it seems to be working fine ... I guess I should read the docs more :)

 
Maybe not :( ... It is sending the keys fine now ... but I still need a way to delete the non-character portions of the string that get picked up if the part number is under 12 chars.

-Tim
 
Here is a function I used in the past to strip leading spaces from a string:

func StripSpaces : string
param string targetline
integer str_length

strlen targetline str_length ;Get length of string

while str_length > 0 ;While the string has at least one character in it...
if rstrcmp targetline " " 1 ;Compare the first character in the string to a space
strdelete targetline 0 1 ;If the first character is a space, delete it from the string
else
exitwhile ;Else exit the while loop
endif
endwhile

return targetline ;Return modified string
endfunc

If you use the strrev command on the string you read from the screen, call this function, then use strrev on the result, it will work to strip trailing spaces in your string.
aspect@aspectscripting.com
 
Thanks knob ... seems to work like a charm.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top