Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
STRTRAN not working
Message
De
13/06/2003 11:05:21
 
 
À
13/06/2003 10:49:26
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00799472
Message ID:
00799808
Vues:
30
Maybe MLINES() with SET MEMOWIDTH would work better.

Alan

>Actually I did try that first. However, using alines populated an array with line breaks in all the wrong places for some reason (straight from the memo field). It was more difficult to determine where the line breaks should be after using alines on this memo field for some reason.
>
>
>>Hey Trace,
>>
>>Yesterday your loop was throwing me for a loop, and it still is today :)
>>
>>It appears you can do this without stepping through it character by character. The input string (from the memo field), already is broken into lines, right? Have you tried using ALINES() to split it into an array of single lines, and then loop through those lines to put chr(13)+chr(10) between them? ALINES() automagically uses chr(10), chr(13), or chr(13)+chr(10) to split between the lines.
>>
>>>The information in lccode is pulled from a memo field in which text from a default batch file was either typed or cut and pasted. It has the code that should be placed into a batch file on the user's system and two variables will be replaced (IMPORTPATH and IMPORTFILE). The below is the only way it seems to format it correctly in the batch file when it is created:
>>>
>>>
>>>M.Handle=FCREATE("\accuwin\sc\vendor\proaccu.bat")
>>>IF M.Handle <> -1		&& file created
>>>	=FPUTS(M.Handle,"@ECHO OFF")
>>>	PRIVATE IMPORTPATH
>>>	PRIVATE IMPORTFILE
>>>	IMPORTPATH=ALLTRIM(Bg_Accuwin)
>>>	IMPORTFILE="ACCUWIN.TXT"
>>>	PRIVATE lcline
>>>	lcline=""
>>>	FOR i = 1 TO LEN(lccode)
>>>		IF ASC(SUBSTR(lccode,i,1))=13 .OR. ASC(SUBSTR(lccode,i,1))=10
>>>			IF ASC(SUBSTR(lccode,i,1))=13
>>>				lcline=lcline+CHR(13)+CHR(10)
>>>			ENDIF
>>>		ELSE
>>>			lcline=lcline+SUBSTR(lccode,i,1)
>>>		ENDIF
>>>	ENDFOR
>>>	lcLine = STRTRAN(lcline,"<<IMPORTPATH>> <<IMPORTFILE>>",IMPORTPATH+IMPORTFILE,1)
>>>	lcLine = STRTRAN(lcline,"<<IMPORTPATH>><<IMPORTFILE>>",IMPORTPATH+IMPORTFILE,1)
>>>	=FPUTS(m.handle,lcline)
>>>	=FCLOSE(m.handle)
>>>ELSE
>>>*...
>>>
>>>
>>>>Y'know Tracy, I'm still real curious about that IF (ASC(... line. should one side of the .OR. say "ASC(SUBSTR(lccode,i,1))=10" instead of "=13" on both sides?
>>>>
>>>>Alan
>>>>
>>>>>When I make mistakes, do I make obvious ones or what? :o)Maybe it has to do with the 4400.00 bill for my daughter's braces I got today...
>>>>>
>>>>>Thanks Mark!
>>>>>
>>>>>>When I step through your code, it does work. However, you are not storing the result of STRTRAN to anything if that is your intention.
>>>>>>
>>>>>>>As I posted to Gerald, the below does not work either though:
>>>>>>>
>>>>>>>
>>>>>>>clear
>>>>>>>lcline=""
>>>>>>>lccode="REM Test.txt"+CHR(13)
>>>>>>>lccode=lccode+"COPY %1 <<IMPORTPATH>> <<IMPORTFILE>>"
>>>>>>>BG_ACCUWIN="C:\FOXPRO\TMP\"
>>>>>>>m.handle=FCREATE("test.txt")
>>>>>>>FOR i = 1 TO LEN(lccode)
>>>>>>>	IF ASC(SUBSTR(lccode,i,1))=13 .OR. ASC(SUBSTR(lccode,i,1))=13
>>>>>>>		lcline=lcline+CHR(13)+CHR(10)
>>>>>>>		? lcline
>>>>>>>	ELSE
>>>>>>>		lcline=lcline+SUBSTR(lccode,i,1)
>>>>>>>		IF "<<IMPORTPATH>>" $ lcline
>>>>>>>			?"Original lines: "+lcline
>>>>>>>			STRTRAN(lcline,"<<IMPORTPATH>>",BG_ACCUWIN)
>>>>>>>			?"New Lines: "+lcline
>>>>>>>			?"******************************"
>>>>>>>			WAIT WINDOW "Found <<IMPORTPATH>>"
>>>>>>>		ENDIF
>>>>>>>		IF "<<IMPORTFILE>>" $ lcline
>>>>>>>			?"Original line: "+lcline
>>>>>>>			STRTRAN(lcline,"<<IMPORTFILE>>","ACCUWIN.TXT")
>>>>>>>			?"New Line: "+lcline
>>>>>>>			?"******************************"
>>>>>>>			WAIT WINDOW "Found <<IMPORTFILE>>"
>>>>>>>		ENDIF
>>>>>>>	ENDIF
>>>>>>>ENDFOR
>>>>>>>=FPUTS(m.handle,lcline)
>>>>>>>=FCLOSE(m.handle)
>>>>>>>MODIFY COMMAND test.txt
>>>>>>>
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform