CALL TABLE FROM *.prb

Moderator: GiD Team

c.souto
Posts: 7
Joined: Thu Oct 17, 2019 5:11 pm

CALL TABLE FROM *.prb

Postby c.souto » Fri Jan 03, 2020 12:26 am

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. :D
User avatar
escolano
Posts: 1605
Joined: Thu Sep 18, 2014 3:31 pm

Re: CALL TABLE FROM *.prb

Postby escolano » Tue Jan 07, 2020 9:59 pm

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
c.souto
Posts: 7
Joined: Thu Oct 17, 2019 5:11 pm

Re: CALL TABLE FROM *.prb

Postby c.souto » Thu Jan 16, 2020 5:09 pm

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!
c.souto
Posts: 7
Joined: Thu Oct 17, 2019 5:11 pm

Re: CALL TABLE FROM *.prb

Postby c.souto » Thu Jan 16, 2020 6:51 pm

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 :D :D

Return to “Customization”

Who is online

Users browsing this forum: No registered users and 0 guests