Alaska Software Inc. - memoline() minor difference might be error
Username: Password:
AuthorTopic: memoline() minor difference might be error
Rodd Grahammemoline() minor difference might be error
on Fri, 23 Sep 2005 10:41:22 -0500
FYI:

If memoline(String, LineLen, Line) is used to extract a line from a string, 
the line is exactly LineLen long, and the last character of the line is not 
blank, and the default wrap of .t. is used, the last word of the line wraps 
to a new line even though it would have fit within the LineLen.  This is 
different than Clipper and possibly an error depending upon how you 
interpret the documentation relative to the test example below.  Probably 
best to turn off wrapping if you do not intend to use it.

Example:

memoline("123 456"+chr(13)+chr(10),7,1)  //RESULT: "123    "
memoline("123 456"+chr(13)+chr(10),7,2)  //RESULT: "456    "

Rodd
Phil Ide
Re: memoline() minor difference might be error
on Fri, 23 Sep 2005 17:01:53 +0100
Rodd,

> Example:
> 
> memoline("123 456"+chr(13)+chr(10),7,1)  //RESULT: "123    "
> memoline("123 456"+chr(13)+chr(10),7,2)  //RESULT: "456    "

Well spotted - but yikes!  Using memoline!  If you use this extensively in
your apps, be aware that Xbase++ has far better abilities to fetch lines
from strings.

As one example, you could use my FileReader class, but the basics are
covered in an Alaska doc:

ftp://ftp.alaska-software.com/documents/readtxt.zip

Regards,

Phil Ide

*******************************************
*   Xbase++ FAQ, Libraries and Sources:   *
*   goto: http://www.idep.org.uk/xbase    *
* --------------------------------------- *
* www.xodc.org.uk - openSource Dev-Center *
*******************************************

I'm fascinated by the way memory diffuses fact.
Rodd GrahamRe: memoline() minor difference might be error
on Fri, 23 Sep 2005 12:08:08 -0500
Phil,

I have read and understand the Alaska "Efficient String Operations in 
Xbase++" document prior to this.  As you know, I am migrating our Clipper 
app (which goes into production on Monday, stod("20050926")) and am trying 
to avoid as many logic changes as possible to avoid introducing new bugs 
during the conversion.

However, I am going to challenge you to show me how to extract the first X 
characters from line I from string S in less source code than:

Result := memoline(S,X,I)

From my perspective, 'better' means problem solved and I can move on.  I 
have trusted the Alaska guys to do a respectable implementation of 
memoline(), and even if they didn't, my specific case only deals with 
strings less than 1K.  I think trust is a difficult thing for programmers 
who are used to solving their own problems (which includes me, but I am 
trying).

I do want to start an Xbase++ library/app framework shortly after the turn 
of the new year to consolidate and document shared Xbase++ logic for all to 
benefit from and improve.  The Xbase++ community is too small for 
proprietary logic to gain any footing.  Any thoughts on quality control and 
preventing forking?

Rodd

"Phil Ide" <phil@xodc.org.uk> wrote in message 
news:186gnat6cujes.dlg@xodc.org.uk...
> Rodd,
>
>> Example:
>>
>> memoline("123 456"+chr(13)+chr(10),7,1)  //RESULT: "123    "
>> memoline("123 456"+chr(13)+chr(10),7,2)  //RESULT: "456    "
>
> Well spotted - but yikes!  Using memoline!  If you use this extensively in
> your apps, be aware that Xbase++ has far better abilities to fetch lines
> from strings.
>
> As one example, you could use my FileReader class, but the basics are
> covered in an Alaska doc:
>
> ftp://ftp.alaska-software.com/documents/readtxt.zip
>
> Regards,
> -- 
> Phil Ide
>
> *******************************************
> *   Xbase++ FAQ, Libraries and Sources:   *
> *   goto: http://www.idep.org.uk/xbase    *
> * --------------------------------------- *
> * www.xodc.org.uk - openSource Dev-Center *
> *******************************************
>
> I'm fascinated by the way memory diffuses fact.
Phil Ide
Re: memoline() minor difference might be error
on Mon, 26 Sep 2005 12:02:19 +0100
Rodd,

> However, I am going to challenge you to show me how to extract the first X 
> characters from line I from string S in less source code than:
> 
> Result := memoline(S,X,I)

You win!

What I can do is fecth that data in a more efficient manner, so if I is
(for example) 10,000, then it will a lot faster.

Regards,

Phil Ide

*******************************************
*   Xbase++ FAQ, Libraries and Sources:   *
*   goto: http://www.idep.org.uk/xbase    *
* --------------------------------------- *
* www.xodc.org.uk - openSource Dev-Center *
*******************************************

This product sadistically tested on gerbils.
Angel Pais Re: memoline() minor difference might be error
on Mon, 26 Sep 2005 18:07:09 -0300
On Fri, 23 Sep 2005 12:08:08 -0500, Rodd Graham wrote:

 
> However, I am going to challenge you to show me how to extract the first X 
> characters from line I from string S in less source code than:
> 
> Result := memoline(S,X,I)
> 

Result := myml(S,X,I)
where myml is your own (more efficient) replacement function to memoline()
by the way, it is 4 characters shorter (G)

Regards
Angel
Rodd GrahamRe: memoline() minor difference might be error
on Mon, 26 Sep 2005 16:29:28 -0500
Angel,

>> However, I am going to challenge you to show me how to extract the first 
>> X
>> characters from line I from string S in less source code than:
>>
>> Result := memoline(S,X,I)
>>
>
> Result := myml(S,X,I)
> where myml is your own (more efficient) replacement function to memoline()
> by the way, it is 4 characters shorter (G)

But you must include and count all source code necessary to compile and link 
with Xbase++.  My linker says something about an unresolved 'MyML'.  

Rodd