Hi!
If a string is quite long, operation like 'str=str+Something' can last a long time. In the loop it lasts even more time. Try to do not add to string, just save to the text file. Something like following (I did not tested a code, but hope you will get a general idea):
Use mytable in 0 shared
gnFieldcount = AFIELDS(gaMyArray)
nhandle=fcreate('tempfile')
fwrite(nhandle,'=TABLE BORDER=10=')
scan
fwrite(nhandle,"=tr=")
FOR nCount = 1 TO gnFieldcount
fwrite(nhandle,"=td= "+alltrim(eval(gaMyArray(nCount,1)) )'; + " =/td="+chr(10))
ENDFOR
fwrite(nhandle,"=/tr=")
endscan
fwrite(nhandle,'=/table=')
fclose(nhandle)
html_out=filetostr('tempfile')
Above should work much more quickly if the total string size is larger than 4-10K
Anyway, I wondered too why it is so slow. Maybe you have an error handler somewhere that is fired?
Another solution is to use COPY TO command and put data into the delimited text file. Than get a text string into the memory variavle and using certain combination of the string processing functions, like CHRTRAN, STRTRAN, do what you want just with a few commands. Is this possible with your data?
Example: of use such functions:
STRTRAN(TempStr, chr(13),"=/tr==tr=") - will end each row and start a new row for your table. You will require than to remove the last =tr= from string.
When using special delimiters and characters in the COPY TO command to separate fields, you can use the same approach to add =td= tags and remove character field bound characters. I guess few VFP function calls will work much more quickly than manual scan of the data.
>This is my code. However it still seems to take over 5 minutes to run? It seems to me the more I store to the memory variable the slower it gets. Any ideas what my problem is (= sign used in place or < >)?
>
>
>Use mytable in 0 shared
>
>
>gnFieldcount = AFIELDS(gaMyArray)
>
>m.test='=TABLE BORDER=10='
>scan
> m.test=m.test + "=tr="
> FOR nCount = 1 TO gnFieldcount
> m.test=m.test+"=td= "+alltrim(eval(gaMyArray(nCount,1)) )'; + " =/td="+chr(10)
> ENDFOR
>
> m.test=m.test+"=/tr="
>
>
>endscan
> m.test=m.test+'=/table='
>
>html_out=m.test
>
>
>Thanks again.
>Todd
Vlad Grynchyshyn, Project Manager, MCP
vgryn@yahoo.comICQ #10709245
The professional level of programmer could be determined by level of stupidity of his/her bugs
It is not appropriate to say that question is "foolish". There could be only foolish answers. Everybody passed period of time when knows nothing about something.