Page 1 of 2
exec()
Posted: Fri Aug 20, 2010 3:28 pm
by cybergeek
is there any function exec() which can execute a piece of script in a variable... dynamically at runtime?
e.g
script.s= ;some scipt here
exec(script)
Re: exec()
Posted: Fri Aug 20, 2010 3:38 pm
by srod
What kind of script are you talking about? VBS, Javascript, LUA....
Re: exec()
Posted: Tue Aug 24, 2010 11:04 am
by cybergeek
purebasic of course
Re: exec()
Posted: Tue Aug 24, 2010 11:09 am
by gnozal
cybergeek wrote:purebasic of course
Purebasic is not a script language.
Re: exec()
Posted: Tue Aug 24, 2010 11:27 am
by srod
cybergeek wrote:purebasic of course
There is no 'of course' about it since, as Gnozal points out, Purebasic is not a scripting language and is not offered as such by the PB team.
Re: exec()
Posted: Tue Aug 24, 2010 12:30 pm
by flaith
RunProgram
can call an external program if you want
Re: exec()
Posted: Tue Aug 24, 2010 12:41 pm
by cybergeek
sorry... i didnt mean script but a programming language
i want an exec function
PBcode$ = ;code + # LF + code
exec(pbcode$)
should work dynamically
Re: exec()
Posted: Tue Aug 24, 2010 12:44 pm
by srod
Then you will have to write a scripting engine which works with PB type source.
You cannot expect this natively of what is a native compiler.
Re: exec()
Posted: Tue Aug 24, 2010 12:45 pm
by cybergeek
looked at a thread RUN TIME COMPILER
http://www.purebasic.fr/english/viewtop ... 3&p=332022
need like that
damn needed this
Re: exec()
Posted: Tue Aug 24, 2010 3:12 pm
by dongnanyanhai
cybergeek wrote:sorry... i didnt mean script but a programming language
i want an exec function
PBcode$ = ;code + # LF + code
exec(pbcode$)
should work dynamically
I hope this code can help you!
Code: Select all
Prototype CallHandler()
Declare gogo()
WinH = OpenWindow(0,50,50,320,200,"MainWindow",#PB_Window_SystemMenu)
If WinH <> 0
handler.Callhandler
ButtonGadget(0,50,50,120,50,"OK")
handler = @gogo()
Repeat
Event = WindowEvent()
Select Event
Case #PB_Event_Gadget
Select EventGadget()
Case 0
handler()
EndSelect
EndSelect
Until Event = #PB_Event_CloseWindow
EndIf
End
Procedure gogo()
MessageRequester("Message","Sucess!")
EndProcedure
Re: exec()
Posted: Tue Aug 24, 2010 3:34 pm
by srod
He wants to execute PB code dynamically from his own application, not trap a button click!

Re: exec()
Posted: Tue Aug 24, 2010 6:41 pm
by Little John
cybergeek,
you might want to take a look at
Lua. It's a nice scripting language, that can co-operate with PB. AFAIR there's a PB library for this purpose somewhere around here.
Regards, Little John
Re: exec()
Posted: Tue Aug 24, 2010 10:05 pm
by NicknameFJ
Hi,
I think I can remember that in the german Forum someone has written a script language with PB-Syntax. I don´t know who it was, just right now, but I´m searching for.
This script language, I guess, is like an PB-Interpreter which can execute PB-Syntax-Scripts dynamically.
Greetings
NicknameFJ
/edit: I found it - here´s the link
http://www.purebasic.fr/german/viewtopi ... 46&start=0
Re: exec()
Posted: Wed Aug 25, 2010 10:15 am
by cybergeek
thx.. but i dont know german ... transalation is very bad ..
but still tried and couldnt get it to work
Code: Select all
Define *ByteCode
script.s = "MessageRequester(" + Chr(34) + "Information" + Chr(34) + "," + Chr(34) + "Just a short information text" + Chr(34) + "," + Chr(34) + "#PB_MessageRequester_Ok)"
*ByteCode = PBSCompileScriptString(script)
If PBSOpenByteMemory(0, *ByteCode)
PBSStartByteCode(0)
EndIf
Re: exec()
Posted: Wed Aug 25, 2010 10:37 am
by citystate
perhaps this will work for you
Code: Select all
Define *ByteCode
script.s = "MessageRequester(" + Chr(34) + "Information" + Chr(34) + "," + Chr(34) + "Just a short information text" + Chr(34) + "," + "#PB_MessageRequester_Ok)"
*ByteCode = PBSCompileScriptString(script)
If PBSOpenByteMemory(0, *ByteCode)
PBSStartByteCode(0)
EndIf
looks like you had an extra Chr(34) in there