Is variable or property an array?
When validating a function, procedure or method parameters, it's sometimes necessary to determine if passed parameter is an array. Until VFP 9.0 there was no obvious way to do that.
In VFP 9.0 the TYPE() function accepts additional second parameter 1, to determine if passed expression is an array, a collection or neither. In previous VFP version we can use the TYPE() function in combination with ALEN() function.
| This is sample code. Add error handling and adjust to your requirements as necessary. |
* VFP 9.0 IF TYPE("SomevariableOrProperty",1) = "A" * It's array ENDIF * VFP 8.0 and earlier IF TYPE("ALEN(SomevariableOrProperty)")) = "N" * It's array ENDIF
A check TYPE("SomevariableOrProperty[1]") = "N" doesn't work for VFP intrinsic properties. It incorrectly returns 'N' for all of them.
loForm = CREATEOBJECT("Form") ? TYPE("loForm.Top[1]") && Returns N
Recent comments
6 days 13 hours ago
6 days 13 hours ago
6 days 19 hours ago
6 days 21 hours ago
1 week 8 hours ago
2 weeks 8 hours ago
6 weeks 19 hours ago
7 weeks 2 days ago
7 weeks 2 days ago
8 weeks 2 hours ago