Results 1 to 4 of 4

Thread: equates: what are they?

  1. #1
    Junior Member
    Join Date
    Dec 2023
    Posts
    24
    Rep Power
    4

    equates: what are they?

    I'm sure the answer to my question is in the manual, but I can't find it, so I'll ask: What is an equate?

  2. #2
    Junior Member
    Join Date
    Dec 2023
    Posts
    24
    Rep Power
    4
    Constants?

  3. #3
    Junior Member
    Join Date
    Dec 2023
    Posts
    24
    Rep Power
    4
    Yes, they are constants.

  4. #4
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,153
    Rep Power
    736
    Yes, basically constants with a syntactic sugar to make their declaration shorter.

    You can also declare constant as:
    Const MyText As String = "Ciao"
    
    ...very handy is then also this construct:
    BEGIN CONST
      %MyValue = 1
      %MyOtherValue
      %MyFinalValue
    END CONST
    
    ...this will automatically assign value of 2 to %MyOtherValue and value of 3 to %MyFinalValue.

    Original equates are inspired by languages such as PowerBASIC, while CONST & BEGIN CONST were added later.

    There are some tricks you can do with equates, like:
    $MYTEXT = "Hello"
    
    MsgBox 0, %MYTEXT(3) ' Will display "HelloHelloHello" - just syntactical sugar, handy especially for pre-defined equates such as $TAB or $CRLF
    

    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

Similar Threads

  1. Equates
    By Charles Pegge in forum O2h Compiler
    Replies: 0
    Last Post: 18-03-2009, 09:26

Members who have read this thread: 1

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •