Difference between revisions of "If"

Jump to navigation Jump to search
519 bytes added ,  02:49, 23 September 2006
→‎Spaces: Revised
imported>Daveh
imported>JOG
(→‎Spaces: Revised)
Line 143: Line 143:
After the condition or the "else" statement the rest of the line is ignored. There aren't any error messages to warn you, so (since the line appears to be correct) you might spend a lot of time locating the source of the problem.
After the condition or the "else" statement the rest of the line is ignored. There aren't any error messages to warn you, so (since the line appears to be correct) you might spend a lot of time locating the source of the problem.


=== Spaces ===
=== Spaces and Tabs===
Ensure that all operators, numbers, variables, and brackets have a space character on each side to avoid compile problems. Omitting the space character can result in the script not working as intended. Tabs cannot be used in place of spaces.
When using a tabs or space to separate operators/expressions you need to use the same separator on each side if you use space on one side and tab on the other the script might be permanently stopped when the line is executed.


   if (SomeVar>=1)      ;BAD
  if SomeVar>=1        ;GOOD
   if ( SomeVar >= 1 )  ;GOOD  
   if (SomeVar>=1)      ;GOOD
 
   if ( SomeVar >= 1 )  ;GOOD
   if ( SomeVar*10-Test2!=player.GetAV Strength-10)           ;BAD
   if (SomeVar___>=___1) ;GOOD ( "___" = Tab)
   if ( SomeVar * 10 - Test2 != player.GetAV Strength - 10 ) ;GOOD
   if___(SomeVar >= 1)   ;GOOD ( Tab before "'''('''" and ''nothing'' after it is okay)


Note that you will not receive any compiler error or warnings if you omit spaces. You can only determine if the problem is due to missing spaces by looking directly at the compiled script data.  
  if ( SomeVar___>=___1);BAD  ( Space and Tab around "'''SomeVar'''" causes problems)
  if___SomeVar >= 1    ;BAD  ( Tab and Space around "'''SomeVar'''")
  if (___SomeVar >= 1)  ;BAD  ( Space and Tab around "'''('''") 
  if___( SomeVar >= 1)  ;BAD  ( Tab and Space around "'''('''")
  if SomeVar >=___1    ;BAD  ( Space and Tab around "'''=>'''") 
  if (SomeVar___>= 1)  ;BAD  ( Tab and Space around "'''=>'''") 
 
Note that you will not receive any compiler error or warnings. You only notice the script not working correctly. You can determine the problem is caused by this by examining the script in an external text-editor or by looking directly at the compiled script data.  


[[Category:Commands]]
[[Category:Commands]]
Anonymous user

Navigation menu