Is there anything like Unix 'exec' in PB?

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by naw.

Hi All, Is there anything like Unix ksh "exec" command in PB?
I'm not a compiler boffin, but I suspect that this may be impossible
because PB is a compiler not an interpreter...

Anyway I want to be able to do the following:

X$="MessageRequester('Y','Z',0)"
exec X$

Ta - N
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.

> Anyway I want to be able to do the following:
> X$="MessageRequester('Y','Z',0)" : exec X$

You're right: you can't. There may be other ways to achieve what you want,
if you can be a little more specific?


PB - Registered PureBasic Coder
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by naw.

I'd like to import *Variables* from an external Text File that builds a configurable GUI a bit like this...

TextFile.txt:

TextGadget,1,2,3,4,"Hello World"

PseudoCode:

while read "./TextFile.txt" into gadget$ x y w h text$
gadget$(x,y,w,h,text$)
done

- I've got no chance, have I :-(
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by tinman.
PseudoCode:

while read "./TextFile.txt" into gadget$ x y w h text$
gadget$(x,y,w,h,text$)
done
Well, you could always build up a look up table for the names of the gadgets:

Code: Select all

name$(0)="TextGadget"
name$(1)="ButtonGadget"
etc

gid=0
while Read "./Textfile.txt" into gadget$ x y w h text$
  i=0 : found=0
  while i<#MAXGADGETS And found=0
    if gadget$=name$(i)
      found=1
    Else
      i=i+1 ; oops forgot that :)
    endif
  wend

  If found=1
    Select i
      Case 0
        TextGadget(gid,x,y,w,h,text$)
      Case 1
        Buttongadget(gid,x,y,w,h,text$)
      ; etc
    EndSelect
    gid=gid+1
  EndIf
Wend


--
It's not minimalist - I'm increasing efficiency by reducing input effort.

Edited by - tinman on 01 May 2002 13:15:04
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by naw.


Yeah! Thats the way I've done it and it works, but only for things that I have in my lookup table... Thanks, though for taking a look (I posted my INI2GUI onto the PB Resource site - it was related to that...)

Cheers - N
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by tinman.
Yeah! Thats the way I've done it and it works, but only for things that I have in my lookup table... Thanks, though for taking a look (I posted my INI2GUI onto the PB Resource site - it was related to that...)
What's the problem with it only working for things in your lookup table? If new gadgets were added to PB you would have to recompile your source to get access to those anyway, so you could update your lookup table at the same time.

Or is there some other reason you don't want a lookup table?


--
It's not minimalist - I'm increasing efficiency by reducing input effort.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by naw.
Or is there some other reason you don't want a lookup table?
Err! well yes, dont flame me for giving a *bad* reason, I am at least being honest here... I'm essentially very lazy and this:

exec cmd$(x,y,z,w,h,text$)

is shorter than this

select cmd$
case "TextGadget" : TextGadget(x,y,w,h,text$)
case "InputGadget" : InputGadget(x,y,w,h,text$)
case "InspectorGadget" : InspectorGadget(x,y,w,h,text$)
case "WidgetGadget" : WidgetGadget(x,y,w,h,text$)
.
.
.
.
endselect

;-)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by tinman.
honest here... I'm essentially very lazy and this:

exec cmd$(x,y,z,w,h,text$)

is shorter than this
That's an excellent reason :)


--
It's not minimalist - I'm increasing efficiency by reducing input effort.
Post Reply