Jump to content
Tom Next - Daytrading Community

Gibt es switch(true)... in MQL4?


kai700

Recommended Posts

 

Die Docu kannte ich. Und sie liest sich auch so, dass es nicht gehen dürfte:

 

"The constant expression can't contain variables or function calls. Expression of the switch operator must be of integer type."

Jetzt habe ich aber noch mal probiert und folgendes geht. Switch operator ist doch jetzt bool? Das es vorher nicht ging, lag an der Syntax. man muss die Variable jeweils in Hochkomma innerhalb der Klammer.

 

<code>

int a = 2;

int b = 3;

 

switch(true)

{

case ('a'=='b'):

Print("CASE A == B");

break;

case ('a'<='b'):

Print("CASE A <= B");

default:

Print("default");

break;

}

</code>

 

PS: Sorry, ich hab mir jetzt zum zweiten mal nen Wolf gesucht, wie die code-tags funktionieren. Ich finds nicht.

Gruss kai

Edited by kai700
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...