Reply to note from Fred Weiner Fri, 1 Feb 2013
18:26:23 -0700
> Another question, regarding this pseudo code plus commentary:
> If the filename includes an extension (dot something)...
> {240}".">;*;
> .... lop it off:
> >;*;
>
> I understand that {240} means "contains." But not what
> does.
It's a parsing operator. If has the string "red.white.blue",
then is "red", is "white", and is
"blue". It works with any separator. If is "and/or", then
is "and", and is "or". Etc., etc.
So, in your example, if is "d:\path\myfile.txt", then
is "d:\path\myfile"; the extension ".txt" is lopped off.
One caveat with VA@: it will only parse a maximum of 77 bytes of
input; if the input string is longer than that, it will parse the
first 77 bytes and *discard* the balance of the string! When I used
in your example, I was gambling that your fully-qualified
path and filename () would never amount to more than 77
characters. Of course, once you changed to (filename
only), any risk was eliminated.
If there is any real chance that the 77-byte limit on input will be
exceeded, you can't use VA@ to parse; you've got to use the XS
parser, which is more labor-intensive. Some years ago I wrote a U2
frame (never published, I don't think) that overcomes the 77-byte
limitation of the native VA@ operator while retaining the handy
syntax. The frame is called VA@*,VN@*, with two variants. VA@ takes
input from any S/G and parses the desired substring into S/G 50; VN@
takes input from any S/G and parses the substring into the S/G that
contained the input, overwriting the original contents of that S/G.
So, for example:
~'JM2.VA@01.1'Q2 puts "red" into S/G 50; and
~'JM2.VN@01.3'Q2 puts "blue" into S/G 01
(overwriting 01's original contents of "red.white.blue"). If you're
interested, see below for the frame and a couple of examples with
long input -- the first paragraph of Moby-Dick turned into comma-
delimited text.
'%--_XYENCode_start--
Frame_(add_to_U2_to_run_examples_below)'.'^{{5VA@*,VN@*}}_"VA@
[S/G]{separator}#"-style_parsing_operator_(e.g.,_'JM2.VA@01,35
'Q2)_overcomes_77-byte_limit_of_native_VA@nn_[S/G_50_out_(fram
ename_VA@*)',_framename_VN@*_sends_output_to_input_S/G]__CLD_r
ev.9/3/08_[Renumber_manually]'^~B~)~>~~>~~~~<
SX45,~~>~~+"~><0~>~<
SV"+~+",~>~"~>~~="VA"~>~+
"~+"~>~>"~>~~~~="VN
"~>~~>~~~>~~+"~>~=~~>~~~
~+1~>~<=~~>~+",43
,"+~+",,42~>~==~-1&~~{~
<0~>"~>~~="VA"~>~+"~+",~<
IS42~>~>"~>~~~="VN"~>~+"~+",~~>"~>~~+"~~~+",~~>~~"~>~~="VN"~>~+"~+",~+"~>~>"~>~~+"~~"~>~~="VA"~>~+"~+",~~>"~>~~~~~~~~~~~~~B'^'^',*',_Example_1_(using_framename_VA@)'.'^',
*',_Parses_"philosophical"_out_of_S/G_01_into_S/G_50'^',*','^~<
SV01,Call,me,Ishmael,Some,years,ago,never,mind,how,long,precis
ely,having,little,or,no,money,in,my,purse,and,nothing,particul
ar,to,interest,me,on,shore,I,thought,I,would,sail,about,a,litt
le,and,see,the,watery,part,of,the,world,It,is,a,way,I,have,of,
driving,off,the,spleen,and,regulating,the,circulation,Whenever
,I,find,myself,growing,grim,about,the,mouth,whenever,it,is,a,d
amp,drizzly,November,in,my,soul,whenever,I,find,myself,involun
tarily,pausing,before,coffin,warehouses,and,bringing,up,the,re
ar,of,every,funeral,I,meet,and,especially,whenever,my,hypos,ge
t,such,an,upper,hand,of,me,that,it,requires,a,strong,moral,pri
nciple,to,prevent,me,from,deliberately,stepping,into,the,stree
t,and,methodically,knocking,people'`s,hats,off,then,I,account,
it,high,time,to,get,to,sea,as,soon,as,I,can,This,is,my,substit
ute,for,pistol,and,ball,With,a,philosophical,flourish,Cato,thr
ows,himself,upon,his,sword,I,quietly,take,to,the,ship,There,is
,nothing,surprising,in,this,If,they,but,knew,it,almost,all,men
,in,their,degree,some,time,or,other,cherish,very,nearly,the,sa
me,feelings,towards,the,ocean,with,me~>'JM2.VA@01,156'Q2~~'^'^',*',_Example_2_(using_framename_VN@)'.'^',*',_Pa
rses_"flourish"_out_of_S/G_01_into_S/G_01_(overwriting_the_ori
ginal'^',*',___contents_of_S/G_01)'^',*','^~'JM2.VN@01,157'Q2~~'^'^
'%--_XYENCode___end--
--
Carl Distefano
cld@xxxxxxxx