Skip to main content

Assigning literal strings to variables

  • March 27, 2023
  • 4 replies
  • 0 views

Shawn Waldie
Forum|alt.badge.img

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
  • March 27, 2023

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
Forum|alt.badge.img

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
Forum|alt.badge.img
  • Participating Frequently
  • March 28, 2023

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
Forum|alt.badge.img

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
------------------------------