Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Moving .TXT/.PRG files into .DBF memo
Message
 
To
19/03/2002 21:39:00
Dragan Nedeljkovich
Now officially retired
Zrenjanin, Serbia
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00634479
Message ID:
00635020
Views:
25
Hello Dragan,

>Take a good look at the StrExtract() function, which is the new thing in VFP7, you'll be surprised what it can do. You'd just have to pass it the filetostr() of your source, "Text" and "Endtext" as parameters, maybe a couple of flags to handle the case blindness/awareness etc, and it will extract the piece of text between these words.

Another Bingo! moment. 7 lines of code:
cPrgTxt = FileToStr(cPrgFile)
n1startPos = AT("TEXT",cPrgTxt,1)+5
n1endPos = AT("ENDTEXT",cPrgTxt,1)-1
REPLACE cMemoField1 WITH SUBSTR(cPrgTxt,n1startPos,n1endPos-n1startPos)
n2startPos = AT("TEXT",cPrgTxt,3)+5
n2endPos = AT("ENDTEXT",cPrgTxt,2)-1
REPLACE cMemoField2 WITH SUBSTR(cPrgTxt,n2startPos,n2endPos-n2startPos)
condense to only three!
cPrgTxt = FileToStr(cPrgFile)
REPLACE cMemoField1 WITH STREXTRACT(cPrgTxt,"TEXT","ENDTEXT",1)
REPLACE cMemoField2 WITH STREXTRACT(cPrgTxt,"TEXT","ENDTEXT",3)
Thanks! This is almost fun... :-) Text from 199 .PRG files distributed to 398 memo fields in just 2 seconds! (after 2 hours of coding). Sure beats retyping or endless Ctrl^C-Ctrl^V. Have a great day.
Randy Bosma
VFP - Because life is too short to code in something else...
Previous
Reply
Map
View

Click here to load this message in the networking platform