Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
MLCOUNT() and MEMOLINE()?
Message
From
02/05/2011 14:20:14
Dragan Nedeljkovich
Now officially retired
Zrenjanin, Serbia
 
 
To
01/05/2011 09:13:24
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Miscellaneous
Thread ID:
01508891
Message ID:
01509066
Views:
94
>> ANTMEMO=SET('MEMOWIDTH')
>> SET MEMOWIDTH TO 33
>> DESCRI=ALLTRIM(DDESC)
>> CREATE CURSOR MDESCRIP (MNOMBRE M(4))
>> APPEND BLANK
>> REPLACE MNOMBRE WITH DESCRI
>> N=1
>> DO WHILE !EMPTY(MLINE(MNOMBRE,N,_MLINE))
>> ??? PADR(mLINE(MNOMBRE,n,_MLINE),33)
>> N=N+1
>> ENDDO
>> SET MEMOWIDTH TO ANTMEMO
>>
>>
>>Thank you
>
>>I'm not sure you're getting the correct result if calling mline() with _mline and n>1. _mline is updated on every call, and contains the offset of the >last byte retrieved during the last call (which would coincide with the beginning of the next line). Next call, if _mline is included as the offset >parameter, starts from that last offset - and your second parameter is the ordinal number of the line starting from that point, so it would count >lines from there. Basically, you're getting the 1st, 3rd, 6th,10th, 15th line etc. Including _mline is much faster (because Fox doesn't have to >calculate the position of the line you asked for), but if you want to get ALL the lines, call it with
>
>Hi Dragan:
>
>Putting code made this become more interesting, didn't it?
>
>VFP help is very confusing to me about this topic and the only I understand of your contribution is: "I'm not sure you're getting the correct result if calling mline() " because you're right. I had to simulate MLCOUNT() and MEMOLINE() Clipper functions for getting what I desired. It was exciting to write so much code alltogether again but now I won't miss those functions of Clipper anymore.
>
>I must say that calling !EMPTY(MLINE(MNOMBRE,N,33)) didn't work either because it always returns empty strings. _mline returns something but, your hit, the line that tries to print is empty.. and n>1 is empty too.

Your loop should look like this:
* reset the offset, just in case
_mline=0
   DO WHILE _mline<len(MNombre)
     ??? PADR(mLINE(MNOMBRE,1,_MLINE),33)
     N=N+1
  ENDDO   
While this loop runs, keep checking _mline in the debugger - put it in the watch window. It will be the length of the string up to the end of the last retrieved line. The meaning of the third parameter is "starting from byte", and the 2nd is "which line". If you know where to start, it is much faster than to let Fox count the lines to that starting point. And _mline is the system variable which remembers where you were after the last call. So if your 12th line ended on byte 234, _mline is 234. mline(nombre,1,_mline) will then give you the first line after 234th byte, which is your 13th line, and so on.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform