Hello,
I want to call a table of data from de *.prb and write the rows as columns so I wrote this code:
*if(strcmp(GenData(Mixture_model),"One_NON-Cohesive_layer")==0)
*set var INS(int)=GenData(Sediment_classes,int)
*set var PASO=5
*for(i=1;i<=INS(int);i=i+PASO)
*GenData(Sediment_classes,*Operation(i+1),real)
*GenData(Sediment_classes,*Operation(i+2),real)
*GenData(Sediment_classes,*Operation(i+3),real)
*GenData(Sediment_classes,*Operation(i+4),real)
*end for
end table
It writes each row as a column but the problem is that this code writes each row data below the previous row. I want to write them side by side. I don't know if anybody could tell me what to modify.
Greetings and thank you very much for the help.
CALL TABLE FROM *.prb
Moderator: GiD Team
Re: CALL TABLE FROM *.prb
I am not sure if I am answering your question,
but in the .bas template fiel if do you want to avoid printing a endline \n you can use the command
*\
e.g.
this:
*GenData(Sediment_classes,*Operation(i+1),real) *GenData(Sediment_classes,*Operation(i+2),real)
is equivalent to this:
*GenData(Sediment_classes,*Operation(i+1),real) *\
*GenData(Sediment_classes,*Operation(i+2),real)
Probably using *\ you will be able to write your array data as you want
but in the .bas template fiel if do you want to avoid printing a endline \n you can use the command
*\
e.g.
this:
*GenData(Sediment_classes,*Operation(i+1),real) *GenData(Sediment_classes,*Operation(i+2),real)
is equivalent to this:
*GenData(Sediment_classes,*Operation(i+1),real) *\
*GenData(Sediment_classes,*Operation(i+2),real)
Probably using *\ you will be able to write your array data as you want
Re: CALL TABLE FROM *.prb
No, that isn't my problem, I'll try to be more clear:
In the interface the user inserts a table of data e.g. this:
1 , 0.5 , 0.6 , 8, 25
2 , 4 , 8 , 10 , 0.1
So, when I use the *bas file to write the .dat I call that table from the problem type with this code:
*set var INS(int)=GenData(Sediment_classes,int)
*set var PASO=5
*for(i=1;i<=INS(int);i=i+PASO)
*GenData(Sediment_classes,*Operation(i+1),real)
*GenData(Sediment_classes,*Operation(i+2),real)
*GenData(Sediment_classes,*Operation(i+3),real)
*GenData(Sediment_classes,*Operation(i+4),real)
*end for
*end for
end table
Then I obtain in the .dat file:
0.5
0.6
8
25
4
8
10
0.1
But what I want is:
0.5 4
0.6 8
8 10
25 0.1
That's my problem, I need each row introduced in the interface as a column in the *.dat file; maybe adding another variable that refeers to rows could be a solution??
Thanks for help!
In the interface the user inserts a table of data e.g. this:
1 , 0.5 , 0.6 , 8, 25
2 , 4 , 8 , 10 , 0.1
So, when I use the *bas file to write the .dat I call that table from the problem type with this code:
*set var INS(int)=GenData(Sediment_classes,int)
*set var PASO=5
*for(i=1;i<=INS(int);i=i+PASO)
*GenData(Sediment_classes,*Operation(i+1),real)
*GenData(Sediment_classes,*Operation(i+2),real)
*GenData(Sediment_classes,*Operation(i+3),real)
*GenData(Sediment_classes,*Operation(i+4),real)
*end for
*end for
end table
Then I obtain in the .dat file:
0.5
0.6
8
25
4
8
10
0.1
But what I want is:
0.5 4
0.6 8
8 10
25 0.1
That's my problem, I need each row introduced in the interface as a column in the *.dat file; maybe adding another variable that refeers to rows could be a solution??
Thanks for help!
Re: CALL TABLE FROM *.prb
Ok, I found the way:
*set var nrows=operation(GenData(Sediment_classes,INT)/5)
number of cols=5, number of rows=*nrows
*end
*for(i=2;i<=5;i=i+1)
*for(j=0;j<=(nrows-1);j=j+1)
*set var pos=operation(j*5+i)
*GenData(Sediment_classes,*pos,real) *\
*end for
*end for
Thank you anyway
*set var nrows=operation(GenData(Sediment_classes,INT)/5)
number of cols=5, number of rows=*nrows
*end
*for(i=2;i<=5;i=i+1)
*for(j=0;j<=(nrows-1);j=j+1)
*set var pos=operation(j*5+i)
*GenData(Sediment_classes,*pos,real) *\
*end for
*end for
Thank you anyway