Cancel
Showing results for 
Search instead for 
Did you mean: 

is it possible to define some condition in a Variable to be used as Algorithm???

Builder
Builder

Hello,

 

in the attached model I Tried to use a Global Variable type String as a condition to turn the method more flexible.

example:

                       Global Variable in the main Frame:

                                 Variable_X:= "singleproc.full = true"

 

                       Condition inside the method:

                                 waituntil Variable_X prio 1;

                                 do something....

                                               

The attached model is not working. Is it possible or is there any other way to do what I want to do???                      

5 REPLIES

Re: is it possible to define some condition in a Variable to be used as Algorithm???

Legend
Legend

I have to say it's not clear in my mind what you're trying to do, if you explain maybe I will help you more.

Anyway, the method is not working because in your waituntil statement you need to compare something wiht something else. In your case, if you write

waituntil y = "singleproc.cont.finished = true" prio 1;

the method will work (even though this doesn't make sense to me).

 

Re: is it possible to define some condition in a Variable to be used as Algorithm???

Builder
Builder

y has the comparison

 

y = "singleproc.cont.finished = true"

 

waituntil y to do something means waituntil singleproc.cont.finished = true to proceed.

 

does it make sense?

is it possible to convert y (string) in algorithm?

Re: is it possible to define some condition in a Variable to be used as Algorithm???

Phenom
Phenom

you can wrap the individual code in a string and execute it through "execute(string)".

 

is
	x:integer;
do
	while x = 0 loop;
		waituntil singleproc.full prio 1;
		execute(var_x);
		singleproc.be.move(singleproc1);
	end;	
end;

 

where the string var_x  equals

 

is do waituntil singleproc.cont.finished and singleproc1.empty prio 1; end;

 

Re: is it possible to define some condition in a Variable to be used as Algorithm???

Legend
Legend

Ok, now I understand.
The execute method is a good idea, but be careful! In my model I have a lot of objects using this function and if you save your model while an execute method it's suspended, likely your model will crash when you re-open it or you will not able to continue the simulation anymore (I mean, you need to reset and play again, no chance to continue from the moment you saved the model).


Another way (very trick I have to say) which I found to bypass this problem, is using the method "Splitstring". In this way you can split your string in different parts, and using some conversion functions you can create a valid waituntil statement.

Re: is it possible to define some condition in a Variable to be used as Algorithm???

Builder
Builder

wow!!! it's a nice solution.

 

This way it's possible to develop customized objects with a large flexibility to cover the more diverse kind of application using the Dialog tool.

 

thanks very much!