Re: Data driving a class by Stefan
Stefan
Tue Jan 11 01:21:53 CST 2005
hey, you're welcome :-)
-Stefan
"John Pugh" <not@real.com> schrieb im Newsbeitrag
news:%23l$Gzp49EHA.2680@TK2MSFTNGP09.phx.gbl...
> Stefan,
>
> Bingo! - CLEAR CLASS did the trick. I still had to COMPILE to display the
> correct record, but did not have to delete the FXP.
>
> Many thanks for your help
>
> John
>
> "Stefan Wuebbe" <stefan.wuebbe@gmx.de> wrote in message
> news:%23NNa$Ow9EHA.2804@TK2MSFTNGP15.phx.gbl...
>> I tried to reproduce your sample code and this sequence work
>> oTest = .NULL.
>> CLEAR CLASS "test_class"
>> CLEAR PROGRAM
>> STRTOFILE(script_def.exec_txt,'test_script.prg',0)
>> COMPILE ('test_script.prg')
>>
>> (The last line was not actually required to get the current row
>> content compiled, at least in my test, but was a good indicator to
>> see all references to the FXP file being removed, i.e. avoid
>> error 1184.)
>>
>>
>> hth
>> -Stefan
>>
>> "John Pugh" <not@real.com> schrieb im Newsbeitrag
>> news:Oqo3W5p9EHA.2596@tk2msftngp13.phx.gbl...
>> > Stefan,
>> >
>> > Thanks for the suggestion - unfortunately I get the same error message.
>> >
>> > Regards
>> > John
>> >
>> > "Stefan Wuebbe" <stefan.wuebbe@gmx.de> wrote in message
>> > news:%23L1O%23Zk9EHA.1264@TK2MSFTNGP12.phx.gbl...
>> >> >>> However the code from the record that was selected the first time
> is
>> >> >>> executed - the .fxp appears to be in memory.
>> >> >>> Attempting to compile test_script.prg or delete test_script.fxp
> causes
>> > an
>> >> >>> error 'outstanding references exist'
>> >>
>> >> Hi John, does "Clear Program" help?
>> >>
>> >>
>> >> hth
>> >> -Stefan
>> >>
>> >> "John Pugh" <not@real.com> schrieb im Newsbeitrag
>> >> news:%23qDp$sg9EHA.4004@tk2msftngp13.phx.gbl...
>> >> > Eric,
>> >> >
>> >> > Thanks for your comments. I am using EXECSCRIPT() for most of what I
> am
>> > data
>> >> > driving that is fairly straightforward.
>> >> >
>> >> > I have a couple of complex routines the could change for users. I
> have
>> > used
>> >> > a .prg for these - makes debugging easier!
>> >> >
>> >> > Regards,
>> >> >
>> >> > John
>> >> > "Eric den Doop" <ericdendoop@xspamblockxfoxite.com> wrote in message
>> >> > news:OaXyXxX9EHA.2016@TK2MSFTNGP15.phx.gbl...
>> >> >> I've used a similar technique for a couple of VFP web applications.
> I
>> >> > think
>> >> >> you are better off using EXECSCRIPT().
>> >> >> --
>> >> >> Eric den Doop
>> >> >> www.foxite.com - The Home Of The Visual FoxPro Experts - Powered By
>> > VFP8
>> >> >>
>> >> >> "John Pugh" <not@real.com> wrote in message
>> >> >> news:ecStxzU9EHA.2572@tk2msftngp13.phx.gbl...
>> >> >> > Hi,
>> >> >> >
>> >> >> > I am attempting to data drive code that can contain several
> methods
>> > by
>> >> >> > creating a table 'script_def' with two fields:-
>> >> >> > * script_name c(10)
>> >> >> > * exec_txt m - contains code to create the class.
>> >> >> >
>> >> >> > The test program below selects the appropriate record, creates the
>> > class
>> >> >> > and
>> >> >> > calls a method.
>> >> >> > MESSAGEBOX confirms that the correct record is selected and that
>> >> >> > test_script.prg contains the text from the correct record.
>> >> >> >
>> >> >> > However the code from the record that was selected the first time
> is
>> >> >> > executed - the .fxp appears to be in memory.
>> >> >> >
>> >> >> > Attempting to compile test_script.prg or delete test_script.fxp
>> > causes
>> >> > an
>> >> >> > error 'outstanding references exist'
>> >> >> >
>> >> >> > Any help in getting this to work (or a better way to do it) would
> be
>> >> >> > appreciated.
>> >> >> >
>> >> >> > TIA,
>> >> >> >
>> >> >> > John Pugh
>> >> >> > Adelaide, South Australia
>> >> >> >
>> >> >> >
>> >> >> > * Test data driving a class
>> >> >> > IF NOT USED('script_def')
>> >> >> > USE script_def IN 0
>> >> >> > ENDIF
>> >> >> > SELECT script_def
>> >> >> > LOCATE FOR script_def.script_name='two'
>> >> >> > MESSAGEBOX(script_def.script_name)
>> >> >> >
>> >> >> > SET SAFETY OFF
>> >> >> > =STRTOFILE(script_def.exec_txt,'test_script.prg',0)
>> >> >> > SET SAFETY ON
>> >> >> > MESSAGEBOX(script_def.exec_txt)
>> >> >> >
>> >> >> > LOCAL o_test
>> >> >> > o_test = NEWOBJECT("test_class",'test_script.prg','')
>> >> >> > =o_test.test_method()
>> >> >> > RELEASE o_test
>> >> >> > RETURN
>> >> >> >
>> >> >> > *************Code in record one of
>> >> >> > script_def*********************************
>> >> >> > * Test class for data driving
>> >> >> > DEFINE CLASS test_class AS CUSTOM
>> >> >> >
>> >> >> > PROCEDURE test_2
>> >> >> > MESSAGEBOX('test_method called from rec 1' )
>> >> >> > ENDPROC
>> >> >> >
>> >> >> > PROCEDURE test_method
>> >> >> > =THIS.test_2()
>> >> >> > ENDPROC
>> >> >> > ENDDEFINE
>> >> >> >
>> >> >> >
>> >> >>
>> >> >>
>> >> >
>> >> >
>> >>
>> >
>> >
>>
>
>