[Date Prev][Date Next][Subject Prev][Subject Next][ Date Index][ Subject Index]

Re: VAriables on the command line.



It occurred to me that it might help to unpack and analyze the long
keyboard-file assignment that I posted last night in response to Fred.
The underlying XPL that accomplishes Fred's desired command is as
follows (using non-decodable, commented pseudo code):

Save full path and filename to Save/Get 01
>;*;
If the filename includes an extension (dot something)...
{240}".">;*;
... lop it off:
>;*;
Finally, issue the TYF (a/k/a PRINTF) command, appending ".ps" to the filename:
BX tyf/nv ,.psQ2 ;*;

Here's the same XPL program in decodable form:

'%--_XYENCode_start--
~~>~~="."~>~~>~
'BXtyf/nv_,~.ps'Q2
'%--_XYENCode___end--
Next, U2 frame XMACRO (which can be shortened to XM) allows you to run little XPL programs from the CMline. The usage is XM [code]. The rules for translating XPL into XM code are in the Help screen (HELP XMACRO), but, basically, left and right guillemets are represented on the CMline as square brackets and functions are represented by their 2-character mnemonics; a function occurring after a non-function must be preceded by a comma. (Another frame, XMCODE, automates the translation from real XPL code to XM-compatible pseudo code, but the end-product may require some manual tweaking.) Translating the above XPL into an XM command, we get:

xm [SX01,[VA$FP]][IF[IS01]{240}"."][SX01,[VA@01.1]][EI],BXtyf/nv ,[PV01].psQ2
Since this barely fits on the CMline, let's recast it as a keyboard file assignment. (It could also be executed as a "long" U2 framename with frame U2L.) To feed an argument to a U2 frame in the KBD file, you need another U2 frame, PrsKbdArg. In straight XPL, it would look like this (using text mnemonics instead of actual 3-byte functions):
JM 2.PrsKbdArgQ2
xm{space}[SX01,[VA$FP]][IF[IS01]{240}"."][SX01,[VA@01.1]][EI],BXtyf/nv
,[PV01].psQ2NO

In decodable form:

'%--_XYENCode_start--
'JM2.PrsKbdArg'Q2xm_[SX01,[VA$FP]][IF[IS01]{240}"."][SX01,[VA@
01.1]][EI],BXtyf/nv_,[PV01].psQ2'NO'^
'%--_XYENCode___end--
Now we can use frame KCODE to translate that into KBD-file syntax (inserting commas between chars, func CO for actual commas, etc.)

20=JM2,.,P,r,s,K,b,d,A,r,g,Q2x,m, ,[,S,X,0,1,CO[,V,A,$,F,P,],],
[,I,F,[,I,S,0,1,],ð,",.,",],[,S,X,0,1,CO[,V,A,@,0,1,.,1,],],[,E,I,],
COB,X,t,y,f,/,n,v, ,CO[,P,V,0,1,],.,p,s,Q,2,NO

In decodable form, this becomes what I posted last night:

'%--_XYENCode_start--
20=JM2,.,P,r,s,K,b,d,A,R,g,Q2x,m,_,[,S,X,0,1,CO[,V,A,$,F,P,],]
,[,I,F,[,I,S,0,1,],~=,",.,",],[,S,X,0,1,CO[,V,A,@,0,1,.,1,],],
[,E,I,],COB,X,t,y,f,/,n,v,_,CO[,P,V,0,1,],.,p,s,Q,2,NO'^
'%--_XYENCode___end--
An alternate approach would be to have the KBD file macro simply place the manufactured TYF command on the CMline without actually executing it. You can then see the command for yourself, and launch it with . This is done by substituting func BC for BX and omitting the Q2:

'%--_XYENCode_start--
20=JM2,.,P,r,s,K,b,d,A,R,g,Q2x,m,_,[,S,X,0,1,CO[,V,A,$,F,P,],]
,[,I,F,[,I,S,0,1,],~=,",.,",],[,S,X,0,1,CO[,V,A,@,0,1,.,1,],],
[,E,I,],COB,C,t,y,f,/,n,v,_,CO[,P,V,0,1,],.,p,s,NO'^
'%--_XYENCode___end--

Hope this helps.

--
Carl Distefano
cld@xxxxxxxx