exec()

Just starting out? Need help? Post your questions and find answers here.
cybergeek
User
User
Posts: 33
Joined: Sat Jul 03, 2010 11:11 am

exec()

Post 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)
PUREBASIC is AWSUM
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: exec()

Post by srod »

What kind of script are you talking about? VBS, Javascript, LUA....
I may look like a mule, but I'm not a complete ass.
cybergeek
User
User
Posts: 33
Joined: Sat Jul 03, 2010 11:11 am

Re: exec()

Post by cybergeek »

purebasic of course
PUREBASIC is AWSUM
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: exec()

Post by gnozal »

cybergeek wrote:purebasic of course
Purebasic is not a script language.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: exec()

Post 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.
I may look like a mule, but I'm not a complete ass.
User avatar
flaith
Enthusiast
Enthusiast
Posts: 704
Joined: Mon Apr 25, 2005 9:28 pm
Location: $300:20 58 FC 60 - Rennes
Contact:

Re: exec()

Post by flaith »

RunProgram
can call an external program if you want
“Fear is a reaction. Courage is a decision.” - WC
cybergeek
User
User
Posts: 33
Joined: Sat Jul 03, 2010 11:11 am

Re: exec()

Post 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
PUREBASIC is AWSUM
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: exec()

Post 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.
I may look like a mule, but I'm not a complete ass.
cybergeek
User
User
Posts: 33
Joined: Sat Jul 03, 2010 11:11 am

Re: exec()

Post by cybergeek »

looked at a thread RUN TIME COMPILER http://www.purebasic.fr/english/viewtop ... 3&p=332022

need like that



damn needed this
PUREBASIC is AWSUM
dongnanyanhai
User
User
Posts: 10
Joined: Thu Aug 05, 2010 4:15 pm

Re: exec()

Post 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
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: exec()

Post by srod »

He wants to execute PB code dynamically from his own application, not trap a button click! :)
I may look like a mule, but I'm not a complete ass.
Little John
Addict
Addict
Posts: 4777
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: exec()

Post 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
User avatar
NicknameFJ
User
User
Posts: 90
Joined: Tue Mar 17, 2009 6:36 pm
Location: Germany

Re: exec()

Post 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
PS: Sorry for my weird english, but english is not my native language.



Image
cybergeek
User
User
Posts: 33
Joined: Sat Jul 03, 2010 11:11 am

Re: exec()

Post by cybergeek »

NicknameFJ wrote:Hi,

/edit: I found it - here´s the link

http://www.purebasic.fr/german/viewtopi ... 46&start=0
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
PUREBASIC is AWSUM
citystate
Enthusiast
Enthusiast
Posts: 638
Joined: Sun Feb 12, 2006 10:06 pm

Re: exec()

Post 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
there is no sig, only zuul (and the following disclaimer)

WARNING: may be talking out of his hat
Post Reply