Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Finding string in TXT file
Message
From
25/12/2022 13:16:19
 
 
To
25/12/2022 11:50:48
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01685605
Message ID:
01685613
Views:
53
I think you should focus on fixing the problem, and not the symptom. And the symptom is occasional write error, most likely a file lock due to slow hardware. So, IOW the program itself works, so no reason to change it.

Put the StrToFile() in a loop, with a little delay between each file write attempt, and exit the loop once the file write is successful. If you have VFP9 it's very easy since you can include a Try-Catch-Endtry in the loop.

NB! When you reply, please select Options (the "filing cabinet" right above my flag), and check "Enable Auto Quote".

>Sorry for a lack of information. Yes, I need to write it back in the same file. File is a small, couple of kb.
>There is a procedure: I receive a file from a service (cyrilyc and latinic letters) which I should transform all to latinic. Some of lines in a file is longest than 254bytes. After transformation I search for a specific strings, remember variables and write it down to database. After that I delete file.
>
>
>If you give a better description of what you really want to achieve, we can help you better.
>
>You don't only want to search a file, you also want to write it back, which is new information. And when you write it back, is it to the same file name, or a new?
>
>Also, please tell us roughly how big the files are.
>
>The more information you give, the better.
>
>>On slow computers when I issue FILETOSTR(), then some proccesing and then STRTOFILE() back, sometimes error file access denied occurs. I don't want to slow down program while proccesing because of few users :-(. So, I'm looking for a possible different solution.
>>
>>May I ask what's wrong with using FileToStr()?
>>
>>>Line lenght can be more than 254 bytes and before the time of proccesing I don't know lenght of a specific line.
>>>
>>>You can use FGET to read text file line by line and compare
>>>
>>>>Any ideas how to find string between two unique strings in TXT file without using FILETOSTR command?
>>>>For example I need to find string
>>>>
>>>>aa
>>>>bb
>>>>cc
>>>>
>>>>in TXT file
>>>>
>>>>1111
>>>>2222
>>>>3333
>>>>first string:aa
>>>>bb
>>>>cc
>>>>second string:fsdfsdfs
>>>>444
>>>>555
Previous
Reply
Map
View

Click here to load this message in the networking platform