PxPlus User Forum

Main Board => Discussions => Programming => Topic started by: Thomas Bock on December 22, 2021, 09:47:34 AM

Title: pass composite string to an extended command
Post by: Thomas Bock on December 22, 2021, 09:47:34 AM
I'm looking for a way to pass one or more composite string(s) to an extended command.
Something like:
-}dim rec$:iol(1)
-}read record (1,key="abc")rec$
-}extCmd rec$
Title: Re: pass composite string to an extended command
Post by: Mike King on December 22, 2021, 10:24:07 AM
You should be able to use a ENTER directive without any parameters to change the internal CALL to your extended command into a PERFORM then use another ENTER to get to name of the variable:

Something like this:

-:list
0010 ENTER
0020 LOCAL _val$
0030 ENTER _val$
0040 LET _val$=STP(_val$,2) ! Remove any leading/trailing spaces
0050 PRINT _val$,"=",EVS("STR("+_val$+")")
-:save
C:\pvxsrc\_cmd\abc
->mike$="I am here"
->abc mike$
mike$=I am here

Title: Re: pass composite string to an extended command
Post by: Thomas Bock on December 23, 2021, 02:18:02 AM
Mike,

Two ENTERs? Nice! I never thought of that.
Here is what I use finally:
Code: [Select]
ENTER
LOCAL param$,cmd$,var$
ENTER param$
LET param$=STP(param$,2)
LET cmd$="dim var$:iol("+param$+")"
EXECUTE cmd$
LET var$=VIS(param$)
PRINT LST(IOL(var$))
PRINT SUB(var$,SEP,"~")
END
Title: Re: pass composite string to an extended command
Post by: Mike King on December 23, 2021, 08:37:19 AM
Yes, an ENTER with no parameters included at the start of a called program effectively converts the CALL into a PERFORM.