Gamestudio Links
Zorro Links
Newest Posts
ZorroGPT
by TipmyPip. 03/05/26 02:58
zorro with ccxt?
by opm. 03/03/26 03:17
WFO Training with parallel cores Zorro64
by Martin_HH. 02/26/26 16:03
Zorro version 3.0 prerelease!
by TipmyPip. 02/25/26 16:38
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
1 registered members (Quad), 4,945 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
the1, alx, ApprenticeInMuc, PatrickH90, USER0328
19200 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
New conditional statments #248892
01/29/09 21:02
01/29/09 21:02
Joined: Jan 2008
Posts: 1,580
Blade280891 Offline OP
Serious User
Blade280891  Offline OP
Serious User

Joined: Jan 2008
Posts: 1,580
Is it possible to add things like php has for example

if(conditions)
{
do something
}

can be

if(conditions)
do something

and this

if(conditions)
{
var = do something
}
else if(conditions)
{
var do something
}

could be

var = (conditions ? true : false);


My Avatar Randomness V2

"Someone get me to the doctor, and someone call the nurse
And someone buy me roses, and someone burned the church"
Re: New conditional statments [Re: Blade280891] #248893
01/29/09 21:06
01/29/09 21:06
Joined: Oct 2007
Posts: 5,211
İstanbul, Turkey
Quad Online
Senior Expert
Quad  Online
Senior Expert

Joined: Oct 2007
Posts: 5,211
İstanbul, Turkey
if(conditions)
do something
^
you can use this, if there is only one statement after the if.(one ";" )
this is same in php. how would it supposed to understand what is condition dependant or not without {}'s when there are more than one statements/instructions.

(conditions ? true : false)-> yeah miss that from PHP, but i guess this is not necessary


3333333333
Re: New conditional statments [Re: Quad] #248894
01/29/09 21:09
01/29/09 21:09
Joined: Jan 2008
Posts: 1,580
Blade280891 Offline OP
Serious User
Blade280891  Offline OP
Serious User

Joined: Jan 2008
Posts: 1,580
Well in php you can do things like

if(condition)
echo "true";
elseif(condition)
echo "maybe";
else
echo "true";

Last edited by Blade280891; 01/29/09 21:15.

My Avatar Randomness V2

"Someone get me to the doctor, and someone call the nurse
And someone buy me roses, and someone burned the church"
Re: New conditional statments [Re: Blade280891] #248896
01/29/09 21:17
01/29/09 21:17
Joined: Oct 2007
Posts: 5,211
İstanbul, Turkey
Quad Online
Senior Expert
Quad  Online
Senior Expert

Joined: Oct 2007
Posts: 5,211
İstanbul, Turkey
you can do it in lite-c too. as in your example, there is only 1 statemens(echo ... wink after ifs end elses.

edit:
this will work:
Php Code:


<?php
$a = true;
$b = true;
if($a)
echo "a";
elseif($b)
echo "b";
else
echo "-";
?>




this will complain about elseif and which if it stands for:
Php Code:


<?php
$a = true;
$b = true;
if($a)
echo "a";
echo "2nd statement";
elseif($b)
echo "b";
else
echo "-";
?>




this will echo "2nd stamaent" but not "a"
Php Code:


<?php
$a = false;
if($a)
echo "a";
echo "2nd statement";
?>




for lite-c:
this wont print "a" but will print "2nd statement", if you set a to 1, both will be printed.
Code:
var a =0;
void main(){
	if(a)
	printf("a");
	
	printf("2nd statement");
}



Last edited by Quadraxas; 01/29/09 21:24.

3333333333
Re: New conditional statments [Re: Quad] #248927
01/30/09 06:54
01/30/09 06:54
Joined: Jul 2000
Posts: 28,077
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,077
Frankfurt
PHP "elseif" is the same as C/C++ "else if".

Re: New conditional statments [Re: jcl] #248969
01/30/09 14:33
01/30/09 14:33
Joined: Jan 2008
Posts: 1,580
Blade280891 Offline OP
Serious User
Blade280891  Offline OP
Serious User

Joined: Jan 2008
Posts: 1,580
Yeah quad i know that about php wink , JCl what about the other one

var = (condition ? true : false)


My Avatar Randomness V2

"Someone get me to the doctor, and someone call the nurse
And someone buy me roses, and someone burned the church"
Re: New conditional statments [Re: Blade280891] #249055
01/31/09 11:33
01/31/09 11:33
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
This trinary operator is listed on the forecast page.

Re: New conditional statments [Re: HeelX] #249060
01/31/09 12:07
01/31/09 12:07
Joined: Jan 2008
Posts: 1,580
Blade280891 Offline OP
Serious User
Blade280891  Offline OP
Serious User

Joined: Jan 2008
Posts: 1,580
ok but it is called ternary not trinary wink

Also JCL, when you implement it will it be like the current php one or the new php one (php 6), the new php one is like so

var = ($condition ?: true)//Does not requrie a false

//where as the current one does

More details here
http://www.php.net/~derick/meeting-notes.html#ifsetor-as-replacement-for-foo-isset-foo-foo-something-else


Last edited by Blade280891; 01/31/09 12:08.

My Avatar Randomness V2

"Someone get me to the doctor, and someone call the nurse
And someone buy me roses, and someone burned the church"
Re: New conditional statments [Re: Blade280891] #249064
01/31/09 12:23
01/31/09 12:23
Joined: Jan 2003
Posts: 4,615
Cambridge
Joey Offline
Expert
Joey  Offline
Expert

Joined: Jan 2003
Posts: 4,615
Cambridge
that is unnecessary. i don't understand you all talking about php which is badly-designed and by far not as powerful as c++ o.O. for the examples in your code, how about:

Code:
var = (bool)condition;
var = condition && true;


and for the examples in your link simply use the ternary operator. i don't think shortening this one seems necessary. an alternative is below.

Code:
var = condition ? foo : var;
condition && (var = foo);


rather request c++ features, such as:

Code:
while ( p = (file = open_file( (p && p->name) || foo ), file.seek(another), file.readline()) ) {}


the ,-operator would often give you the possibility to write more compact code.

Re: New conditional statments [Re: Joey] #249068
01/31/09 12:27
01/31/09 12:27
Joined: Jan 2008
Posts: 1,580
Blade280891 Offline OP
Serious User
Blade280891  Offline OP
Serious User

Joined: Jan 2008
Posts: 1,580
PHP is only badly designed for those who can't use it
wink
Please do not try and spin this thread off into a poitnless discussion when the feature has been added onto the forcast page

Edit: the true and false in my example was just to show where you would put the values, not has to be put so (bool) will not help if you want it to change the var to text or similar

Last edited by Blade280891; 01/31/09 12:32.

My Avatar Randomness V2

"Someone get me to the doctor, and someone call the nurse
And someone buy me roses, and someone burned the church"
Page 1 of 2 1 2

Moderated by  aztec, Spirit 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1