Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Indent a long string into a txt file
Message
From
02/05/2022 15:11:22
 
 
To
02/05/2022 13:26:47
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01684311
Message ID:
01684328
Views:
29
>>>>>>>Hi,
>>>>>>>
>>>>>>>The code writes a long string (it could be up to 200 or more characters) into a .txt file. The string is written to the .txt file using strtofile() function. I would like the long string to be indented by, say 10 characters. I can indent the first line, by adding a space(10). But the rest of the string go to the 1st column,
>>>>>>>Is there a way to do it, other than parsing the string into 60-70 characters and adding a space(10) before each line?
>>>>>>>
>>>>>>>TIA
>>>>>>
>>>>>>Sorry for a newbie question. I think VFP has a function that will populate an array from a long string, setting the max number of characters in each element. If my memory services me right, what is this function?
>>>>>>Basically I want the VFP to parse the string into smaller strings, each one no more than 60 char in length.
>>>>>>TIA
>>>>>
>>>>>AFAIK there's no such function.
>>>>
>>>>I suppose since I didn't remember this function, my memory works :)
>>>
>>>Right. 😂
>>
>>I think I found it: memlines() and mline()
>
>I think you were getting MLINE() and MEMLINES() mixed up with ALINES() function.
>ALINES() splits the long string into array elements -- using CR, LF, CR/LF, or LF/CR to determine the end of line and not affected by SET MEMOWIDTH.
>MLINE() doesn't split string into an array and uses SET MEMOWIDTH to determine length of each "line" (it also takes into account CR, LF and combination of the two for end-of-line marks)
>
>NOTE:
>CR denotes "carriage return" (move carriage/cursor to beginning of line) -- CHR(13)
>LF denotes "line feed" (advance to next line) -- CHR(10)
>Depending on the system the "newline" to denote the end of a text line could vary. In DOS/Windows it is denoted by CR followed by LF, while in Unix systems it is simply a LF. I vaguely recall there was a system that used CR as end-of-line in a text file (but I don't remember which system it was).. These different ways of denoting the end-of-line in text file was cause of grief when transferring files between various systems (if you forgot to set the right transfer mode when transporting the files).

You are right that initially I was thinking of ALINES(). But, after testing both, I find the MLINE() works better for me since I can define the max length of each line (using SET MEMOWIDTH). So, in my case, MLINE() gives me exactly what I was looking for.
Thank you.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Reply
Map
View

Click here to load this message in the networking platform