• News:
    • 0.40: added multiple names per variable, see below
  • Description:
    Variables can be defined via DEF keyword, nearly every where you like, outside a procedure they are global, inside a procedure they are local.

  • Note:
    Global variables are always cleared, but local variables, as they are defined on the stack, contains trash, so if You aren't sure, that the variable is cleared, clear it manualy.

  • E-Note:
    If the variable haven't given any type, it's taken as a PTR TO LONG, not PTR TO CHAR like in AmigaE or CreativE.

  • Syntax:
      DEF<ext> <name> [ <field> ] [ =<default> ] [ :<type> ]...
    

    See this for <ext> explanation.
      DEF name                  // name is VOID/LONG
      DEF name:type             // name is type
      DEF name[]:type           // name is PTR TO type
      DEF name[][]:type         // name is PTR TO PTR TO type
      DEF name[a]:type          // name is array of a types
      DEF name[a,b]:type        // name is array of a*b types with width of a
      DEF name[:a]:type         // name is PTR TO type of width a
      DEF name[:a][:b]:type     // name is PTR TO type of width a and height b
      etc.
    

    (See Types to get info about ":" character between brackets)
      EDEF name[:type]          // for external variables (see Multiple source)
    
  • Simplier/Faster variable definition:
      DEFL  name        is the same as  DEF name:LONG
      DEFUL name        is the same as  DEF name:ULONG
      DEFW  name        is the same as  DEF name:WORD
      DEFUW name        is the same as  DEF name:UWORD
      DEFB  name        is the same as  DEF name:BYTE
      DEFUB name        is the same as  DEF name:UBYTE
      DEFF  name        is the same as  DEF name:FLOAT
      DEFD  name        is the same as  DEF name:DOUBLE
      DEFS  name[x]     is the same as  DEF name[x]:STRING
    
  • Multiple names:
    Actualy you can define upto 4 synonyms for single variable separated by '|'. This way defined variables occupies ony one piece of memory, but several names can be used if needed:
      DEF  abc|klm|xyz:PTR TO L
    
      abc:=[1,2,3]:L
      klm[1]:=4
      xyz[2]:=16
    
    results in abc/klm/xyz contains a pointer to a list of longs [1,4,16].
    abc is the variable, klm and xyz are just synonyms for the same piece of data.

  • Default values:
    Default values are used in two ways: First is global, where You are slightly limited. Global variables can contain only numbers, constants, strings and lists. Nothing more. Local variables can contain everything. Each variable can have its initial value/list/string:
      DEF num=123:LONG,
          float=456.789:FLOAT,
          name='Hello World!\n':PTR TO CHAR,
          list=[12,23,34,45,56]:UWORD
    

    or more complex:
      DEF num=12*3+232/6:LONG,
          float=31/2.2+76.3:FLOAT,
          name='Hello '+
               'Amigans!\n',
          list=[[1,2,3]:LONG,[4,5,6]:LONG,[7,8,9]:LONG]:PTR TO LONG
    

    Variables do not must be defined before they are used, if they are global it is definitely unimportant, if they are local there are some limitations:
      PROC main()
         PrintF('n=\d, m=\d\n',n,m)
         DEF n=1
      ENDPROC
      DEF m=2
    

    is same as:
      PROC main()
         DEF n
         PrintF('n=\d, m=\d\n',n,m)
         n:=1
      ENDPROC
      DEF m=2
    

    it means, that if you want to give to variable default value (n=1), the value will be given on the place where it is defined (in our case after it was printed)