need help in ternary operator - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: need help in ternary operator (
/showthread.php?tid=459649)
need help in ternary operator -
newbienoob - 24.08.2013
I'm not really good in TO so I'm not sure what could be the reason of this problem.
pawn Code:
(db_num_rows(Result)) ? ShowPlayerDialog(playerid, dlogin, DIALOG_STYLE_INPUT, ""horange"LOGIN", "test", "Login", "Quit")
: ShowPlayerDialog(playerid, dregister, DIALOG_STYLE_INPUT, ""horange"REGISTER", "test", "Register", "Quit");
Code:
warning 215: expression has no effect
Re : need help in ternary operator -
Naruto_Emilio - 24.08.2013
Youre using a long length how about strcat
Re: need help in ternary operator -
newbienoob - 24.08.2013
Nope. If I did this
pawn Code:
(a == b) ? c = d : c = e;
I'll still get the same warning.
Re : need help in ternary operator -
Naruto_Emilio - 24.08.2013
make them in format string
Re: need help in ternary operator -
newbienoob - 24.08.2013
Sorry, but I don't understand you. You mean, the dialog?
EDIT: Edited main post.
Re: need help in ternary operator -
Pottus - 24.08.2013
I don't see the point of using the ternary syntax for something like that just use if/else it makes absolutely no difference once it's compiled.
Re: need help in ternary operator -
newbienoob - 24.08.2013
pawn Code:
if(db_num_rows(result))
{
ShowPlayerDialog(.....);
}
else
{
ShowPlayerDialog(.....);
}
//Looks ugly
(db_num_rows(result)) ? ShowPlayerDialog(....) : ShowPlayerDialog(....);
//Looks simple and clean!
Re: need help in ternary operator -
RajatPawar - 24.08.2013
Quote:
Originally Posted by newbienoob
Nope. If I did this
pawn Code:
(a == b) ? c = d : c = e;
I'll still get the same warning.
|
That would be something like
I'll edit this for the main post
Re: need help in ternary operator -
Misiur - 24.08.2013
Quote:
Originally Posted by newbienoob
pawn Code:
if(db_num_rows(result)) { ShowPlayerDialog(.....); } else { ShowPlayerDialog(.....); } //Looks ugly
(db_num_rows(result)) ? ShowPlayerDialog(....) : ShowPlayerDialog(....); //Looks simple and clean!
|
Ternary operators are useful in many, many cases, but they _don't_ make your code easier to read.