:whatfile infile="*.in" ;Create template for a dialog box to prompt user hFP=FileOpen("adimport.dlg","WRITE") FileWrite(hFP,"[infile$ ]") FileWrite(hFP,"[infile\ ]") FileWrite(hFP,"[infile\ ]") FileWrite(hFP,"[infile\ ] [i^1Tab delimited file ]") FileWrite(hFP,"[infile\ ] [i^2Comma delimited file ]") FileWrite(hFP,"[infile\ ]") FileWrite(hFP,"[infile\ ]") FileWrite(hFP,"[infile\ ]") FileClose(hFP) DialogBox("AddrMan Converter","adimport.dlg") ;Pop up ye olde dialog box CRLF=strcat(num2char(13),num2char(10)) ;define a CRLF DELIMIT=Num2Char(9) ;setup delimiter DELIMITNAME="TABs" ;and a name for the same if i==2 then DELIMIT="," ;nope, delimites are really commas if i==2 then DELIMITNAME="COMMAs" ; and they are called commas count=0 ;initialize record count to zero infile = StrUpper(infile) ;Make file name all uppercase If FileExist(infile) == @FALSE Then Goto nofile ;Ooops can't find file if WinExist("Address") then goto runnin Message("AddrMan Converter","Address Manager not running. Get it going.") Exit :runnin WinActivate("Address") ;Activate Addrman f = FileOpen(infile, "READ") ;Open file for input :nextline l = FileRead(f) ;Read a line If (l == "*EOF*") Then Goto done ;All done??? if count>0 then goto contin dummy=strscan(l,DELIMIT,1,@FWDSCAN) ;Check first line. Can we even find a delimiter? if dummy!=0 then goto doit ;Delimiter found. All is hunky dorey ;No delimiter. User probably chose wrong file delim type Message("AddrMan Converter","%DELIMITNAME% not found in file %CRLF%Probably specified incorrectly") FileClose(f) ;Close file goto whatfile ; and let user try, try again :doit Sendkey("!ea!u!l") ;all looks good, get data entry dialog box up :contin linepointer=1 ;Initialize linepointer var maxpointer=strlen(l) ;Determine end of line varssent=0 ;No vars sent to dialog box for this line (yet) :nextvar thischar=strsub(l,linepointer,1) ;Get next character if thischar=='"' then goto scan4quote ;Is it a " if so, goto scan4quote nextpointer=strscan(l,DELIMIT,linepointer,@FWDSCAN) ;go find the next delimiter if nextpointer==0 then goto doneline ;Next delimiter no exist, must be doned thisvar=strsub(l,linepointer,nextpointer-linepointer) ;pick out the current variable linepointer=nextpointer+1 ;update current line pointer var goto sendit :scan4quote nextpointer=strscan(l,'"',linepointer+1,@FWDSCAN) ;Find next " if nextpointer==0 then goto doneline ;NO " ??????, oh well we must be done with this line thisvar=strsub(l,linepointer+1,nextpointer-linepointer-1) ;pick out the current variable linepointer=nextpointer+2 ;Update the current line pointer :sendit if strlen(thisvar)==0 then goto nextone ;send string to the sendkey cleaners.....cleanup special characters.. thisvar=strreplace(thisvar,'{','{{}') thisvar=strreplace(thisvar,'~','{~}') thisvar=strreplace(thisvar,'!','{!}') thisvar=strreplace(thisvar,'^','{^}') thisvar=strreplace(thisvar,'+','{+}') SendKey(thisvar) ;Pop variable into the clipboard :nextone SendKey("{TAB}") ;Splat clipboard data into field, and move to next field varssent=varssent+1 ;Increment count of vars splatted if varssent>=13 then goto doneline ;Have we filled the dialog box...If so ignore rest if linepointer>maxpointer then goto doneline ; if no data left one line....must be done.... goto nextvar ;process next field :doneline count=count+1 ;Increment record count SendKey("!a") ;Use SendKey push the "Another" button Goto nextline ;And do the next record :done FileClose(f) ;All doned, close file Message("Processing complete", "%count% records imported from %infile%") Exit ;Bye Bye