Page 1 of 1

Problem with *if statement

Posted: Mon Apr 13, 2015 11:50 pm
by wfmoralesp
Hi,

I'm trying to use an IF statement in my .bas file as:

*loop intervals
check_mat=*IntvData(1)
*if(IntvData(1)!=0)
*IntvData(1),*IntvData(2),*IntvData(3)
*Set Cond Structure *nodes
*if(CondNumEntities>0)
*loop *nodes *OnlyInCond
*if(strcmp(*cond(1),"Liner")==0)
*cond(2),1,*NodesNum,*cond(4),*cond(3)
*endif
*end nodes
*endif
*endif
*end intervals

with a condition:

NUMBER:30 CONDITION: Structure
CONDTYPE: over lines
CONDMESHTYPE: over nodes
QUESTION: Structural_element#CB#(Liner,Beam,Pile,Rockbolt)
VALUE:Liner
QUESTION: Sequential_ID
VALUE:1
QUESTION: Property_ID
VALUE:1
QUESTION: Segments
VALUE:10
END CONDITION

and:

INTERVAL DATA
QUESTION: Material_ID_to_modify
VALUE:1
QUESTION: Material_ID_to_apply
VALUE:1
QUESTION: Sequential_ID
VALUE:1
END INTERVAL DATA

But it keeps telling me "Error into an *if expression".

Why is it telling me this or what am I doing wrong? Thx so much in advance.

cheers,

Ferney

Re: Problem with *if statement

Posted: Tue Apr 14, 2015 11:16 am
by escolano
I think that the error is in the line
*if(strcmp(*cond(1),"Liner")==0)
try without the '*' inside conditionals
*if(strcmp(cond(1),"Liner")==0)

other comments,
I recommend you to use field names instead of field index when possible, it is easier to be mantained and more user readable,
e.g.
instead of
*IntvData(1),*IntvData(2),*IntvData(3)
use
*IntvData(Material_ID_to_modify),*IntvData(Material_ID_to_apply),*IntvData(Sequential_ID)


and
*if(CondNumEntities>0)
*endif
is unneded, the *loop *nodes *OnlyInCond will be done only over the entities with the condition (none if CondNumEntities==0)

Re: Problem with *if statement

Posted: Tue Apr 14, 2015 3:04 pm
by wfmoralesp
Hi,

your suggestion of using (*if(strcmp(cond(1),"Liner")==0)) worked. However, the another IF statement (*if(IntvData(1)!=0)) continues showing the error message. I even tried your suggestion of using the field's name, i.e. *if(IntvData(Material_ID_to_modify)!=0), but nothing :(, any other ideas?

Thx for your support,

Ferney

Re: Problem with *if statement

Posted: Tue Apr 14, 2015 3:15 pm
by escolano
Instead
*if(IntvData(1)!=0)
you can simply use
*if(IntvData(1))
(the condition is true if is not zero, like all languages: C/C++,...)
and if the error persists try to splicitly say that this field must be considered as an integer (in general all dada fields are strings)
to do this could add an extra argument ,int

*if(IntvData(1,int))

Re: Problem with *if statement

Posted: Tue Apr 14, 2015 3:34 pm
by wfmoralesp
Thx so much for your help, your idea of explicitly expressing field as integer did the work, at the end I have it working as: *if(IntvData(1,int))