Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Antonymous function of Alines()

Status
Not open for further replies.

jonscott8

Programmer
May 12, 2000
1,317
US
Alines() is used to copy each line of a character/memo expression into an array. Anyone know of a function to do exactly the opposite: copy each element of an array into a character/memo expression??

I know I could do it programmatically by looping through the array, but I was hoping I had overlooked a VFP function that does this. [sig]<p>Jon Hawkins<br><a href=mailto: jonscott8@yahoo.com> jonscott8@yahoo.com</a><br><a href= > </a><br>Focus on the solution....Not the problem.[/sig]
 
I did a bit of research, Jon, and no luck. Of course, the program would be only three lines of code. [sig]<p>Robert Bradley<br><a href=mailto: > </a><br><a href= - Visual FoxPro Development</a><br> [/sig]
 
Robert

Close?

FOR lnRow = 1 TO ALEN(laArray)
[tab]laArray[1] = ALLT(laArray[1]) + ALLT(laArray[lnRow])
ENDFOR

Chris [sig][/sig]
 
Chris, following code have more speed for large memo fields.
In addition, when you have 10000 rows, better will be to save memo lines into file and than use 'append memo', becase command 'lcMemo = lcMemo + laArray[lnRow]' works quite slow at the end of array scan - it copies lcMemo content extra time.
Following more speed code

local lnRow, lnLen, lcMemo
select 0
lnLen = ALEN(laArray)
lcMemo = alaArray[1]
FOR lnRow = 2 TO lnLen
lcMemo = lcMemo + laArray[lnRow]
ENDFOR

When you need sample for large amount of data, I may post it too.
[sig]<p>Vlad Grynchyshyn<br><a href=mailto:vgryn@softserve.lviv.ua>vgryn@softserve.lviv.ua</a><br>[/sig]
 
Vlad

lcMemo = alaArray[1] && Typo?

Entirely agree with your code for large volume of data.

What I was trying to determine was Robert's three line program, hence the question close?

Chris [sig][/sig]
 
Code:
for each lcLine in aMyArray
   cMyBigString = cMyBigString + lcLine
endfor

is what I had in mind. Any of the other solutions are, of course, just fine, and probably better. [sig]<p>Robert Bradley<br><a href=mailto: > </a><br><a href= - Visual FoxPro Development</a><br> [/sig]
 
Actually to do the reverse of the Alines() function, it'd be something like this:

lcLongString=laMyArray(1)
FOR lnElement = 2 TO ALEN(laMyArray,1)
lcLongString = CHR(13)+CHR(10)+laMyArray(lnElement)
ENDFOR
REPLACE MyTable.MyMemoField WITH lcLongString

The CR/LF is necessary to maintain the proper lineage in the memo field. Therefore when you issue
Alines(laMyArray,MyTable.MyMemoField), you get each line in a corresponding row of the array.

Thanks for all the responses.

[SET RANT ON]
Don't you just hate when MS creates a function but doesnt create a reverse for that function...kinda like &quot;Add New Hardware&quot; in the Control Panel...........WHERE THE {BLEEP} IS THE REMOVE HARDWARE!!!
[SET RANT OFF] [sig]<p>Jon Hawkins<br><a href=mailto: jonscott8@yahoo.com> jonscott8@yahoo.com</a><br><a href= > </a><br>Focus on the solution....Not the problem.[/sig]
 
Another good sample (see my new thread also):

append general Somefield from (somefile)

Ok, I query data, I want to show this file now. What is opposite to above command??? Damn!!!

The most interest is that Memo and General fields have the same structure when saved in dbf/fpt file. However,
append memo command have its reverse command. append general - do not have. :(((( [sig]<p>Vlad Grynchyshyn<br><a href=mailto:vgryn@softserve.lviv.ua>vgryn@softserve.lviv.ua</a><br>[/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top