Chris Miller said:
And I get it as a one time analysis to decide how to change a function, introducing a new variable decoupling from a variable passed in by reference or not. It was never intended for permanent runtime decision to have code catering for both cases.
Correct. And it was more of a mental exercise and a realization why I've seen code where Microsoft does that seemingly unnecessarily at time in some of their old VFP examples.
It would be nice to have a feature like this:
Code:
FUNCTION my_function
LPARAMETERS tcDirectory, tcFilename
* Add this ability:
VALIZE(tcDirectory)
VALIZE(tcFilename)
Where you force convert them to value for your local use. It would allow logic like this:
Code:
IF NOT ADDBS(UPPER(FULLPATH(tcDirectory))) == UPPER(tcDirectory)
VALIZE(tcDirectory)
tcDirectory = ADDBS(UPPER(FULLPATH(tcDirectory)))
ENDIF
It would allow the ability to switch the local parameter passed by reference or value, to now be a value from this point forward regardless of how it was passed in.
In logic, it would be like this:
Code:
void my_function(char* directory, char* filename)
{
char _directory[_MAX_PATH];
make_fullpath(_directory, directory);
if (strcmp(_directory, directory) != 0)
directory = &_directory; // Make it be our local copy, but continue using directory as a pointer
}
You basically create a local copy of the variable and still continue to use the pointer, but the local copy is hidden, unlike the above example where it was required to be coded.
I just naturally think of things like this while I'm coding. How it might be be nice to have a particular feature or ability to do something that's not currently available, how it would make the code nicer.
A lot of features I added to Visual FreePro were for supporting legacy code. I created a new LOGICALX data type, which allowed you to convert a boolean .T./.F. value to now be a .T./.F./ plus also a range of other settings (up to 252 additional as it uses one byte to store ASCII 0..255 internally. When evaluated as a boolean it would always return .t. and .f., but when evaluated as a logicalx() it would retrieve the actual value, which is basically a small integer in the range of 0=.f., 32=.f., 255=.t. 1 to 126=other possible settings which evaluate to .f., and 127-254=other possible settings which evaluate to .t.). It was a way to allow new code to run atop legacy code (without changing any legacy code or its use of the logical values), but knowing now in the new code that it's not only .t. or .f., but also other settings which allow for expansion. The old code returned .t. or .f. if it connected to the remote server. The new one returns a logicalx extension, which evaluates to .t. or .f. in legacy code, but in logicalx() testing, would return the actual value, which could indicate a connection speed setting, or a reason for failure.
Lots of other ideas like that went into Visual FreePro's design. Anytime you'd see the X extended on to something, like LOGICALX(), DATEX(), DATETIMEX(), etc.
--
Rick C. Hodgin