About JScript language

Plugins are written in JScript which has a few differences from JavaScript and is more limited.

  • No custom objects. JScript doesn't support creating objects. You can use objects that are exported by Rapid PHP API but you can't create your own custom objects.
  • No case sensitivity.
  • Different operator precedence in boolean expressions. In JavaScript you can write if (a == 0 || b == 1). In JScript you must write if ((a == 0) || (b == 1)) otherwise it will be interpreted incorrectly, i.e. make sure that subexpressions between the boolean operators are enclosed in brackets.
  • Strings are 1-based. To access first character of string you must write s[1] instead of s[0]. Arrays and lists are 0-based.
  • Strings are not objects and don't have callable methods. To obtain substring, length etc use appropriate functions such as copy, length.
  • String literals can only be enclosed in double quotes, not single quotes.
  • Static types. Internally Rapid PHP is statically typed. Which is why you might experience problems when assigning numbers to fields that expect strings and likewise. Use appropriate functions for type conversions such as _t, IntToStr, StrToIntDef etc.
  • Functions support (and sometimes require) variable passing by reference. To declare such variable it must be prefixed by & (e.g. function Test(&a)).
  • If functions need to be referenced then it's done by &function_name.
  • Objects that you create will not be destroyed automatically. Use delete obj statement to destroy objects and free memory. You should free all your objects on exit signal.
  • Instead of try..catch, use try..except. Sample:
      try {
        B = nil; //make it crash deliberately
        B.SetSize(10, 10);
      } except {
        alert(ExceptionClassName + "\n" + ExceptionMessage);