Please use string variables instead of alpha in logic

Other discussions about CSPro
Forum rules
New release: CSPro 8.0
Post Reply
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Please use string variables instead of alpha in logic

Post by josh »

We see a lot of code that gets posted to this forum or sent to the cspro mailing list that still uses alpha variables in logic. For example:
PROC GLOBAL
alpha(50) name;
In all but a few very rare cases you should instead string variables:
PROC GLOBAL
string name;
The alpha logic variable is a relic from older versions of CSPro before string variables were added and we strongly discourage you from using them.

String variables can do everything alpha variables can and are superior to the old alpha variables in a number of ways:

- You don't specify the width when declaring. String variables grow to fit the length their contents.
- You don't need to use strip() to remove the blanks at the end of a string when displaying them like you do with alpha variables. Strings don't have blanks added to the end.
- Strings use less memory.
htuser
Posts: 631
Joined: December 19th, 2011, 6:26 pm
Location: Silver Spring Area, MD, USA

Re: Please use string variables instead of alpha in logic

Post by htuser »

Thank you Josh,
I change alpha to string this week except for : array alpha.
array alpha (2) responses_ha6(12)

Must i replace all array alpha with array string?

Thanks in advance for response,
G.VOLNY, a CSProuser from Haiti, since 2004
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Please use string variables instead of alpha in logic

Post by josh »

Definitely use array string instead of array alpha.
Post Reply