Please use string variables instead of alpha in logic
Posted: May 18th, 2016, 12:09 pm
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:
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.
PROC GLOBAL
alpha(50) name;
In all but a few very rare cases you should instead string variables:alpha(50) name;
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 name;
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.