On 19 Feb 2003 at 17:55, François Van Emelen wrote:

> It is rather a function that acts upon the content of a string variable
> as if it had been typed in on the command line.
> example:
> 100 my_string$="qdos"
> 120 my_new_string$=XYZ("upper$"&"("&my_string$&")")
> 130 rem XYZ => name of the function that would do the trick
> 140 print my_new_string$
> 150 rem line 140 would not display "upper$"&"("&my_string$&")"
> 160 rem but "QDOS"
>
> Sorry for the disturbance and thanks for your explanation
> François Van Emelen
OK, so what you seem to need is a kind of VAL function.
How about this -it builds a small basic program and then executes
the command you want, recovering the result from the program's output.

DEFine FuNction val$ (command$,parameter$)
LOCal cc%,oc%,cf$,of$,res$
  cf$="ram1_strictly_private"&RND(1 TO 100)& RND(1 TO 100)&"_bas"
  of$="ram1_strictly_private2"&RND(1 TO 100)& RND(1 TO 100)
  cc%=FOP_OVER(cf$)             : REMark open command file channel
  PRINT#cc%;"a$=";              : REMark build command line program
  PRINT#cc%;command$;"('";parameter$;"')"
  PRINT#cc%,"of$='";of$;"'"
  PRINT#cc%;"oc%=fop_over(of$)" : REMark open output file channel
  PRINT#cc%;"print #oc%,a$"             : rem and print out result
  PRINT#cc%;"close#oc%"
  CLOSE#cc%
  EW cf$                        : REMark execute sbasic with this file
  oc%=FOP_IN(of$)
  INPUT#oc%,res$          : rem now get result
  CLOSE#oc%
  DELETE of$
  DELETE cf$
  RETurn res$
END DEFine val$
:

I don't pretend it's elegant (prehaps using pipes would habe been more elegant). It
also is probably pretty slow.
But it'll work, at least with string functions
I'm sure you can adapt it if more than one parameter is needed.
You DO need SMSQ/E to execute the basic file.
Hope this helps.

Wolfgang

Reply via email to