Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Displaying a Table
Message
 
 
À
04/05/2001 10:11:46
Todd Wolfe
Certified Marketing Services
Kinderhook, New York, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
FoxWeb
Divers
Thread ID:
00502684
Message ID:
00503579
Vues:
26
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)  && Create array

nhandle=fcreate('tempfile')


fwrite(nhandle,'=TABLE BORDER=10=')

scan &&go through all records
	fwrite(nhandle,"=tr=")
	FOR nCount = 1 TO gnFieldcount  &&go across table
          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)  && Create array
>
>m.test='=TABLE BORDER=10='
>scan &&go through all records
>	m.test=m.test + "=tr="
>	FOR nCount = 1 TO gnFieldcount  &&go across table
>    	  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.com
ICQ #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.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform