mtlgd 0 Posted July 23, 2007 I can't figure out how to structure script properly.<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">switch (Param1) do { Â Â case 0: Â Â { code; Â Â }; Â Â case 1: Â Â { code; Â Â }; Â Â }; This is an extract of code that I know works, taken from another script that was downloaded, however when I try to structure my scripting this way, I get the error "missing {". The code itself is good, I can pull it all up to one line and it executes perfectly, but then its six miles long and dificult to read. I've tried using several editors which all insert CRLF characters at the end of the line. however they also show those characters in the sample script also (unless its an editor shortcoming). Any suggestions? I found a discussion about editors and have tried most of them an they all seem to do it. This is the code, in its prefered structure. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">switch (_p2) do { Â Â case 32: Â Â { if ((MyVecX >= 0) and (MyVecX < 1) and (MyVecY <= 1 ) and (MyVecY > 0)) then {MyVecX = MyVecX + _mySin; MyVecY = MyVecY - _mySin}; if ((MyVecX > 0) and (MyVecX <= 1) and (MyVecY <= 0 ) and (MyVecY > -1)) then {MyVecX = MyVecX - _mySin; MyVecY = MyVecY - _mySin}; if ((MyVecX <= 0) and (MyVecX > -1) and (MyVecY >= -1 ) and (MyVecY < 0)) then {MyVecX = MyVecX - _mySin; MyVecY = MyVecY + _mySin}; if ((MyVecX >= -1) and (MyVecX < 0) and (MyVecY >= 0 ) and (MyVecY < 1)) then {MyVecX = MyVecX + _mySin; MyVecY = MyVecY + _mySin}; Â Â }; Â Â case 30: Â Â { if ((MyVecX > -1) and (MyVecX <= 0) and (MyVecY <= 1 ) and (MyVecY > 0)) then {MyVecX = MyVecX - _mySin; MyVecY = MyVecY - _mySin}; if ((MyVecX >= -1) and (MyVecX < 0) and (MyVecY <= 0 ) and (MyVecY > -1)) then {MyVecX = MyVecX + _mySin; MyVecY = MyVecY - _mySin}; if ((MyVecX >= 0) and (MyVecX < 1) and (MyVecY >= -1 ) and (MyVecY < 0)) then {MyVecX = MyVecX + _mySin; MyVecY = MyVecY + _mySin}; if ((MyVecX <= 1) and (MyVecX > 0) and (MyVecY >= 0 ) and (MyVecY < 1)) then {MyVecX = MyVecX - _mySin; MyVecY = MyVecY + _mySin}; Â Â }; }; As you can see, with all of it on one line its hellishly hard to read. Both files are .sqf format. Mtl Share this post Link to post Share on other sites
ManDay 0 Posted July 23, 2007 Add your code line by line and tell us at which point you get the error. €: Oh yes, right taurus. I didn't see that. If you are still getting errors do what I suggested. Share this post Link to post Share on other sites
Taurus 20 Posted July 23, 2007 The only thing I see that you might have missed is the last ; after each line. i.e. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">case 32: { if ((MyVecX >= 0) and (MyVecX < 1) and (MyVecY <= 1 ) and (MyVecY > 0)) then { MyVecX = MyVecX + _mySin; MyVecY = MyVecY - _mySin; }; if ((MyVecX > 0) and (MyVecX <= 1) and (MyVecY <= 0 ) and (MyVecY > -1)) then { MyVecX = MyVecX - _mySin; MyVecY = MyVecY - _mySin; }; if ((MyVecX <= 0) and (MyVecX > -1) and (MyVecY >= -1 ) and (MyVecY < 0)) then { MyVecX = MyVecX - _mySin; MyVecY = MyVecY + _mySin; }; if ((MyVecX >= -1) and (MyVecX < 0) and (MyVecY >= 0 ) and (MyVecY < 1)) then { MyVecX = MyVecX + _mySin; MyVecY = MyVecY + _mySin; }; }; The compiler doesn't always show exactly what is wrong. Share this post Link to post Share on other sites
sickboy 13 Posted July 23, 2007 Are you sure you are running the script with execVM? (and not exec, which is for SQS) Do all variables that you use down there exist and have valid numbers? is the _p2 variable defined as a private variable? (aswell as the others with _) private ["_p2"]; Read ur text now a couple of times but don't spot any typo yet :S The compiler might tell you in the arma.rpt which row is the error,. @Taurus, those ; are unnececairy before the }; because it's on 1 line Share this post Link to post Share on other sites
Taurus 20 Posted July 23, 2007 @Taurus, those ; are unnececairy before the }; because it's on 1 line Ye, I just realized, but I didn't want to edit my post "again" Anyways, I think its like sickboy is saying, check how you start the script. Also, I don't think switches are allowed when calling upon an function from an init-line. I don't recall. Share this post Link to post Share on other sites
mtlgd 0 Posted July 23, 2007 Are you sure you are running the script with execVM? (and not exec, which is for SQS) Bingo!! Thanks a lot, six miles worth, my sanity is preserved!! Share this post Link to post Share on other sites