LogAwp_attrib11Opasnet base connectionInterface for uploading data to and downloading from the Opasnet Base.
<a href="http://en.opasnet.org/w/Image:Opasnet_base_connection.ANA">Wiki description</a>Jouni Tuomisto9. maata 2008 10:42ktluser12. Julta 2010 1:23 48,241,0,0,1,1,1,0,0,0,01,18,25,800,416,172,102,90,476,316Arial, 150,Model Op_en2676,2,2,-32766,1,Opasnet base connection.ANA79,1,1,0,1,9,2794,2159,15,02,40,50,640,600Username0196,44,1188,121,0,0,1,0,0,0,206,0,152425,39321,65535Opasnet_usernameTabIndex:1 TextAlways2 Analytica modelktluser1. Aprta 2009 9:38 48,24200,216,160,321,0,0,1,1,1,0,,0,1,759,60,353,272,173 Analytica model:140,28,-1124,121,0,0,1,0,1,0,,0,65535,65532,19661Add a list of variable identifiers to be downloaded at the same time. First, give the number of Analytica variables (nodes) you want to upload. Then, fill in the table Object info. Finally, go back to main page.140,140,-1124,1001,0,0,1,0,1,0,,0,N variables0140,180,1116,121,0,0,1,0,0,0,72,0,152425,39321,65535N_variables2Object info0140,204,1116,121,0,0,1,0,0,0,72,0,152425,39321,65535Object_infoReplace data?0264,140,1256,121,0,0,1,0,0,0,374,0,152425,39321,65535Replace_data_Data source0264,116,1256,121,0,0,1,0,0,0,374,0,1Data_sourceWriterpsswd0196,68,1188,121,0,0,1,0,0,0,206,0,152425,39321,65535WriterpsswdUpload data:264,300,-1256,121,0,0,1,0,1,0,,0,65535,65532,19661Upload all data directly to Opasnet Base. This includes
both object and explanation information (if not uploaded
already) and the actual observations.264,348,-1256,361,0,0,1,0,1,0,,0,Provide general information:264,20,-1256,121,0,0,1,0,1,0,,0,65535,65532,19661Help pages in Opasnet about
<a href="http://en.opasnet.org/w/Opasnet_Base">Opasnet Base</a>
<a href="http://en.opasnet.org/w/Uploading_to_Opasnet_Base">Uploading to Opasnet Base</a>
<a href="http://en.opasnet.org/w/Opasnet_base_connection">Opasnet Base connection</a>
<a href="http://en.opasnet.org/w/Opasnet_Base_UI">Opasnet Base user interface</a>
652,68,-1108,60Choose the format of input data.264,92,-1256,121,0,0,1,0,1,0,,0,65535,65532,196611 Copy-paste a data tablektluser4. Febta 2010 7:10 48,2472,216,160,321,541,26,589,389,17Copy-paste a data table. After filling the two fields, go back to main page.304,168,-1252,1201,0,0,1,0,1,0,,0,2,693,146,476,224Providing upload data:304,36,-1252,121,0,0,1,0,1,0,,0,65535,65532,19661Observations0308,152,1248,801,0,0,1,0,0,0,366,0,152425,39321,65535Copy_pasteTabIndex:3Object info0176,256,1116,131,0,0,1,0,0,0,72,0,152425,39321,65535Object_info1_3_4Data table1416,264,1104,131,0,0,1,0,0,0,72,0,1Data_tableCheck that your data table looks sensible:160,264,-1148,123 Node to be formatted as data tablektluser4. Febta 2010 7:10 48,24328,216,160,321,729,57,382,341,17Columns['Exposure','Asthma','Atopy']224,272,148,12[Formnode Columns1]['Exposure','Asthma','Atopy']N_rows0172,181,1116,131,0,0,1,0,0,0,72,0,152425,39321,65535N_rowsFirst row must contain values, not column names! After filling the four fields go back to main page.172,148,-1124,1001,0,0,1,0,1,0,,0,Analytica table0172,204,1116,121,0,0,1,0,0,0,72,0,152425,39321,65535Analytica_tableColumns0172,157,1116,131,0,0,1,0,0,0,72,0,1Columns2 Node formatted as data table:172,36,-1124,121,0,0,1,0,1,0,,0,65535,65532,19661Object info0172,229,1116,131,0,0,1,0,0,0,72,0,152425,39321,65535Object_info1_3_44 Ready-made data-table nodektluser4. Febta 2010 7:10 48,24456,216,160,321,770,118,445,300,17Ready-made0212,156,1148,121,0,0,1,0,0,0,154,0,152425,39321,65535Ready_madeObject info0212,180,1148,121,0,0,1,0,0,0,72,0,152425,39321,65535Object_info1_3_4Give the name of the Analytica node that is formatted as data table. Then, give object info and go back to main page.212,148,-1164,1001,0,0,1,0,1,0,,0,2 Node formatted as data table:212,36,-1164,121,0,0,1,0,1,0,,0,65535,65532,19661Model detailsktluser4. Febta 2010 7:10 48,24664,352,148,241,0,0,1,1,1,0,,0,1,10,46,1124,528,17Password0736,352,1160,121,0,0,1,0,0,0,142,0,152425,39321,65535Opasnet_passwordTabIndex:2 TextAlwaysPlatform0736,16,1160,121,0,0,1,0,0,0,142,0,152425,39321,65535PlatformC) For very large variables: Upload only the object and location information. Create csv files of other data to c:\temp\ and upload them separately (you need a direct access to the Opasnet Base).832,212,-1256,681,0,0,1,0,1,0,,0,B) Upload so that the actual data is not visible without a password. Metadata is visible anyway.832,88,-1256,481,0,0,1,0,1,0,,0,2,693,146,476,224Writerjtue24. maata 2009 9:36 48,24184,40,148,241,298,13,707,490,17W locvar a:= Locations;
var b:= a[.j='obj_id_i'];
var c:= cardinals[table1='loc']+a[@.j=1];
a:= array(a.j,[c, c, findid(b,obj,'ident'), a, a, a]);
textify(a)512,296,148,162,84,125,476,2452,318,186,606,278,0,MIDM65535,45873,39321[Sys_localindex('J'),Sys_localindex('I')]2,D,4,2,0,0,4,0,$,0,"ABBREV",0100,1,1,1,1,9,2970,2100,15,0[Sys_localindex('I'),16,Sys_localindex('I'),1,Sys_localindex('J'),1]W loccellvar a:= Loccells;
var b:= textify(findid(a[.j='id'], obj, 'ident'));
var c:= textify(a[.j='loc_id']);
b:= findid(b&'+'&c, (if Loc.j='obj_id_i' then Loc&'+'&Loc[.j='location'] else Loc), 'obj_id_i');
a:= array(a.j,[(@a.i+cardinals[table1='loccell']), (a+cardinals[table1='cell']), b]);
textify(a)512,384,148,162,776,90,476,4872,33,106,453,537,0,MIDM65535,45873,39321[Sys_localindex('J'),Sys_localindex('I')]2,I,4,2,0,0,4,0,$,0,"ABBREV",0W cellvar a:= Cells;
a:= array(a.j, [
a[.j='id']+cardinals[table1='cell'],
W_actobjs[@w_actsi=lap*2], a, a, a]);
textify(a)512,336,148,162,783,409,476,3792,14,241,659,368,0,MIDM65535,45873,39321[Sys_localindex('J'),Sys_localindex('I')]2,D,4,2,0,0,4,0,$,0,"ABBREV",0[Sys_localindex('J'),1,Sys_localindex('I'),1,Sys_localindex('J'),1]W objvar a:= Objects;
var b:= if a[.j='ident'] = 0 then -1 else a[.j='ident'];
b:= findid(b, obj, 'ident');
b:= if b='0' then cardinals[table1='obj']+a[.j='id'] else b;
a:= if a.j='id' then b else a;
textify(a)512,96,148,162,372,300,476,3432,590,354,626,444,0,MIDM65535,45873,39321[Sys_localindex('J'),Sys_localindex('I')]2,I,4,2,0,0,4,0,$,0,"ABBREV",0[]W actIndex j:= ['id', 'acttype_id','who','comments'];
var a:= Acts[.j=j];
a:= if j='id' then a+cardinals[table1='act'] else a;
a:= if a=null or a=0 then '' else a&'';
textify(a)512,136,148,162,66,82,476,3402,34,242,690,459,0,MIDM65535,45873,39321[Sys_localindex('J'),Sys_localindex('I')]2,I,4,2,0,0,4,0,$,0,"ABBREV",0[Sys_localindex('J'),1,Sys_localindex('I'),1,Sys_localindex('J'),1]W resvar a:= Results;
index i:= subset(if a[.j='result']=null and a[.j='description']=0 then 0 else 1);
a:= a[.i=i];
a:= array(a.j, [textify(a.i+Cardinals[table1='res']), textify(a+ Cardinals[table1='cell']), textify(a),a,a]);
if a=null then '' else a512,424,148,132,629,191,582,2972,461,218,609,375,0,MIDM65535,45873,39321[Sys_localindex('J'),Sys_localindex('I')]2,D,4,2,0,0,4,0,$,0,"ABBREV",0[]Object info for lapObject_info[N_vars=Lap]176,336,148,202,140,217,476,2242,653,25,488,226,0,MIDM2,104,359,460,228,0,MIDM52425,39321,65535[N_vars,Info][N_vars,Info][0,1,1,0]Loccellsvar a:= cellulise(Data_table);
index temp:= copyindex(a.j);
a:= a[.j=temp];
index j:= ['id', 'cell_id', 'loc_id'];
index i:= 1..size(a);
a:= array(j,[a.temp, @a.cell, a]);
concatrows(a,a.temp,a.cell,i)400,384,148,162,692,58,526,5362,51,58,552,488,0,MIDM[Sys_localindex('J'),Sys_localindex('I'),Undefined,Undefined,Undefined,1]2,D,4,2,0,0,4,0,$,0,"ABBREV",0[][Sys_localindex('J'),3,Sys_localindex('CELL'),1,Sys_localindex('J'),1]Resultsvar a:= data_table[.j='result'];
var b:= cellrow;
b:= sum(if b=1 then @b.cell else 0,b.cell);
var c:= Data_table[.j='obs'];
c:= if c=null then 0 else c;
index j:= ['id','cell_id','obs','result','restext'];
array(j,[0, b, c, (if istext(a) then '' else a) , (if istext(a) then a else '')])400,424,148,162,416,57,581,5672,662,12,469,411,0,MIDM[Sys_localindex('J'),Sys_localindex('I')]2,D,4,2,0,0,4,0,$,0,"ABBREV",0[Run,2,Sys_localindex('J'),1,Sys_localindex('I'),1]Locationsvar a:= removecol(data_table);
index temp:= ['obj_id_i','location'];
a:= array(temp,[a.j,a]);
index temp2:= 1..size(a.j)*size(a.i);
a:= concatrows(a,a.j,a.i,temp2);
index i:= unique(a,a.temp2);
a:= a[.temp2=i];
index j:= ['id', 'std_id', 'obj_id_i', 'location', 'description'];
a:= array(j,[@i, @i, a[temp='obj_id_i'], a[temp='location'], ''])400,296,148,162,498,99,476,5812,594,317,495,259,0,MIDM[Sys_localindex('J'),Sys_localindex('I')]2,D,4,2,0,0,4,0,$,0,"ABBREV",0['','','','',''][Self,4,Sys_localindex('J'),1,Sys_localindex('I'),1]Data tableData_table1;
Data_table2;
Data_table3;
Data_table4;
var a:= evaluate('Data_table'&selecttext(Data_source,1,1));
indexify(a)176,208,148,162,150,90,482,5012,363,425,698,233,0,MIDM[Formnode Data_table8][Sys_localindex('I'),Sys_localindex('J')]2,D,4,2,0,0,4,0,$,0,"ABBREV",0[1,1,1,0][Sys_localindex('I'),1,Sys_localindex('J'),1]Info['Analytica identifier','ident','name','unit','# explanation cols','observation name','probabilistic?']200,48,148,132,102,90,476,3792,90,166,416,303,0,MIDM['Analytica identifier','ident','name','unit','# explanation cols','observation name','probabilistic?']ObjectsIndex j:= ['id','ident','name','unit','objtype_id','page','wiki_id'];
index i:= copyindex(N_vars);
var a:= Object_info[Info=j];
var Ident:= Object_info[Info='ident'];
a:= if a=null then 0 else a;
var b:= sum(findintext(wikis,ident)*@wikis,wikis);
var c:= if b=0 then '' else wikis[@wikis=b];
c:= if b=0 then '2664' else selecttext(ident,1+textlength(c));
a:= array(j,[@N_vars, ident, a, a, 1, c&'', if b=0 then '1' else b&'']);
a[@N_vars=@i]400,96,148,162,573,29,547,7242,11,31,656,283,0,MIDM[Sys_localindex('J'),Sys_localindex('I')][Indices,1,Sys_localindex('J'),1,Sys_localindex('I'),1]Copy-paste'Country Year Diagnosis Sex Age Deaths
Seychelles 2001 AAA Male 0-365 days 8
Seychelles 2001 AAA Female 0-365 days 11
Seychelles 2001 A00-B99 Male 0-365 days 0
Seychelles 2001 A00-B99 Female 0-365 days 0
Seychelles 2001 A00 Male 0-365 days 0
Seychelles 2001 A00 Female 0-365 days 0
Seychelles 2001 A09 Male 0-365 days 0
Seychelles 2001 A09 Female 0-365 days 0
Seychelles 2001 A01-A08 Male 0-365 days 0
Seychelles 2001 A01-A08 Female 0-365 days 0'64,256,152,162,586,79,476,465[Formnode Observations3]52425,39321,65535Data table1var a:= splittext(textreplace(Copy_paste, chr(10),'',true),chr(13));
index columns:= splittext(slice(a,1), chr(9));
index rows:= 1..size(a)-1;
a:= slice(a,rows+1);
a:= splittext(a, chr(9));
a:= for y:= rows do (slice(a[rows=y],@columns));
observise(a)64,208,148,162,7,115,476,3622,578,406,623,231,0,MIDM[Sys_localindex('ROWS'),Sys_localindex('COLUMNS')][1,1,1,0]['Country Year ICD-10 Sex Age Deaths','Seychelles 2001 AAA Male 0-365 days 8','Seychelles 2001 AAA Female 0-365 days 11','Seychelles 2001 A00-B99 Male 0-365 days 0','Seychelles 2001 A00-B99 Female 0-365 days 0','Seychelles 2001 A00 Male 0-365 days 0','Seychelles 2001 A00 Female 0-365 days 0','Seychelles 2001 A09 Male 0-365 days 0','Seychelles 2001 A09 Female 0-365 days 0','Seychelles 2001 A01-A08 Male 0-365 days 0','Seychelles 2001 A01-A08 Female 0-365 days 0']TestvariableTable(Time,Testindex)(
uniform(0,1),
uniform(1,2),
uniform(2,3)
)72,448,148,242,424,516,416,303,0,MIDM[Time,Testindex][Time,Testindex][1,0,0,0]Testindex['item 1']72,480,148,122,102,90,476,224['item 1']W cellsec(if w_cell.j = 'mean' then '' else W_cell)624,336,148,162,782,213,476,3792,41,191,618,368,0,MIDM65535,45873,39321[Sys_localindex('J'),Sys_localindex('I')]2,D,4,2,0,0,4,0,$,0,"ABBREV",0Cellsvar a:= Data_table;
index j:= ['id', 'actobj_id', 'mean', 'sd', 'n'];
var b:= cellrow;
b:= if b=1 then a[.j='result'] else null;
b:= array(j, [@b.cell, '', mean(b,b.i), sdeviation(b,b.i), sum(b<>null,b.i)]);
index i:= copyindex(b.cell);
b[.cell=i]400,336,148,162,7,30,526,6452,528,83,608,328,0,MIDM[Sys_localindex('J'),Sys_localindex('I'),Undefined,Undefined,Undefined,1]2,D,4,2,0,0,4,0,$,0,"ABBREV",0[][N_vars,2,Sys_localindex('I'),1,Sys_localindex('J'),1]Data table2var a:= Object_info_for_lap[Info='Analytica identifier'];
a:= if proba then sample(evaluate(a)) else evaluate(a);
var c:= Object_info_for_lap[Info='observation name'];
c:= if c='' or c=0 then 'result' else c;
index temp:= concat(indexnames(a),[c]);
index rows:= 1..size(a);
a:= if size(a)=1 then array(rows,temp,[a]) else
Mdarraytotable(a, rows, temp);
index columns:= if temp='Run' then 'obs' else temp;
a[@temp=@columns]64,336,148,202,29,169,476,4442,607,20,630,303,0,MIDM[Sys_localindex('ROWS'),Sys_localindex('COLUMNS')][1,1,1,0][N_vars,1,Sys_localindex('J'),1,Sys_localindex('I'),1]Probavar a:= Object_info_for_lap[Info='probabilistic?'];
(a=1 or a='Yes' or a='Y' or a='yes' or a='y')64,392,148,16Data sourceChoice(Self,1,False)176,160,148,162,102,90,476,224[Formnode Data_source1]52425,39321,65535['1 Copy-paste table','2 Analytica model','3 Node to be formatted as data table','4 Ready-made data table node'][1,1,0,0]N vars1.. N_variables200,72,148,12[1]N variablesif selecttext(Data_source,1,1)='2' then N_variables2 else 1200,96,148,1219661,48336,65535Lap1176,392,148,16[0,1,0,1]Indicescopyindex(Find_ind)400,260,148,122,140,321,476,4092,40,50,416,303,0,MIDM['Country','Year','Diagnosis','Sex','Age','Population']Object infoTable(Info,N_vars)(
'Testvariable',
'Op_en4589',
'Asthma and allergy',
'#',
0,
'Observation',
1
)200,24,148,162,140,217,476,2242,745,383,494,259,0,MIDM2,590,303,460,228,0,MIDM[Formnode Object_info4]52425,39321,65535[N_vars,Info][N_vars,Info][1,1,1,0]Analytica tableTable(Columns,Rows)(
1,0,1,1,0,1,1,0,0,1,
0,0,0,1,0,0,0,0,0,0,
1,0,0,0,0,0,0,0,0,0
)64,80,148,242,38,23,716,390,0,MIDM2,248,258,639,303,0,MIDM[Formnode Analytica_table2]52425,39321,65535[Columns,Rows][Columns,Rows]2,D,4,2,0,0,4,0,$,0,"ABBREV",0Rows1..N_rows64,112,148,12[1,2,3,4,5,6,7,8,9,10]1064,136,148,121,1,1,1,1,1,0,0,0,0[Formnode N_rows1]52425,39321,65535ActsIndex j:= ['id', 'acttype_id','who','comments'];
var c:= '';
var x:= 1;
var b:= while x<= size(N_vars) do (x:= x+1; c:= c&',create,upload');
b:= selecttext(b,2);
index i:= splittext(b,',');
array(j,[
@i,
if i='create' then 1 else (if selecttext(replace_data_,1,1)='Y' then 4 else 5),
opasnet_username,
if i ='upload' then 'Analytica '&Analyticaedition&', ('&Analyticaplatform&'), Version: '&textify(Analyticaversion) else ''])400,136,148,162,29,37,525,7242,29,360,694,283,0,MIDM[Sys_localindex('J'),Sys_localindex('I')]['',''][Self,1,Sys_localindex('I'),1,Sys_localindex('J'),1]Upload type 1.64,224,-156,561,0,0,1,0,1,0,,0,Upload type 3.64,84,-156,761,0,0,1,0,1,0,,0,Upload type 2.120,356,-1112,601,0,0,1,0,1,0,,0,W actobjindex j:= ['id', 'act_id', 'obj_id', 'series_id'];
var a:= w_act;
a:= array(j,[
@a.i+cardinals[table1='actobj'],
W_acts[@w_actsi=@a.i],
W_objs[@N_vars=round(@a.i/2+0.1)],
if a[.j= 'acttype_id'] = '5' then Seriess[@N_vars = round(@a.i/2+0.1)] else W_acts[@w_actsi=@a.i]]);
textify(a)624,136,148,162,77,45,476,3402,422,292,690,285,0,MIDM65535,45873,39321[Sys_localindex('J'),Sys_localindex('I')]2,I,4,2,0,0,4,0,$,0,"ABBREV",0[][Sys_localindex('J'),1,Sys_localindex('I'),1,Sys_localindex('J'),1]Find indcopyindex(removecol(data_table).j)
{var a:= Data_table.j[@.j=1..(size(Data_table.j)-1)];
a:= jointext(a,,',');
var b:= Object_info[Info='Analytica identifier'];
var c:= ['Run'];
var x:= 1;
while x<=size(b) do (
c:= concat(c,indexnames(evaluate(slice(b,x))));
x:= x+1);
c:= textreplace(c, '.' , '');
index temp:= 1..size(c);
c:= slice(c, temp);
c:= c[temp= unique(c,temp)];
index i:= 1..(size(c)-1);
c:= slice(c, i+1);
b:= jointext(c,c.i,',');
a:= if selecttext(Data_source,1,1)='2' then b else a;
splittext(a,',')}400,200,148,122,24,99,476,4182,264,274,416,303,0,MIDM[Self,Sys_localindex('I')]['Run']Series9.6.2010 Jouni Tuomisto
Why is this not just simply Cardinal? Because this looks for the previous replace event of the same object. This is used in the case that this upload is an append, not a replace.for x[]:= W_obj.i do (
var a:= query('
SELECT MAX(act.id)
FROM actobj
LEFT JOIN act ON actobj.act_id = act.id
WHERE obj_id = '&chr(39)&W_obj[.j = 'id', .i = x]&chr(39)&'
AND acttype_id = 4
');
a[@.j = 1, @.i=1] )624,96,148,162,102,90,476,3742,258,57,416,303,0,MIDM39325,65535,39321[Sys_localindex('I'),Sys_localindex('J')]Data table4var a:= ready_made;
a:= if istext(a) and size(a)=1 then evaluate(a) else a;
observise(a)352,48,148,162,4,175,482,5012,17,71,736,338,0,MIDM19661,48336,65535[Sys_localindex('ROWS'),Sys_localindex('COLUMNS')]2,D,4,2,0,0,4,0,$,0,"ABBREV",0[1,1,1,0][Sys_localindex('I'),1,Sys_localindex('J'),1]Data table3observise(analytica_table)64,40,148,162,4,175,482,5012,12,93,736,338,0,MIDM[Rows,Sys_localindex('COLUMNS')]2,D,4,2,0,0,4,0,$,0,"ABBREV",0[1,1,1,0][Sys_localindex('I'),1,Sys_localindex('J'),1]index columns:= ['Country','Year','Diagnosis','Sex','Age','Deaths'];
index rows:= 1..10;
array(rows,columns,[["Seychelles","2001","AAA","Male","0-365 days","8"],
["Seychelles","2001","AAA","Female","0-365 days","11"],
["Seychelles","2001","A00-B99","Male","0-365 days","0"],
["Seychelles","2001","A00-B99","Female","0-365 days","0"],
["Seychelles","2001","A00","Male","0-365 days","0"],
["Seychelles","2001","A00","Female","0-365 days","0"],
["Seychelles","2001","A09","Male","0-365 days","0"],
["Seychelles","2001","A09","Female","0-365 days","0"],
["Seychelles","2001","A01-A08","Male","0-365 days","0"],
["Seychelles","2001","A01-A08","Female","0-365 days","0"]])576,48,148,242,264,274,617,303,0,MIDM[Sys_localindex('COLUMNS'),Sys_localindex('ROWS')]W indvar a:= Indices1;
var b:= if a[.j='ident'] = 0 then -1 else a[.j='ident'];
b:= findid(b, obj, 'ident');
b:= if b='0' then cardinals[table1='obj']+a[.j='id'] else b;
a:= if a.j='id' then b else a;
textify(a)512,232,148,162,372,300,476,3432,429,135,626,444,0,MIDM65535,45873,39321[Sys_localindex('J'),Sys_localindex('I')]2,I,4,2,0,0,4,0,$,0,"ABBREV",0[]IndicesIndex j:= ['id','ident','name','unit','objtype_id','page','wiki_id'];
var a:= array(j,[@indices, indices, indices, '', 6, 2664, 1]);
index i:= copyindex(indices);
a[indices=i]400,232,148,162,573,29,547,7242,11,31,656,283,0,MIDM[Sys_localindex('J'),Sys_localindex('I')][Indices,1,Sys_localindex('J'),1,Sys_localindex('I'),1]Ready-madeVa1464,46,148,222,4,175,482,5012,17,71,736,338,0,MIDM[Formnode Ready_made1]52425,39321,65535[Sys_localindex('COLUMNS'),Sys_localindex('ROWS')]2,D,4,2,0,0,4,0,$,0,"ABBREV",0[1,1,1,0][Sys_localindex('I'),1,Sys_localindex('J'),1]Cellrowvar a:= Data_table;
var b:=cellulise(a);
b:= jointext(b,b.j,',');
var c:= removecol(a);
c:= jointext(c,c.j,',');
b:= b=c; /* THIS IS A MEMORY-INTENSIVE ROW. A LOOP COULD WORK BETTER?*/288,408,148,162,7,30,526,6452,528,83,608,328,0,MIDM[Sys_localindex('CELL'),Sys_localindex('I'),Undefined,Undefined,Undefined,1]2,D,4,2,0,0,4,0,$,0,"ABBREV",0[][N_vars,2,Sys_localindex('I'),1,Sys_localindex('J'),1]N variables1288,148,148,12[Formnode N_variables3]52425,39321,65535Upload type 4.468,44,-1172,361,0,0,1,0,1,0,,0,W objsTable(N_vars)(
'1278'
)624,216,148,162,372,300,476,3432,590,354,626,444,0,MIDM52427,56425,65535[Sys_localindex('J'),Sys_localindex('I')]2,I,4,2,0,0,4,0,$,0,"ABBREV",0[]W actsTable(W_actsi)(
'425','426'
)624,248,148,162,66,82,476,3402,38,26,208,200,0,MIDM52427,56425,65535[Sys_localindex('J'),Sys_localindex('I')]2,I,4,2,0,0,4,0,$,0,"ABBREV",0[Sys_localindex('J'),1,Sys_localindex('I'),1,Sys_localindex('J'),1]W actobjsTable(W_actsi)(
'888','889'
)624,280,148,162,77,45,476,3402,349,265,690,459,0,MIDM52427,56425,65535[Sys_localindex('J'),Sys_localindex('I')]2,I,4,2,0,0,4,0,$,0,"ABBREV",0[][Sys_localindex('J'),1,Sys_localindex('I'),1,Sys_localindex('J'),1]W_actsi1..size(N_vars)*2624,304,148,1339321,39325,65535[1,2]SeriessTable(N_vars)(
424
)624,184,148,162,77,45,476,3402,349,265,690,459,0,MIDM52427,56425,65535[Sys_localindex('J'),Sys_localindex('I')]2,I,4,2,0,0,4,0,$,0,"ABBREV",0[][Sys_localindex('J'),1,Sys_localindex('I'),1,Sys_localindex('J'),1](a)Indexifyvar node:= selecttext(data_source,1,1)='2';
var N_indices:= Object_info_for_lap[Info='# explanation cols'];
N_Indices:= if node then size(a.columns)-1 else N_indices+proba;
index h:= if N_indices=0 then [] else a.columns[@a.columns=1..N_indices];
var c:= Object_info_for_lap[Info='observation name'];
c:= if c='' or c=0 or node then 'Observation' else c;
index j:= concat(h,[c,'result']);
index obs:= a.columns[@a.columns=(N_indices+1)..size(a.columns)];
index temp:= 1..size(a.rows)*size(obs);
var conv:= if j='result' then @obs+N_indices else @j;
a:= a[@.columns=conv];
a:= if @j=size(j)-1 then obs else a;
a:= concatrows(a, obs, a.rows, temp);
a:= if j='result' then
(var d:= a[j='result']; if evaluate(d)=null then d else evaluate(d)) else a;
index i:= Subset(a[j='result']<>null);
a[temp=i]72,424,148,122,745,11,476,650a(a)observiseif 1-proba then a else (
var node:= selecttext(data_source,1,1)='2';
var N_indices:= Object_info_for_lap[Info='# explanation cols'];
N_Indices:= if node then size(a.columns)-1 else N_indices;
index expl:= 1..N_indices;
var b:= jointext(a[@.columns=expl],expl,'+');
index cell:= unique(b, b.rows);
var c:= b[@.rows=cell];
b:= b=c;
b:= sum(cumulate(b,b.rows)*b,cell);
b:= if N_indices=0 then @a.rows else b;
index columns:= concat(['obs'],a.columns);
if columns='obs' then b else a[.columns=columns]
)72,400,148,122,94,57,476,447a(a)Cellulise{var b:= jointext(a.j,a.j,',');
b:= Textreplace(b, 'obs,','');
index h:= splittext(Textreplace(b, ',result',''),',');
a:= a[.j=h];}
a:= removecol(a);
var b:= if proba then a else @a.i;
index cell:= unique(b,b.i);
a:= a[.i=cell];72,448,148,122,724,488,476,324aReaderktluser3. Augta 2008 18:31jtue9. lokta 2008 14:01 48,24312,40,148,241,1,1,1,1,1,0,0,0,01,601,119,477,429,17Arial, 15(vident:text, seriesid:optional)Read meanReads the mean data about the vident variable from the Opasnet Base. Uses the run with runid as run.id if specified; otherwise uses the newest run of that variable.
PARAMETERS:
* Vident: the ident of the variable in the Opasnet Base.
* Runid: the id of the run from which the results will be brought. If omitted, the newest result will be brought.
Change
run to actif isnotspecified(seriesid) or istext(seriesid) then seriesid:= Newest_series(vident);
query( '
SELECT obj.ident, obj.name, obj.unit, cell.id as cell_id, mean, sd, n, act_id, comments, time, std.location, ind.ident AS iident, ind.name AS iiname, actobj.series_id
FROM obj
LEFT JOIN actobj ON obj.id = actobj.obj_id
LEFT JOIN act ON act.id = actobj.act_id
LEFT JOIN cell ON cell.actobj_id = actobj.id
LEFT JOIN loccell ON loccell.cell_id = cell.id
LEFT JOIN loc ON loccell.loc_id = loc.id
LEFT JOIN loc as std ON loc.std_id = std.id
LEFT JOIN obj as ind ON std.obj_id_i = ind.id
WHERE obj.ident = '&chr(39)&vident&chr(39)&'
AND actobj.series_id = '&chr(39)&seriesid&chr(39)
)56,80,148,122,585,25,516,58939325,65535,39321vident,seriesid(vident:text)Newest seriesThis function checks for the newest result (according to run_id) of the variable. The function is used if the user does not define the run_id as an optional parameter in functions Read_mean and Read_sample.
PARAMETERS:
* Vident: the Ident of the variable in the Opasnet Base.var a:= query('
SELECT actobj.series_id, var.ident
FROM obj AS var
LEFT JOIN actobj ON var.id = actobj.obj_id
LEFT JOIN act ON actobj.act_id = act.id
WHERE var.ident = "'&vident&'"
');
max(a[@.j=1],a.i)56,22,148,222,678,59,476,56639325,65535,39321vident(vident:text, seriesid:optional)Read sampleReads the sample data about the vident variable from the Opasnet Base. Uses the runident run if specified; otherwise uses the newest run of that variable.
PARAMETERS:
* Vident: the name of the variable in the Opasnet Base.
* Runid: the id of the run from which the results will be brought. If omitted, the newest result will be brought.
chenge
run to act
add restextif isnotspecified(seriesid) or istext(seriesid) then seriesid:= Newest_series(vident);
query( '
SELECT obj.id AS obj_id, obj.ident, obj.unit, ind.ident as iident, cell.id AS cell_id, location, mean, n, obs, result, restext
FROM obj
LEFT JOIN actobj ON actobj.obj_id = obj.id
LEFT JOIN act ON actobj.act_id = act.id
LEFT JOIN cell ON cell.actobj_id = actobj.id
LEFT JOIN loccell ON loccell.cell_id = cell.id
LEFT JOIN loc ON loccell.loc_id = loc.id
LEFT JOIN obj as ind ON loc.obj_id_i = ind.id
LEFT JOIN res ON res.cell_id = cell.id
WHERE obj.ident = '&chr(39)&vident&chr(39)&'
AND actobj.series_id = '&chr(39)&seriesid&chr(39)
)56,112,148,222,55,35,516,61239325,65535,39321vident,seriesidEnter variable Ident'Op_en1912'168,83,148,27[Formnode Enter_variable1]52425,39321,65535Enter variable0288,24,1176,131,0,0,1,0,0,0,170,0,152425,39321,65535Enter_variableNewest seriesNewest_series(Enter_variable)288,61,148,222,200,56,416,303,0,MIDM[Sys_localindex('J'),Sys_localindex('I')]Var inforead_mean(Enter_variable)288,116,148,122,28,65,1144,438,0,MIDM[Sys_localindex('J'),Sys_localindex('I')](a,b,x)MakeindThe input table a must have a structure that is also used as input for MDTable function. The function removes one column with location information and makes a dimension (index) with the locations in the column. Inde is the (local) index that will be added. Note that unlike MDTable function, this can use local indices in the output.index inde / slice(b.m, x) := b[.n = unique(b[@.m = x], b.n), @b.m = x];
a:= if inde = a[@.m=1] then a else 0;
index m:= slice(a.m,(2..size(a.m)));
a:= a[.m=m]56,192,148,122,61,72,476,454a,b,x(a)Get cell_idMakes a multi-dimensional array with the same structure as the original variable that was stored into the Opasnet Base. The contents of the array are the cell_ids of the variable. The input parameter must be a 2D table with the structure that comes from the Read_mean function.
1) Slices the necessary columns from the input table and converts that to a 2D table that has the same structure as is used for input to the function MDTable.
2) Defines the local indices, and changes a location column to a dimension one at a time until all columns have been changed.
NOTE! There is a problem that if there are two or more cells with the exactly same locations, only the one with a largest cell_id will be taken.index k:= ['iident','location','cell_id', 'act_id'];
a:= a[.j=k];
a:= if a.k = 'iident' then textreplace(a, ' ', '_', true) else a;
index L:= a[@k=1]&'+'&textify(a[@k=3]);
index m:= concat(a[.i=unique(a[@k=1],a.i), @k=1],['act_id', 'result']);
index n:= a[.i=unique(a[@k=3],a.i), @k=3];
a:= a[@.i=@L];
var c:= a[L=(m)&'+'&textify(n), @k=4, @m=1];
a:= a[L=(m)&'+'&textify(n), @k=2];
a:= if m='result' then n else a;
a:= if m='act_id' then c else a;
var b:= a;
var x:= 1;
a:= while x< size(b.m) do (
a:= makeind(a,b,x);
x:= x+1;
a);
a:= max(a[@.m=1], a.n);
if size(a.act_id)=1 then a[@.act_id = 1] else a56,168,148,132,160,51,476,628aVar meanget_mean(Enter_variable)288,140,148,122,835,77,420,564,0,MIDM[Sys_localindex('ACT_ID'),Sys_localindex('MONTH')]2,I,4,2,0,0,4,0,$,0,"ABBREV",0[Sys_localindex('M'),1,Sys_localindex('N'),1,Sys_localindex('ACTION'),1](vident:text, runident:optional)Get meanGives the mean result of a (multidimensional) variable stored in the Opasnet Base. The procedure is simple because it utilises the variable structure (with res_ids) derived by the get_res_id function.var a:= read_mean(vident, runident);
index o:= a[.j='cell_id'];
index j:= ['mean','sd'];
var output:= a[@.i=@o, .j = j];
a:= Get_cell_id(a);
{output[o=a]}56,216,148,122,114,117,476,428vident,runident(vident:text, runident:optional)Get sampleGives the sample result of a (multidimensional) variable stored in the Opasnet Base. The procedure is simple because it utilises the variable structure (with res_ids) derived by the get_res_id function.
Note that if the Analytica samplesize is smaller than the samplesize stored in the Opasnet Base, the extra samples will be discarded. If the samplesize is larger, the remaining rows will be null.
1) Brings the data into the right structure.
2) Chooses whether the actual result is numerical (in the Result column) or text (in the Description column).var a:= read_sample(vident, runident);
var b:= textify(Get_cell_id(read_mean(vident,runident)));
index k:= textify(a[.j='cell_id'])&'+'&textify(a[.j='obs']);
index runn:= min(a[.j='obs'],a.i)..max(a[.j='obs'],a.i);
a:= if a[.j='restext'] = '' then a[.j='result'] else a[.j='restext'];
a:= a[@.i=@k];
a:= a[k=b&'+'&runn];
a:= if max(runn)=0 then a[@runn=1] else a[@runn=@run];56,240,148,122,613,48,476,556vident,runidentVar sampleget_sample(Enter_variable)288,164,148,122,86,111,476,2242,18,155,646,307,0,MEAN[Sys_localindex('OP_EN1899'),Sys_localindex('SALMON')][Sys_localindex('OP_EN1898'),1,Sys_localindex('YEAR'),1,Sys_localindex('SALMON'),1,Sys_localindex('OP_EN1899'),1]Var run infoDescribes the runs of the defined variable. This should be made a function.var_run_info(Enter_variable)288,92,148,122,41,152,1235,369,0,MIDM[Sys_localindex('J'),Sys_localindex('I')](vident:text)Var run infoThis function checks for the newest result (according to run_id) of the variable. The function is used if the user does not define the run_id as an optional parameter in functions Read_mean and Read_sample.
PARAMETERS:
* Vident: the Ident of the variable in the Opasnet Base.
Change:
objinfo to act
run to act
add objactquery( '
SELECT obj.id AS ovj_id, obj.ident, obj.name, obj.unit, actobj.series_id, actobj.act_id, comments, act.time, act.who
FROM obj
LEFT JOIN actobj ON obj.id = actobj.obj_id
LEFT JOIN act ON act.id = actobj.act_id
WHERE obj.ident = '&chr(39)&vident&chr(39)&'
')56,56,148,132,182,31,476,56639325,65535,39321videntUse these functions to retireve data from the Opasnet Base:
* Newest_series: finds the newest upload of the object.
* Obj_act_info: Finds the action information of the object.
* Read_mean: Reads the means of each cell.
* Get_mean: Makes read_mean table into an array.
* Read_sample: Reads the whole sample.
* Get_sample: Makes read_sample table into a probabilistic array.280,294,-1168,110(a:text)QueryPerforms a query and results the standard table with columns .j and rows .i.Lap;
index i:= DBquery(Odbc,a);
index j:= dblabels(i);
dbtable(i,j)56,144,148,132,100,154,476,56639325,65535,39321aWikisNames of different wikis used.Table(Self)(
'Op_en','Op_fi','Heande','En','Fit','Erac','Beneris','Intarese','Piltti','Kantiva','Bioher','Heimtsa')[1,2,3,4,5,8,9,10,11,13,14,15]184,168,148,1665535,52427,65534[Self](a)Textifyif a = null then '' else a&''72,376,148,122,309,205,559,372a2,F,4,14,0,0,4,0,$,0,"ABBREV",0(a; file:texttype)Tablefya:= '"'&a&'"';
a:= jointext(a,a.j,';');
Writetextfile('c:\temp\'&file, a)72,352,148,132,44,303,476,22465535,45873,39321a,file2,F,4,14,0,0,4,0,$,0,"ABBREV",0Concatenation UDFsThis library contains functions to make various instances of concatenation more convenient. Concat3 thru Concat10 are generalizations of the built-in Concat function which concatenate from 3 to 10 arrays in a single call (while the built-in Concat concatenates two arrays). ConcatRows concatenates all the rows of a single array.David Kendall & Lonnie ChrismanMon, Jan 26, 2004 8:49 AMLonnieWed, Sep 05, 2007 3:23 PM48,24488,40,168,201,0,0,1,1,1,0,0,0,01,50,200,488,454,23(A1, A2, A3: ArrayType; I1, I2, I3, J: IndexType )Concat3Concatenates three arrays, A1, A2, and A3. I1, I2, and I3 are the indexes that are joined; J is the index of the new array; J usually is the concatenation of I1, I2, and I3Index I12 := Concat(I1,I2);
Concat( Concat( A1,A2,I1,I2,I12 ), A3, I12, I3, J )88,64,148,262,56,56,986,596A1,A2,A3,I1,I2,I3,J(A1, A2, A3, A4: ArrayType; I1, I2, I3, I4, J: IndexType )Concat4Concatenates four arrays, A1, A2, A3, and A4. I1, I2, I3, and I4 are the indexes that are joined; J is the index of the new array; J usually is the concatenation of I1, I2, I3, and I4.Index I12 := Concat(I1,I2);
Index I123:= Concat(I12, I3);
Concat(
Concat(
Concat( A1,A2,I1,I2,I12 ),
A3, I12, I3, I123),
A4, I123, I4, J);
192,64,148,242,30,30,986,596A1,A2,A3,A4,I1,I2,I3,I4,J0(A1, A2, A3, A4, A5, A6, A7, A8, A9: ArrayType; I1, I2, I3, I4, I5, I6, I7, I8, I9, J: IndexType)Concat9Concatenates nine arrays, A1, ..., A9. I1, ..., I9 are the indexes joined; J is the index of the new array; J usually is the concatenation of I1, ..., I9.Index I12 := Concat(I1,I2);
Index I123 := Concat(I12, I3);
Index I1234 := Concat(I123, I4);
Index I12345 := Concat(I1234, I5);
Index I123456 := Concat(I12345, I6);
Index I1234567 := Concat(I123456, I7);
Index I12345678 := Concat(I1234567, I8);
Concat(
Concat(
Concat(
Concat(
Concat(
Concat(
Concat(
Concat( A1,A2,I1,I2,I12 ),
A3, I12, I3, I123),
A4, I123, I4, I1234),
A5, I1234, I5, I12345),
A6, I12345, I6, I123456),
A7, I123456, I7, I1234567),
A8, I1234567, I8, I12345678),
A9, I12345678, I9, J);88,232,148,242,27,120,469,638A1,A2,A3,A4,A5,A6,A7,A8,A9,I1,I2,I3,I4,I5,I6,I7,I8,I9,J0(A1, A2, A3, A4, A5: ArrayType; I1, I2, I3, I4, I5, J: IndexType )Concat5Concatenates five arrays, A1, ..., A5. I1, ..., I5 are the indexes joined; J is the index of the new array; J usually is the concatenation of I1, ..., I5.Index I12 := Concat(I1,I2);
Index I123:= Concat(I12, I3);
Index I1234 := Concat(I123, I4);
Concat(
Concat(
Concat(
Concat( A1,A2,I1,I2,I12 ),
A3, I12, I3, I123),
A4, I123, I4, I1234),
A5, I1234, I5, J);88,120,148,242,160,160,986,596A1,A2,A3,A4,A5,I1,I2,I3,I4,I5,J(A1, A2, A3, A4, A5, A6: ArrayType; I1, I2, I3, I4, I5, I6, J: IndexType )Concat6Concatenates six arrays, A1, ..., A6. I1, ..., I6 are the indexes joined; J is the index of the new array; J usually is the concatenation of I1, ..., I6.Index I12 := Concat(I1,I2);
Index I123:= Concat(I12, I3);
Index I1234 := Concat(I123, I4);
Index I12345 := Concat(I1234, I5);
Concat(
Concat(
Concat(
Concat(
Concat( A1,A2,I1,I2,I12 ),
A3, I12, I3, I123),
A4, I123, I4, I1234),
A5, I1234, I5, I12345),
A6, I12345, I6, J);192,120,148,242,644,94,602,712A1,A2,A3,A4,A5,A6,I1,I2,I3,I4,I5,I6,J0(A1, A2, A3, A4, A5, A6, A7: ArrayType; I1, I2, I3, I4, I5, I6, I7, J: IndexType )Concat7Concatenates seven arrays, A1, ..., A7. I1, ..., I7 are the indexes joined; J is the index of the new array; J usually is the concatenation of I1, ..., I7.Index I12 := Concat(I1,I2);
Index I123:= Concat(I12, I3);
Index I1234 := Concat(I123, I4);
Index I12345 := Concat(I1234, I5);
Index I123456 := Concat(I12345, I6);
Concat(
Concat(
Concat(
Concat(
Concat(
Concat( A1,A2,I1,I2,I12 ),
A3, I12, I3, I123),
A4, I123, I4, I1234),
A5, I1234, I5, I12345),
A6, I12345, I6, I123456),
A7, I123456, I7, J);88,176,148,242,580,98,551,565A1,A2,A3,A4,A5,A6,A7,I1,I2,I3,I4,I5,I6,I7,J(A1, A2, A3, A4, A5, A6, A7, A8: ArrayType; I1, I2, I3, I4, I5, I6, I7, I8, J: IndexType )Concat8Concatenates eight arrays, A1, ..., A8. I1, ..., I8 are the indexes joined; J is the index of the new array; J usually is the concatenation of I1, ..., I8.Index I12 := Concat(I1,I2);
Index I123:= Concat(I12, I3);
Index I1234 := Concat(I123, I4);
Index I12345 := Concat(I1234, I5);
Index I123456 := Concat(I12345, I6);
Index I1234567 := Concat(I123456, I7);
Concat(
Concat(
Concat(
Concat(
Concat(
Concat(
Concat( A1,A2,I1,I2,I12 ),
A3, I12, I3, I123),
A4, I123, I4, I1234),
A5, I1234, I5, I12345),
A6, I12345, I6, I123456),
A7, I123456, I7, I1234567),
A8, I1234567, I8, J);192,176,148,242,12,98,561,737A1,A2,A3,A4,A5,A6,A7,A8,I1,I2,I3,I4,I5,I6,I7,I8,J0(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10: ArrayType; I1, I2, I3, I4, I5, I6, I7, I8, I9, I10, J: IndexType)Concat10Concatenates ten arrays, A1, ..., A10. I1, ..., I10 are the indexes joined; J is the index of the new array; J usually is the concatenation of I1, ..., I10.Index I12 := Concat(I1,I2);
Index I123 := Concat(I12, I3);
Index I1234 := Concat(I123, I4);
Index I12345 := Concat(I1234, I5);
Index I123456 := Concat(I12345, I6);
Index I1234567 := Concat(I123456, I7);
Index I12345678 := Concat(I1234567, I8);
Index I123456789 := Concat(I12345678, I9);
Concat(
Concat(
Concat(
Concat(
Concat(
Concat(
Concat(
Concat(
Concat( A1,A2,I1,I2,I12 ),
A3, I12, I3, I123),
A4, I123, I4, I1234),
A5, I1234, I5, I12345),
A6, I12345, I6, I123456),
A7, I123456, I7, I1234567),
A8, I1234567, I8, I12345678),
A9, I12345678, I9, I123456789),
A10, I123456789, I10, J);192,232,148,242,542,93,632,744A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,I1,I2,I3,I4,I5,I6,I7,I8,I9,I10,J0(A : ArrayType ; RowIndex,ColIndex,ResultIndex : IndexType)ConcatRows (A,I,J,K)Takes an array, A indexed by RowIndex & ColIndex, and concatenates each row, henceforth flattening the array by one dimension. The result is indexed by ResultIndex, which must be an index with size(RowIndex) * size(ColIndex) elements.index L := [ identifier of RowIndex, identifier of ColIndex, "val"];
slice(Mdarraytotable(A,ResultIndex,L),L,3)320,64,164,242,499,85,478,348A,RowIndex,ColIndex,ResultIndexODBC LibraryLonnieThu, Sep 11, 1997 2:15 PMLonnieTue, Feb 05, 2008 10:03 AM48,24496,96,152,201,1,1,1,1,1,0,0,0,01,20,272,499,462,17Arial, 13(A:ArrayType;I:IndexType;L:IndexType;row:IndexType;dbTableName)InsertRecSqlGenerates the SQL "INSERT INTO" statement for one line of table A. A is a 2-D table indexed by rows I and columns L. L's domain serves as the column names in the database table. dbTableName is the name of the table in the database. The result begins with two semi-colons, since it will be used with an SQL statement preceeding it.
29.8.2008 Jouni Tuomisto
I added the parameter IGNORE because it ignores rows that would cause duplicate-key violations. This way, there is no need to check for e.g. existing locations of new indices.
6.1.2009 Jouni Tuomisto
I changed the A[I=row] to A[@I=@row] because the original function does not work correctly, if there are non-unique rows in the index.(';;INSERT IGNORE INTO ' & dbTableName & '(' & JoinText(L,L,',') & ') VALUES (' & Vallist(A[@I=@row],L)) & ') '184,32,152,242,591,203,487,469A,I,L,row,dbTableName(V:ArrayType;I:IndexType)ValListTakes a list of values, and returns a string which the concatenation of each value, separated by commas, and with each value quoted.JoinText( '''' & V & '''', I, ',')72,32,052,242,642,360,476,224V,I1,F,4,14,0,0(Tabl:ArrayType;RowIndex:IndexType;LabelIndex:IndexType;dbTableName)WriteTableSql(Table,Rows,Labels,dbTableName)Returns the SQL that will write the table to the database table.
This can be used as the second argument to DBWrite.
This SQL statement replaces the entire contents of an existing table with the new data.'DELETE FROM '& Dbtablename & JoinText(Insertrecsql(Tabl, Rowindex, Labelindex, Rowindex, Dbtablename),RowIndex)328,32,188,242,728,341,510,476Tabl,RowIndex,LabelIndex,dbTableName(Tabl:ArrayType;RowIndex:IndexType;LabelIndex:IndexType;dbTableName)AppendTableSql(Table,Rows,Labels,dbTableName)Returns the SQL that will write the table to the database table.
This can be used as the second argument to DBWrite.
This SQL statement replaces the entire contents of an existing table with the new data.JoinText(Insertrecsql(Tabl, Rowindex, Labelindex, Rowindex, Dbtablename),RowIndex)328,88,188,242,559,127,510,476Tabl,RowIndex,LabelIndex,dbTableNameTablesList of such tables in Opasnet Base that are being written to by this module.['act','actobj','cell','obj','loc','loccell','obj','res']296,216,148,122,396,363,377,227,0,MIDMCardinalsThe largest id values for the selected Opasnet Base tables.for x[]:= table1 do (
var a:= query('SELECT MAX(id) AS id FROM '&x&' ');
max(max(a,a.i),a.j))296,192,148,122,634,394,476,3322,193,270,416,303,0,MIDM2,70,351,229,303,0,MIDM39325,65535,393212,I,4,2,0,0,4,0,$,0,"ABBREV",0(in, table; cond:texttype)Findidindex L:= in[.i=unique(in, in.i)];
var a:= if (L&' ') = (table[.j=cond]&' ') then table[.j='id'] else 0;
a:= textify(sum(a, table.i));
a[.L=in]72,280,148,122,636,101,494,519in,table,cond(var, table)Writeif size(var)>0 then dbwrite((if platform = 'Lumina AWP' then 'Driver={MySQL ODBC 3.51 Driver};Server=193.167.179.97' else 'Driver={MySQL ODBC 5.1 Driver};Server=10.66.10.102')&';Database=opasnet_base;User=result_writer; Password='&writerpsswd&';Option=3'
, appendtablesql(var,var.i, var.j, table&' '))72,304,148,122,751,65,501,45765535,45873,39321var,tableOpasnet usernameThe username for Opasnet wiki'Add your username'72,176,148,221,1,1,1,1,1,0,0,0,02,102,90,476,398[Formnode Username1]52425,39321,65535Opasnet passwordThe user's password for Opasnet wiki.'Add password'72,232,148,221,1,1,1,1,1,0,0,0,02,102,90,476,520[Formnode Password1]52425,39321,65535ODBCvar a:= if platform='Lumina AWP' then 'Driver={MySQL ODBC 3.51 Driver};Server=193.167.179.97' else 'Driver={MySQL ODBC 5.1 Driver};Server=10.66.10.102';
a&';Database=opasnet_base;User=result_reader; Password=ora4ever;Option=3'184,136,148,121,1,0,1,1,1,0,,0,2,180,61,508,4202,56,66,918,303,0,MIDMLocLap;
query('
SELECT loc.*, ind.* FROM loc, obj as ind WHERE loc.obj_id_i = ind.id ')296,160,148,131,1,0,1,1,1,0,0,0,02,370,45,476,4452,43,42,1147,516,0,MIDM39325,65535,39321[Sys_localindex('J'),Sys_localindex('I')]2,I,4,2,0,0,4,0,$,0,"ABBREV",0ObjLap;
query('SELECT * FROM obj ')296,136,148,131,1,0,1,1,1,0,0,0,02,378,21,493,5012,218,87,977,421,0,MIDM39325,65535,39321[Sys_localindex('J'),Sys_localindex('I')][Self,1,Sys_localindex('I'),1,Sys_localindex('J'),1](var, table)Write1if size(var)>0 then appendtablesql(var,var.i, var.j, table&' ')72,328,148,132,284,58,476,224var,table'Add a password for the Base'184,200,052,121,1,1,1,1,1,0,0,0,02,163,375,476,224[Formnode Writerpsswd1]52425,39321,65535PlatformChoice(Self,2,False,1)72,136,148,12[Formnode Platform1]52425,39321,65535['Lumina AWP','THL computer']Object infosubtable(Object_info[Info=Info1_3_4, @n_vars=1])184,248,148,202,102,90,476,3732,244,392,402,256,0,MIDM2,599,363,416,303,0,MIDM[Formnode Object_info7, Formnode Object_info1, Formnode Object_info3]52425,39321,65535[N_vars,Info1_3_4][Self]['','','']Info['ident','name','unit','# explanation cols','observation name','probabilistic?']184,280,148,131,1,1,1,1,1,0,0,0,0Do nextThis is a temporary node that is ovewritten when Upload_data and Upload_results are being run.''296,352,148,16Replace data?Choice(Self,1,False)296,256,148,222,102,90,476,384[Formnode Replace_data_1]52425,39321,65535['Yes, replace previous data (if any)','No, there is previous data and I want to append']Enter anacode"index vehicle_type:= ['Bus','Minibus','Car d','Car g'];
var Car_maintenance:= Triangular( 0.03, 0.058, 0.086 );
var Fuel_price:=
(var a:= 0.95*triangular(0.8,1,1.2);
var b:= 1.22*triangular(0.8,1,1.2);
array(Vehicle_type,[a,a,a,b]));
var Fuel_consumption:=
(var a:= (8.7/100)*Triangular(0.75,1,1.25);
var b:= (5.7/100)*Triangular(0.75,1,1.25);
var c:= (8/100)*Triangular(0.5,1,1.5);
a:= array(Vehicle_type,[a,a,b,c]);
);
fuel_price*fuel_consumption+car_maintenance"496,280,148,24[Formnode Enter_anacode1]52425,39321,65535Enter anacode0736,432,1160,561,0,0,1,0,0,0,182,0,152425,39321,65535Enter_anacodeExample codeindex vehicle_type:= ['Bus','Minibus','Car d','Car g'];
var Car_maintenance:= Triangular( 0.03, 0.058, 0.086 );
var Fuel_price:=
(var a:= 0.95*triangular(0.8,1,1.2);
var b:= 1.22*triangular(0.8,1,1.2);
array(Vehicle_type,[a,a,a,b]));
var Fuel_consumption:=
(var a:= (8.7/100)*Triangular(0.75,1,1.25);
var b:= (5.7/100)*Triangular(0.75,1,1.25);
var c:= (8/100)*Triangular(0.5,1,1.5);
a:= array(Vehicle_type,[a,a,b,c]);
);
fuel_price*fuel_consumption+car_maintenance496,216,148,24Code nodeevaluate(Enter_anacode)496,336,148,162,104,114,416,303,0,SAMP[Undefined,Sys_localindex('VEHICLE_TYPE'),Undefined,Undefined,Undefined,1][1,0,0,0](a)Removecolvar b:= jointext(a.j,a.j,',');
b:= Textreplace(b, 'obs,','');
index j:= splittext(Textreplace(b, ',result',''),',');
a:= a[.j=j];
72,472,148,122,450,561,476,224aProvide data in the format you selected.264,172,-1256,121,0,0,1,0,1,0,,0,65535,65532,19661