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

Re: Xy as database handler--a workable idea



Reply to note from Harry Binswanger  Sun, 14 Jun 2009 00:51:36 -0400

Harry:

> I would have records > 77 bytes, but no fields > than that.

Records > 77 is a deal-breaker. You can't use native VA@.

> Now, I wonder if we can take the next step: making
> (effectively) arrays for XPL.

For 2-dimensional arrays, that's a fairly straight-forward
adaptation of the code I posted yesterday (see below). The wildcard
in any such exercise, of course, is available memory (or the lack of
it). For data of more than a couple of thousand bytes, you're better
off putting the data in a text file and using normal editing
commands to locate or change fields. For example, suppose your data
looked like this:

row 1: col1,col2,col3,col4,col5,col6,col7,col8,col9
row 2: col1,col2,col3,col4,col5,col6,col7,col8,col9
...
row 1000: col1,col2,col3,col4,col5,col6,col7,col8,col9

To locate (col,row)=(7,3), you could simply do:
SE/6 "[cr+lf]"<xc>
SE/2 ","<xc>

However, to illustrate that, in principle, you can do these things
in memory, with XPL, plug the frames below into U2, and try commands
like the following:

ARRAYINT 7,7<Helpkey> (Initialize array with 7 cols, 7 rows)
ARRAYPUT 5,3=Harry<Helpkey> (Put "Harry" into field 5,3)

See the frames themselves for more usage details.

For...Next loops are an easy extension to these frames. I leave it
to you as an exercise. Have it on my desk before midnight!

XPLeNCODE v2.0
b-gin [UNTITLED]
{{;5arrayint}} Initialize 2-dimensional data array (saved to{032}
ARRAY.SAV) [CLD][cr|lf]
{002}
;*;[cr|lf]
;*; Usages:[cr|lf]
;*;{032} ARRAYINT rows,cols<Helpkey>[cr|lf]
;*; {032}
{<}SV50,rows,cols{>}
[JM_]2.arrayint[Q2_]
[cr|lf]
;*;[cr|lf]
[JM_]2.arrayspec[Q2_]
{<}SV99,{>}
{<}SX51,{<}PV51{>}-1{>}
{<}IF{<}PV51{>}>0{>}{<}CUa,51{>}
{<}SX99,{<}IS99{>}+","{>}
{<}LBa{>}
{<}EI{>}
{<}SX50,{<}IS99{>}+"[cr|lf]
"{>}
{<}SX99,{<}IS50{>}{>}
{<}SX52,{<}PV52{>}-1{>}
{<}IF{<}PV52{>}>0{>}{<}CUb,52{>}
{<}SX99,{<}IS99{>}+{<}IS50{>}{>}
{<}LBb{>}
{<}EI{>}
[JM_]2.arraysave[Q2_]
{002}
[cr|lf]
[cr|lf]
{{;5arrayput}} Put data in col,row (S/G 50 in; data in
ARRAY.SAV){032}[CLD][cr|lf]
{002}
;*;[cr|lf]
;*; Usages:[cr|lf]
;*; ARRAYPUT rows,col=[data]<Helpkey>[cr|lf]
;*; {032}
{<}SV50,row,col=[data]{>}
[JM_]2.arrayput[Q2_]
[cr|lf]
;*;[cr|lf]
{<}IF{<}VA|50{>}<1{>}
{<}PRARRAYPUT row,col=[data]<Helpkey>{>}{<}EX{>}
{<}EI{>};*;[cr|lf]
{<}SX98,{<}is50{>}{>}
[JM_]2.arrayldpm[Q2_]
{<}SX50,{<}is98{>}{>};*;[cr|lf]
{<}SV51,={>}
{<}XS50,51,51,52,53{>}
{<}SX50,{<}IS51{>}{>}
[JM_]2.arrayspec[Q2_]
;*;[cr|lf]
{<}SX50,{<}IS53{>}{>}
{<}SV53,[cr|lf]{>}
{<}SX54,{<}IS99{>}{>}
{<}SV55,{>}
{<}IF{<}PV52{>}>1{>}
{<}SX52,{<}PV52{>}-1{>}{<}CUb,52{>}
{<}SV56,{>}
{<}XS54,53,57,58,56{>}
{<}IF{<}IS58{>}<>{<}IS53{>}{>}
{<}SX52,{<}PV52{>}+1{>}
{<}SV51,row{>}
{<}LBa{>}
{<}SX51,"Nonexistent "+{<}is51{>}+" "+{<}is52{>}{>}
{<}PR@51{>}{<}EX{>}
{<}EI{>}
{<}SX55,{<}IS55{>}+{<}IS57{>}+{<}IS53{>}{>}
{<}SX54,{<}IS56{>}{>}
{<}LBb{>}
{<}EI{>}
{<}SV53,,{>}
{<}SX51,{<}PV51{>}-1{>}{<}CUc,51{>}
{<}SV56,{>}
{<}XS54,53,57,58,56{>}
{<}IF{<}is58{>}<>{<}is53{>}{>}
{<}SX52,{<}pv51{>}+1{>}
{<}SV51,column{>}
{<}GLa{>}
{<}EI{>}
{<}SX55,{<}IS55{>}+{<}IS57{>}+{<}IS53{>}{>}
{<}SX54,{<}IS56{>}{>}
{<}LBc{>}
{<}IF{<}IS53{>}{238}{<}IS54{>}<0{>}
{<}SV53,{>}
{<}SV54,{>}
{<}SV58,{>}
{<}EI{>}
{<}IF{<}VA|54{>}>0{>}
{<}SV58,{>}
{<}XS54,53,57,57,58{>}
{<}EI{>}
{<}SX99,{<}IS55{>}+{<}IS50{>}+{<}IS53{>}+{<}IS58{>}{>}
[JM_]2.arraysave[Q2_]
{002}
[cr|lf]
[cr|lf]
{{;5arrayspec}} Test for valid cols,rows spec in S/G 50 [CLD][cr|lf]
{002}
{<}SX51,{<}VA@50,1{>}{>}
{<}SX52,{<}VA@50,2{>}{>}
{<}IF{<}VA|50{>}<1+{<}VA|51{>}+{<}VA|52{>}!{<}VA{021}51{>}+{<}VA{
021}52{>}<2!{<}VA@50{>}{240}"."{>}
{<}PRBad array spec: @50{>}{<}EX1{>}
{<}EI{>}
{<}IF{<}PV51{>}<1!{<}PV52{>}<1{>}
{<}GLa{>}
{<}EI{>}{002}
[cr|lf]
[cr|lf]
{{;5arraysave}} Save S/G 99 to ARRAY.SAV (in Editor's dir)
[CLD][cr|lf]
{002}
{<}SX50,{<}va$ed{>}{>}
[JM_]2.GetPath[Q2_]
{<}SX50,{<}is50{>}+"\ARRAY.SAV"{>}
[BX_]sa %99,{<}PV50{>}[Q2_]
[BX_]wt[Q2_]
[JM_]2.CallOrGo/100[Q2_]
[JM_]2.reca[Q2_]
{<}PRDone{>}{002}
[cr|lf]
[cr|lf]
{{;5arrayldpm}} LDPM ARRAY.SAV to S/G 99 [CLD][cr|lf]
{002}
{<}SX50,{<}va$ed{>}{>}
[JM_]2.GetPath[Q2_]
{<}SX50,{<}is50{>}+"\ARRAY.SAV"{>}
[JM_]2.SV50[Q2_]
{<}SX99,{<}is50{>}{>}{002}
[cr|lf]
[cr|lf]
{{;5SV50}} SaVe file contents{032}to S/G 50 (S/G 50 in & out: d:\
path\filename in; file contents out) [CLD 1/18/09][cr|lf]
{002}
{<}IF{<}VA|50{>}>0{>}
[BX_]exist {<}PV50{>}[Q2_]
{<}IF@not({<}ER{>}){>}
{<}IF".DLL"{238}{<}VA$ED{>}<0{>}
{<}SX49,{<}IS50{>}{>}
[JM_]2.UsurpB[Q2_]
{<}SX51,"
{<}IF{<}PV54{>}<0{>}
{<}SV"+{<}IS50{>}+",{>}
{<}EI{>}
{<}SX52,{<}IS"+{<}IS50{>}+"{>}{>}"{>}{<}PV51{>}
[BX_]ldpm {<}PV49{>},{<}PV50{>}[Q2_]
[BX_]wt[Q2_]
{<}SX51,"
{<}SX49,{<}IS"+{<}IS50{>}+"{>}+""""{>}
{<}IF{<}PV54{>}<0{>}
[BX_]remove "+{<}IS50{>}+"[Q2_]
{<}EI{>}
{<}SX"+{<}IS50{>}+",{<}IS52{>}{>}"{>}{<}PV51{>}
{<}SX50,{<}IS49{>}{>}{<}EX{>}
{<}EI{>}
{<}SX50,{<}IS50{>}+",50"{>}
[JM_]2.ldnb[Q2_]
{<}EX{>}
{<}EI{>}
{<}SV50,{>}
{<}EI{>}{002}
[cr|lf]
[cr|lf]
- - - - - [cr|lf]
-nd
XPLeNCODE


'%--_XYENCode_start--
{{5arrayint}}_Initialize_2-dimensional_data_array_(saved_to_AR
RAY.SAV)_[CLD]'^~B',*','^',*',__Usages'.'^',*',__ARRAYINT_rows
,cols<Helpkey>'^',*',__~<SV50,rows,cols~>'JM2.arrayint'Q2'^',*
','^'JM2.arrayspec'Q2~<SV99,~>~<SX51,~<PV51~>-1~>~<IF~<PV51~>>
0~>~<CUa,51~>~<SX99,~<IS99~>+","~>~<LBa~>~<EI~>~<SX50,~<IS99~>
+"'^"~>~<SX99,~<IS50~>~>~<SX52,~<PV52~>-1~>~<IF~<PV52~>>0~>~<C
Ub,52~>~<SX99,~<IS99~>+~<IS50~>~>~<LBb~>~<EI~>'JM2.arraysave'Q2
~B'^'^{{5arrayput}}_Put_data_in_col,row_(S/G_50_in',_data_in_A
RRAY.SAV)_[CLD]'^~B',*','^',*',__Usages'.'^',*',__ARRAYPUT_row
s,col=[data]<Helpkey>'^',*',__~<SV50,row,col=[data]~>'JM2.arra
yput'Q2'^',*','^~<IF~<VA|50~><1~>~<PRARRAYPUT_row,col=[data]<H
elpkey>~>~<EX~>~<EI~>',*','^~<SX98,~<is50~>~>'JM2.arrayldpm'Q2
~<SX50,~<is98~>~>',*','^~<SV51,=~>~<XS50,51,51,52,53~>~<SX50,~<
IS51~>~>'JM2.arrayspec'Q2',*','^~<SX50,~<IS53~>~>~<SV53,'^~>~<
SX54,~<IS99~>~>~<SV55,~>~<IF~<PV52~>>1~>~<SX52,~<PV52~>-1~>~<C
Ub,52~>~<SV56,~>~<XS54,53,57,58,56~>~<IF~<IS58~><>~<IS53~>~>~<
SX52,~<PV52~>+1~>~<SV51,row~>~<LBa~>~<SX51,"Nonexistent_"+~<is
51~>+"_"+~<is52~>~>~<PR@51~>~<EX~>~<EI~>~<SX55,~<IS55~>+~<IS57
~>+~<IS53~>~>~<SX54,~<IS56~>~>~<LBb~>~<EI~>~<SV53,,~>~<SX51,~<
PV51~>-1~>~<CUc,51~>~<SV56,~>~<XS54,53,57,58,56~>~<IF~<is58~><
>~<is53~>~>~<SX52,~<pv51~>+1~>~<SV51,column~>~<GLa~>~<EI~>~<SX
55,~<IS55~>+~<IS57~>+~<IS53~>~>~<SX54,~<IS56~>~>~<LBc~>~<IF~<I
S53~>~{~<IS54~><0~>~<SV53,~>~<SV54,~>~<SV58,~>~<EI~>~<IF~<VA|5
4~>>0~>~<SV58,~>~<XS54,53,57,57,58~>~<EI~>~<SX99,~<IS55~>+~<IS
50~>+~<IS53~>+~<IS58~>~>'JM2.arraysave'Q2~B'^'^{{5arrayspec}}_
Test_for_valid_cols,rows_spec_in_S/G_50_[CLD]'^~B~<SX51,~<VA@5
0,1~>~>~<SX52,~<VA@50,2~>~>~<IF~<VA|50~><1+~<VA|51~>+~<VA|52~>
'|~<VA~U51~>+~<VA~U52~><2'|~<VA@50~>~="."~>~<PRBad_array_spec'.
_@50~>~<EX1~>~<EI~>~<IF~<PV51~><1'|~<PV52~><1~>~<GLa~>~<EI~>~B
'^'^{{5arraysave}}_Save_S/G_99_to_ARRAY.SAV_(in_Editor'`s_dir)
_[CLD]'^~B~<SX50,~<va$ed~>~>'JM2.GetPath'Q2~<SX50,~<is50~>+"\A
RRAY.SAV"~>'BXsa_'/99,~<PV50~>'Q2'BXwt'Q2'JM2.CallOrGo/100'Q2'JM
2.reca'Q2~<PRDone~>~B'^'^{{5arrayldpm}}_LDPM_ARRAY.SAV_to_S/G_
99_[CLD]'^~B~<SX50,~<va$ed~>~>'JM2.GetPath'Q2~<SX50,~<is50~>+"
\ARRAY.SAV"~>'JM2.SV50'Q2~<SX99,~<is50~>~>~B'^'^{{5SV50}}_SaVe
_file_contents_to_S/G_50_(S/G_50_in_&_out'._d'.\path\filename_
in',_file_contents_out)_[CLD_1/18/09]'^~B~<IF~<VA|50~>>0~>'BXe
xist_~<PV50~>'Q2~<IF@not(~<ER~>)~>~<IF".DLL"~{~<VA$ED~><0~>~<S
X49,~<IS50~>~>'JM2.UsurpB'Q2~<SX51,"~<IF~<PV54~><0~>~<SV"+~<IS
50~>+",~>~<EI~>~<SX52,~<IS"+~<IS50~>+"~>~>"~>~<PV51~>'BXldpm_~<
PV49~>,~<PV50~>'Q2'BXwt'Q2~<SX51,"~<SX49,~<IS"+~<IS50~>+"~>+""
""~>~<IF~<PV54~><0~>'BXremove_"+~<IS50~>+"'Q2~<EI~>~<SX"+~<IS5
0~>+",~<IS52~>~>"~>~<PV51~>~<SX50,~<IS49~>~>~<EX~>~<EI~>~<SX50
,~<IS50~>+",50"~>'JM2.ldnb'Q2~<EX~>~<EI~>~<SV50,~>~<EI~>~B'^'^
-_-_-_-_-_'^
'%--_XYENCode___end--

-- Carl Distefano cld@xxxxxxxx