Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
SScript: API reference « Noumena
[go: Go Back, main page]

Noumena

SScript: API reference page



If you are not very comfortable with smalltalk messages you should probably take a look at the Smalltalk reference

The following classes have been extended:

  • Object
    • _clear()

      Equivalent to obj.innerHTML= '';

  • String
    • _asBlock()

      Transforms the current "string block" into an anonymous function.  The current string may have formal parameters like [:param1 :param2 ... :paramN | BLOCK].  BLOCK may have as much as instructions as you like, separated by ';'.   BLOCK may return any value and the "return" instruction must be expressed by the "^" operator.

    • _isNumber()

      Answers by true or false if the current string represents a number.

    • _printOn(...)

      Takes string or object variable arguments. If string, it calls the document.getElementById(string);  method and applies .innerHTML+= self to the retrieved object.  If object, it just applies the latter.

    • _print()

      Shows an "alert" of the current string. "howdy"._print() is the same as typing alert("howdy").

    • _whileTrue(aStringBlock)

      Executes aStringBlock until the condition is false.  This method has also been overloaded with _whileTrue(aBlock).

    • _asNumber()

      Transforms the current string matching a number into a Number instance.  null is returned if the current string does not match a number expression.

  • Array
    • _do(aStringBlock)

      Applies aStringBlock to each element of the Array. The current Array is not modified.  The current method has also been overloaded with _do(aBlock)  (and so do all other array methods having aStringBlock as formal parameter).

    • _collect(aStringBlock)

      Does the same as _do but returns a new modified Array instance.

    • _select(aStringBlock)

      Returns a new Array instance with all elements in the current array object which satisfy the condition  given in aStringBlock.

    • _reject(aStringBlock)

      Returns a new Array instance with all elements in the current array object which do not satisfy the condition  given in aStringBlock.

    • _inject_into(initialValue, aStringBlock)

      Accumulates a running value associated with evaluating aStringBlock.  The running value is initialized to initialValue.  The current running value and the next element of the receiver are provided as the arguments to aStringBlock.

    • _sort(aStringBlock)

      Sorts the current array using the comparison block given.

    • _allSatisfy(aStringBlock)

      Returns true if all the elements in the array satisfy aStringBlock. Returns false otherwise.

    • _anySatisfy(aStringBlock)

      Returns true if any element in the array satisfies aStringBlock. Returns false otherwise.

    • _includes(anObject)

      Returns true if the object is contained in the array. Returns false otherwise.

    • _includesAllOf(anArray)

      Returns true if all the elements in the argument array are included in object array. Returns false otherwise.

    • _includesAnyOf(anArray)

      Returns true if any element in the argument array is included in object array. Returns false otherwise.

    • _isEmpty()

      Returns true if the array is empty and false otherwise.

    • _occurrencesOf(anObject)

      Returns the number of occurrences of the object in the array.

  • Number
    • _isNumber()

      Returns true.

    • _printOn(...)

      Takes string or object variable arguments. If string, it calls the document.getElementById(string);  method and applies .innerHTML+= self to the retrieved object.  If object, it just applies the latter.

    • _print()

      Shows the object in an alert.

    • _to_do(number, aStringBlock)

      Iterates from the number object to number (included) executing aStringBlock each step.  This method has also been overloaded with _to_do(number, aBlock)

    To make it easier, all Math functions applying to the Number class have also been added as Number instance messages.  In fact, this Java-like Math class was created (in Java) as a support for Number operations, because in Java numbers are built-in types.  However, JavaScript numbers are instances of the Number class, so all Math class methods should actually be Number messages!  Many of them are self explanatory:

    • _abs()
    • _acos()
    • _asin()
    • _atan()
    • _atan2()
    • _ceil()
    • _cos()
    • _degreesToRadians()
    • _even()
    • _exp()
    • _factorial()
    • _floor()
    • _isZero()
    • _odd()
    • _pow(pow)
    • _radiansToDegrees()
    • _round()
    • _sin()
    • _sqrt()
    • _squared()
    • _tan()
  • Boolean
    • _ifTrue(aStringBlock)

      If the Boolean object is true, then aStringBlock is executed.  This method has also been overloaded with _ifTrue(aBlock).

    • _ifFalse(aStringBlock)

      If the Boolean object is false, then aStringBlock is executed.  This method has also been overloaded with _ifFalse(aBlock).

    • _ifTrue_ifFalse(aStringBlock1, aStringBlock2)

      If the Boolean object is true then aStringBlock1 is executed. aStringBlock2 is executed otherwise.  This method has also been overloaded with _ifTrue_ifFalse(aBlock, aBlock), _ifTrue_ifFalse(aBlock, aStringBlock) and _ifTrue_ifFalse(aStringBlock, aBlock).

  • Function
    • _asBlock()

      Returns this.

    • _whileTrue(aStringBlock)

      Does the same as the String's _whileTrue message. This message has also been overloaded with _whileTrue(aBlock).