Posted by member 12025 on 2004-08-11 12:51:14 link

The objective is that the bang is called and passed proper parameters. The last parameter is assumed to be a set of variables in need of expansion (but actually using %{} causes problems). It expands them, then executes the bang. Given use of !ParseEvars, and having another couple bangs in mind to add to this one, it needs to just take all but the last and convert them into a string, separated by spaces, so the end can be
*script exec %{tmpFirstParams} %{result}


!msgbox: ...er, yeah, might do that :).
...ok, now I did, and made one change, just to see what it would do, and it fixed it. I've been up all night reloading Win2k, and will now sleep, but here is the 90% done script (at least five special cases need to be dealt with, but it works for easy test cases):
;------------------------------------------------------------------------------
; One-line Exapnsion/execution
;------------------------------------------------------------------------------
; USE:
; !eval !bang(s) var vara{varb{varb}}}
; EXAMPLE:
;
; !eval !ParseEvars !varSet tmp "<<test>style>_<<test>thick>_border_<<test>_grip>_bottom"
; !eval !varSet tmp "{<<test>style>_<<test>thick>_border_<<test>_grip>_bottom}" ; extra expansion !NEED TO DO
; !eval !varSet tmp "#<<test>style>_<<test>thick>_border_<<test>_grip>_bottom#" ; enclose in %# %# !NEED TO DO

*script bang !eval

*script exec !varSet tmpParamCount 1
*script exec !varSet tmpFirstParams ""
*script exec !varSet tmpLeft ""
*script exec !varSet tmpRight ""
*script exec !setlistsep <

*script exec !varSet tmpNextParam "%{P}{\%{tmpParamCount}}"

*script LABEL upToVar
*script exec !varSet curParam "%{tmpNextParam}"
*script exec !varAdd tmpParamCount "1"
*script exec !varSet tmpNextParam "%{P}{\%{tmpParamCount}}"
*script exec !msgbox "parameter: %{curParam} | next: %{tmpNextParam} | count: %{tmpParamCount}"
*script GOTOIF ( "%{tmpNextParam}" = "" ) foundVar
*script exec !ifEval ( "%{tmpFirstParams}" = "" ) '|varSet tmpFirstParams "%{\1}"' else '|varSet tmpFirstParams "%{tmpFirstParams} %{curParam}"'
*script exec !msgbox "params: %{tmpFirstParams}"
*script GOTO upToVar

*script LABEL foundVar
*script exec !varSet tmpVar "%{curParam}"
*script exec !varshow curParam

*script LABEL foundVarAgain
*script GOTOIF ( "%{tmpVar:_}" = "" ) endForVar
*script exec !varSet tmpLeft "%{tmpVar:}"
*script exec !varSet tmpRight "%{tmpVar:_}"
*script exec !msgbox "parameters: %{tmpFirstParams} | left: %{tmpLeft} | right:_ %{tmpRight}"

*script LABEL loopVarIn
*script GOTOIF ( "%{tmpRight:_}" = "" ) replaceVar
*script exec !varSet tmpLeft %{tmpLeft}<%{tmpRight:}
*script exec !varSet tmpRight %{tmpRight:_}
*script GOTO loopVarIn

*script LABEL replaceVar
*script exec !setlistsep >
*script exec !varSet tmpRightTwo "%{tmpRight:_}"
*script exec !varSet tmpLeftTwo "%{tmpRight:}"
*script exec !varSet tmpLeftTwo "%{P}{%{tmpLeftTwo}}"
*script exec !varSet tmpVar "%{tmpLeft}%{tmpLeftTwo}%{tmpRightTwo}"
*script exec !varSet tmpLeft ""
*script exec !varSet tmpRight ""
*script exec !setlistsep <
*script GOTO foundVarAgain

*script LABEL endForVar
*script exec !msgbox "%{tmpFirstParams} %{tmpVar}"

*script ~bang