• Tutorials

  • Home
  • GPDL Data Types



    DungeonCraft Help Home



    Data in GPDL consists of strings of characters. Period. No integers, no booleans, no pointers. Strings only.

    You are allowed to write things like '$RANDOM(12)', meaning a random number between 0 and 11, inclusive. But even though you did not write quotation marks around '12', the compiler put those quotes in for you. An equivalent expression is: '

    $RANDOM("12"). The result of this expression is a string such as "11".

    Of course many functions expect and return integer values. These functions convert the string arguments to integers before using them and convert integer results to strings before returning them.

    When an integer or real number is expected as an argument (for example: $nPlus(3,6)) the strings are converted to integers and any non-numeric characters in the string except minus and period are simply ignored. Any minus signs will toggle the sign of the result. If more than one decimal point appears in a real number, all but the first are ignored. Real numbers are truncated towards zero when an integer is expected. As examples:

    "ab1c3" will evaluate to 13.

    "Samuel" will evaluate to 0.

    "1.3.4.5" will evaluate to 1.345 and yield 1 as an integer.

    "1.-.-.3.-.4.5" will evaluate to -1.345 and yield -1 as an integer.

    " +-5E3 " will evaluate to -53.



    Now it must be said that although we have not lied to you about the fact that the only data type is a string, it must be said that certain system functions expect and return very special strings. The GPDL compiler checks that functions expecting such special strings are properly fed what they expect. The 'TYPE' of the parameters expected by and returned by these functions is specified in the descriptions of the functions themselves. These 'special' types of strings cannot be created in any way except by a system function that is defined as returning such a value. These special strings serve two purposes:

    Compile-time error checking. Makes life easier.

    Efficiency. Much faster runtime execution.