Why can I not do this switch? - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Why can I not do this switch? (
/showthread.php?tid=176563)
Why can I not do this switch? -
Memoryz - 13.09.2010
pawn Код:
switch(idx)
{
case 0: file2 = fopen("CRP_Scriptfiles/Businesses/businesses.cfg", io_write);
else: fopen("CRP_Scriptfiles/Businesses/businesses.cfg", io_append);
}
I get these errors:
Quote:
(15862) : error 002: only a single statement (or expression) can follow each "case"
(15862) : error 029: invalid expression, assumed zero
|
Line 15862 is the "else:" line.
What is another way to do "else"..
I do not want to use the elseif, etc, I would like to use the switch system.
Re: Why can I not do this switch? -
[XST]O_x - 13.09.2010
When trying to detect failed switch case statements,we use 'default'.
pawn Код:
case 0: file2 = fopen("CRP_Scriptfiles/Businesses/businesses.cfg", io_write);
default: fopen("CRP_Scriptfiles/Businesses/businesses.cfg", io_append);
Re: Why can I not do this switch? -
Memoryz - 13.09.2010
Quote:
Originally Posted by [XST]O_x
When trying to detect failed switch case statements,we use 'default'.
pawn Код:
case 0: file2 = fopen("CRP_Scriptfiles/Businesses/businesses.cfg", io_write); default: fopen("CRP_Scriptfiles/Businesses/businesses.cfg", io_append);
|
Perfect, thank-you.
Im so used to using ifs and else, but now im going to transfer everything to switches, a lot easier