Skip to main content
Shawn Waldie
Mar 27, 2023 12:44 PM UTC

Assigning literal strings to variables

What are all the valid ways to quote literal strings when assigning them to variables in unibasic on Unidata?



------------------------------
Shawn Waldie
enterprise application developer
Rocket Forum Shared Account
Los Angeles CA US
------------------------------

    4 replies

    David Green
    Inspiring
    Mar 27, 2023 1:47 PM UTC

    What are all the valid ways to quote literal strings when assigning them to variables in unibasic on Unidata?



    ------------------------------
    Shawn Waldie
    enterprise application developer
    Rocket Forum Shared Account
    Los Angeles CA US
    ------------------------------

    I use double quotes, single quotes, and backslashes.

    "Hello"

    'Hello'

    \\Hello\\

    of course the functions DQUOTE and SQUOTE can be useful too.



    ------------------------------
    David Green
    Computer Programmer
    Rocket Forum Shared Account
    ------------------------------
    Shawn Waldie
    Mar 27, 2023 1:54 PM UTC

    I use double quotes, single quotes, and backslashes.

    "Hello"

    'Hello'

    \\Hello\\

    of course the functions DQUOTE and SQUOTE can be useful too.



    ------------------------------
    David Green
    Computer Programmer
    Rocket Forum Shared Account
    ------------------------------

    Thank you, David.

    I knew there was at least one more way to do it.



    ------------------------------
    Shawn Waldie
    enterprise application developer
    Rocket Forum Shared Account
    Los Angeles CA US
    ------------------------------
    Peter Gonzalez
    Participating Frequently
    Mar 28, 2023 8:57 AM UTC

    What are all the valid ways to quote literal strings when assigning them to variables in unibasic on Unidata?



    ------------------------------
    Shawn Waldie
    enterprise application developer
    Rocket Forum Shared Account
    Los Angeles CA US
    ------------------------------

    Shawn,

    For consistency I never use a  '  but rather ".  

    COLOR = "BLUE"   ;* preferred method of the "

    COLOR = 'RED'    ;*  never used. 

    COLOR = \\YELLOW\\   ;* never use to assign a variable but preferred method to execute a TCL statement or an Operating system command. 

    STMT = \\SELECT FILENAME WITH COLOR = "BLUE" \\   ;* preferred method of the \\    It's much easier to read and easy on the eyes. 



    ------------------------------
    Peter Gonzalez
    Programmer/Systems Analyst/EDI Developer
    Self Registered
    St. Louis MO US
    ------------------------------
    Shawn Waldie
    Mar 28, 2023 9:50 PM UTC

    Shawn,

    For consistency I never use a  '  but rather ".  

    COLOR = "BLUE"   ;* preferred method of the "

    COLOR = 'RED'    ;*  never used. 

    COLOR = \\YELLOW\\   ;* never use to assign a variable but preferred method to execute a TCL statement or an Operating system command. 

    STMT = \\SELECT FILENAME WITH COLOR = "BLUE" \\   ;* preferred method of the \\    It's much easier to read and easy on the eyes. 



    ------------------------------
    Peter Gonzalez
    Programmer/Systems Analyst/EDI Developer
    Self Registered
    St. Louis MO US
    ------------------------------

    Great suggestions...thank you, Peter.

    In the case that gave rise to my initial question, i have to use something other than a double quote since the string being defined will contain those.



    ------------------------------
    Shawn Waldie
    enterprise application developer
    Rocket Forum Shared Account
    Los Angeles CA US
    ------------------------------