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!

How to use TRANSMIT with array values

Status
Not open for further replies.

tipster222

Technical User
Mar 23, 2005
5
US
This is from a sample script in Procomm that I modify. After storing the information in each array, I like to use the values with using Transmit of each value in the array. Something like:
Transmit clli[1] and Transmit Tgrp[1]. This do not work, what is the correct format or do you know any other way to get around with this? Thanks in advance.

string Clli[13] ; Declare string array with 10 elements.
proc main
string FName
integer Tgrp[13] ; Declare integer array with 10 elements.
integer Count = 0 ; Variable subscript used to reference our
; arrays.
string szLine ; Variable to store line from file.
string szTemp ; Temporary variable used for Age.
if isfile FName
if fopen 0 "NAMES.LST" READ
; Open Clli file for read only.
while not feof 0 ; Loop while we’re not at end of the file.
fgets 0 szLine ; Get a line from the file and extract the
; Clli and Tgrp.
strtok Clli[Count] szLine "," 1
strtok szTemp szLine "," 1
atoi szTemp Tgrp[Count]
; Convert Tgrp to integer and put

; it into our Tgrp array.
if (Count += 1) == 13
; Increment array subscript and make
exitwhile ; sure that we don’t increment past the
endif ; last elements in the two arrays .
endwhile
fclose 0 ; Close our file of Clli and Tgrp.
else ; Display a message if an error occurred.

errormsg "Couldn’t open NAMES.LST for input!"
endif

endif

endproc
 
I used the test script below and it was able to send a member of the string array successfully:

string Clli[13] ; Declare string array with 10 elements.
proc main
Clli[1] = "foo"
transmit Clli[1]
endproc

My guess would be that your data is either not being read from the file correctly or the strtok commands are giving you different results than expected.


 
Thanks Knob. What I'm trying to do is to read two sets of data from a file. Right now, I have this script where user must input data individually. I want to be able to store the data in a file and read from it. Using Arrays is probably just one option, any help or tips is greatly helpful.

sdlginput "TGNO" "Enter TG Number:" TGNO ;User input 1st data
sdlginput "CLLI" "Enter Clli:" CLLI ;User input 2nd data
transmit "^M"
waitfor "TGNO="
transmit TGNO ;Transmit first data input
transmit "^M"
waitfor "TGNAME="
transmit CLLI ;Transmit second data input
transmit ";^M"
waitfor "EXEC'D"
transmit "^M"
waitfor "<
 
knob,
The data is similar to this except its 13 elements instead of just 4, it's store in a file called NAMES.LST:
Bob Jennings,35
Frosty T. Snowman,1
Joseph Risingstar,18
E.L. Capitan,51


I don't really have complete working script, sorry for the confusion. Where should the NAMES.LST suppose located? Also, how can I display the output just to test, I tried with using usermsg but nothing happened. Thanks.
P.S. I've created a second script to read two separate files without array somewhat working that I'm using now.
 
OK, instead of strtok I would recommend using the strextract command since that won't alter the string you are reading from like strtok.

As for the location of the file, since you have no path information in the fopen command, the script will look for it in the ASPECT directory under your Procomm install.

One other thing you will want to do is add the TEXT flag to your fopen command. This will strip out any carriage returns and linefeeds from the string while the script is working with it.

Actually, once I made the above change and ran through the script in the debugger, it looked like the data was being read correctly from NAMES.LST (so you can ignore what I mentioned earlier about strextract). Here is a link to a page on my site that shows how to use the debugger to view variables while the script is running, I sometimes find it easier to use than usermsg commands but I've been using it for awhile:


 
knob,
I haven't forgotten your valuable pointers and helps. I just have so many things going on right now. I'll come back to your suggestions once my other project is done. Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top