Page 1 of 1

Please use string variables instead of alpha in logic

Posted: May 18th, 2016, 12:09 pm
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.

Re: Please use string variables instead of alpha in logic

Posted: May 18th, 2016, 1:19 pm
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,

Re: Please use string variables instead of alpha in logic

Posted: May 18th, 2016, 3:52 pm
by josh
Definitely use array string instead of array alpha.