RPG – Short form expressions

The Free format RPG is full of shortcuts which save you typing time. Two common shortcuts borrowed from objective C, are += and —=, which are used for incrementing and decrementing.

 /FREE

  // increment count by 1 
  count = count + 1;        // long form
  count += 1;               // short form 

  // decrement count by 5        
  count = count - 5;        // long form
  count -= 5;               // short form     
 /END-FREE

Shortcuts also exist for other maths functions such as multiply, divide, and cube…

 /FREE
            
  // multiply count by (a+b)
  count = count * (a+b);    // long form   
  count *= (a+b);           // short form    
       
  // divide count by 17  
  count = count / 17;       // long form   
  count /= 17;              // short form 

  // cube the count          
  count = count ** 3;       // long form   
  count **= 3;              // short form  

 /END-FREE