Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
StrToFile Equivalent in FPD26?
Message
De
13/02/2003 05:44:54
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
10/02/2003 10:52:33
Information générale
Forum:
Visual FoxPro
Catégorie:
FoxPro 2.x
Divers
Thread ID:
00751416
Message ID:
00752618
Vues:
13
>Is there a strtofile equivalent in FPD26? I'd like to run the code below in FPD26 (see compile directives-only bottom portion is for FPD26) but it bombs out at the StrToFile portion of course:
>
>
>************************************************************************
>* codefile.prg
>************************************************************************
>* Example only
>* Creates a table that stores a code name and code code
>* Allows program code to be compiled and run on the fly by seeking
>* the program name to run (stored in cprogram character field) and running
>* the associated code (stored in mcode memo field)
>*
>* VFP7 Example Usage:
>*    EXECSCRIPT(codefile.mcode,'Good Morning',64,'Personal Message')
>*
>* FPD26 USAGE:
>*    STRTOFILE(mcode, lcFileName )
>*    COMPILE (lcFileName)
>*    DO (lcFileName) WITH 'This is an example using the compile';
>*       +'for FPD26.','15,10',10
>*
>CLEAR
>IF FILE('codefile.dbf')
>	DELETE FILE ('codefile.dbf')
>ENDIF
>IF FILE('codefile.cdx')
>	DELETE FILE ('codefile.cdx')
>ENDIF
>IF FILE('codefile.fpt')
>	DELETE FILE ('codefile.fpt')
>ENDIF
>lcFileName = SYS(2015)
>lcDelete=lcFilename + ".fxp"
>lcFileName=lcFilename+".prg"
>#IF 'VISUAL' $ UPPER(VERSION())
>	SET SAFETY OFF
>	SELE 0
>	CREATE TABLE codefile FREE (cprogram c(15), mcode m)
>	INDEX ON cprogram TAG cprogram
>	SET ORDER TO TAG cprogram
>	APPEND BLANK
>	REPLACE cprogram WITH 'msgbox'
>	REPLACE mcode WITH ;
>		"PARAMETERS cmsg,nbuttons,ctitle"+CHR(13);
>		+"IF TYPE('cmsg')='L'"+CHR(13);
>		+"	cmsg='This is a test message.'"+CHR(13);
>		+"ENDIF"+CHR(13);
>		+"IF TYPE('nbuttons')='L'"+CHR(13);
>		+"	nbuttons=16"+CHR(13);
>		+"ENDIF"+CHR(13);
>		+"IF TYPE('ctitle')='L'"+CHR(13);
>		+"	ctitle='IMPORTANT MESSAGE'"+CHR(13);
>		+"ENDIF"+CHR(13);
>		+"MESSAGEBOX(cmsg,nbuttons,ctitle)"+CHR(13)
>	IF SEEK('msgbox','codefile','cprogram')
>		*VFP7/VFP8 code:
>		EXECSCRIPT(codefile.mcode,'VFP7 msg',64,'codeFile example.')
>		*VFP6 and below code:
>		STRTOFILE(mcode, lcFileName )
>		COMPILE (lcFileName)
>		DO (lcFileName) WITH 'VFP6',64,'codeFile example.'
>	ELSE
>		WAIT WINDOW "Could Not Find Program to Run." AT 22,35
>	ENDIF
>#ELSE
>	SET SAFETY OFF
>	SELE 0
>	CREATE TABLE codefile (cprogram c(15), mcode m)
>	INDEX ON cprogram TAG cprogram
>	SET ORDER TO TAG cprogram
>	APPEND BLANK
>	REPLACE cprogram WITH 'waitbox'
>	REPLACE mcode WITH ;
>		"PARAMETERS cmsg,clocation,ntimeout"+CHR(13);
>		+"IF TYPE('cmsg')='L'"+CHR(13);
>		+"	cmsg='This is a test message.'"+CHR(13);
>		+"ENDIF"+CHR(13);
>		+"IF TYPE('clocation')='L'"+CHR(13);
>		+"	clocation='22,35'"+CHR(13);
>		+"ENDIF"+CHR(13);
>		+"IF TYPE('ntimeout')='L'"+CHR(13);
>		+"	ntimeout=5"+CHR(13);
>		+"ENDIF"+CHR(13);
>		+"mycode=' WAIT WINDOW '"+";"+CHR(13);
>		+"+CHR(39)+cmsg+CHR(39)";
>		+"+' AT '"+";"+CHR(13);
>		+"+clocation"+";"+CHR(13);
>		+"+' TIMEOUT '";
>		+"+ALLTRIM(STR(ntimeout))";
>		+CHR(13);
>		+"&mycode"
>	WAIT WINDOW "Ready to seek"
>	IF SEEK('waitbox','codefile','cprogram')
>		STRTOFILE(mcode, lcFileName )
>		COMPILE (lcFileName)
>		DO (lcFileName) WITH 'FPD26.','15,10',10
>	ELSE
>		WAIT WINDOW "Could Not Find Program to Run." AT 22,35
>	ENDIF
>#ENDIF
>IF USED('codefile')
>	USE IN codefile
>ENDIF
>IF FILE(lcFileName)
>	DELETE FILE (lcFileName)
>ENDIF
>IF FILE(lcDelete)
>	DELETE FILE (lcDelete)
>ENDIF
>RETURN
>
>
>
>TIA All!!!

Hi Tracy,
In FPD2.x you could use lowlevel file IO functions instead of StrToFile(). However as I could see what you want to write is from a memo field. FPD2.x supports 'Copy memo' command. ie :

copy memo mCode to (m.lcFileName)

However "compile" wouldn't work (introduced in VFP6 SP3) in runtime. Either use precompiled fxp's or codeblock utility.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform