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

Text files

Status
Not open for further replies.

foleys

Technical User
Apr 16, 2003
33
0
0
US
I am trying to install a script that calls 3 text files up. I have stored the files in the aspect folder of procomm, but the script fails when it gets to the point of calling the file.

Can anyone see where i am going wrong.

proc main

string tn
string mem
string des

if fopen 0 "tn.txt" read
if fopen 1 "mem.txt" read
if fopen 2 "des.txt" read
while not feof 0
fgets 0 tn
fgets 1 mem
fgets 2 des

transmit "new^M"
waitfor "TYPE "
transmit "did^M"
waitfor "TN "
transmit tn
waitfor "DES "
transmit des
waitfor "PDCA "
transmit "2^M"
waitfor "PCML "
transmit "a^M"
waitfor "cust"
transmit "o^m"
waitfor "NCOS "
transmit "7^M"
waitfor "RTMB "
transmit "0 "
transmit mem
waitfor "NITE "
transmit "^M"
waitfor "AST "
transmit "^M"
waitfor "CLS "
transmit "unr dtn^M"
waitfor "TKID "
transmit "^M"
waitfor "req"
pause 2
endwhile
else
endif
endif
endif
endproc
 
Are you receiving an error message of some sort? You might also try adding the TEXT keyword to the end of the three fopen commands as it will strip out carriage returns and linefeeds from the line read from the text files.

 
But then you need to replace a line like
Code:
transmit des
with
Code:
transmit des
transmit "^M"
I prefere using DDE to read such info from a excel-file
and using it as input to the script.
Spreadsheets are much easyer to create and edit.
But thats my personal oppinion ;-)

Check the help-function for examples on DDE usage.

HTH
 
late reply, i have had better results using a delimnited file then handling x numbers of files
Code:
proc main

   string sline, tn,key0,cpnd,key1,key2

   fopen 0 "3904.txt" READ               ;Open our data file
   while not feof 0                       ;While the file still has data
      fgets 0 sLine                       ;Read a line of data
      strtok tn sLine "`t" 1          ;Get the first field
      strtok key0 sLine "`t" 1          ;Get the second field
      strtok cpnd sLine "`t" 1          ;Get the third field
      strtok key1 sLine "`t" 1          ;Get the fourth field
      strtok key2 sLine "`t" 1          ;Get the fifth field
     ; strtok sTemp3 sLine "`t" 1          ;Get the sixth field
  
  set txpace 30
  waitfor "req:"
   transmit "new^M"
  waitfor "type"
   transmit "3904^M" 
  waitfor "tn  "
   transmit tn
   transmit "^M"
  waitfor "des"
   transmit "xxxx^M"
  waitfor "CUST"
   transmit "0^M"
  waitfor "KBA"
   transmit "^M"
  waitfor "dba"
   transmit "^M"
 waitfor "fdn"
   transmit "xxxxx^M"
 waitfor "tgar"
   transmit "^M"
 waitfor "ldn"
   transmit "^M"
 waitfor "ncos"
   transmit "5^M"
 waitfor "rnpg"
   transmit "^M"
 waitfor "ssu"
   transmit "^M"
 waitfor "xlst"
   transmit "^M"
 waitfor "sgrp"
   transmit "^M"
 waitfor "cls"
   transmit "LNA FNA HTA HFA MWA CNDA DNDA CFXA FTTU AHA^M"
 waitfor "rco"
   transmit "^M"
 waitfor "hunt"
   transmit "xxxxx^M"
 waitfor "lhk"
   transmit "0^M"
 waitfor "lnrs"
   transmit "^M"
 waitfor "sci"
   transmit "^M"
 waitfor "plev"
   transmit "^M"
 waitfor "ast"
   transmit "^M"
 waitfor "iapg"
   transmit "^M"
 waitfor "mlwu_lang"
   transmit "^M"
 waitfor "mlng"
   transmit "^M"
 waitfor "dndr"
   transmit "^M"
 waitfor "key  "
   transmit key0
   transmit "^M"
 waitfor "marp"
   transmit "^M"
 waitfor "cpnd"
   transmit "new^M"
 waitfor "name  "
   transmit cpnd
   transmit "^M"
 waitfor "vmb"
   transmit "^M"
 waitfor "key  "
   transmit key1
   transmit "^M"
 waitfor "marp"
   transmit "^M"
 waitfor "cpnd"
   transmit "^M"
 waitfor "vmb"
   transmit "^M"
 waitfor "key  "
   transmit key2
   transmit "^M"
 waitfor "marp"
   transmit "^M"
 waitfor "cpnd"
   transmit "^M"
 waitfor "vmb"
   transmit "^M"
 waitfor "key"
   transmit "3 adl^M"
 waitfor "key"
   transmit "4 adl^M"
 waitfor "key"
   transmit "5 adl^M"
 waitfor "key"
   transmit "6 csd^M"
 waitfor "key"
   transmit "7 adl^M"
 waitfor "key"
   transmit "8 adl^M"
 waitfor "key"
   transmit "9 adl^M"
 waitfor "key"
   transmit "10 adl^M"
 waitfor "key"
   transmit "11 adl^M"
 waitfor "key"
   transmit "16 mwk xxxxx^M"
 waitfor "key"
   transmit "24 nul^M"
 waitfor "key"
   transmit "25 nul^M"
 waitfor "key"
   transmit "26 nul^M"
   
  
   endwhile
   
   fclose 0

   
endproc


and you can look at compile options to open the debugger.. that tells you what line the file dies on.. even if it just freezes, when you stop it, you get a pop up to see what it was waiting for..

john poole
bellsouth business
columbia,sc
 
Thanks again I will have a go with this.
 
When I have a script that needs a lot of carrage returns, I often define a macro for the "transmit "^M" command

Like this

#DEFINE CR transmit "^M"

Then, for every line that you have transmit "^M", just use "CR".

This will also work with a line like this

transmit "10 adl"
CR

This saves the effort of entering transmit "^M" a bunch of times. Also, for me I find that I make fewer errors, as I don't forget the "^M" at the end of a transmit command
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top