09-09-2010 05:10 PM
Hi all,
I want to make a type def or strict type def (not sure which one would do ) for a password, so that if the password need to be updated, I can just change the password in the type def/strict type def and the change would be applied to all existing programs that use the password control/constant? How? Thanks!
Yik
Solved! Go to Solution.
09-09-2010 05:22 PM - edited 09-09-2010 05:23 PM
You could just put the constant (string) in a vi that only has that, which then would be used everywhere. Changing it would get propogated to all places it is used. Or you could make it a typedef'd enum, retrieving the control's "strings[]" with a property node, for your password comparison. I have put it in encrypted form in a text file, read in at program initialization, allowing me to change it without having to recompile the program. In many environments there is no such thing as a small program change, any recompile, rebuild, whatever requires a rigorous retesting/requalification to absolutely confirm that the program's functionality hasn't changed. That is why I try not to hard-code any constants other than Universal ones, like pi.
09-10-2010 10:09 AM
So I cannot just create a numeric controls, key in the password, and set the password as default when I need to change the password? If I do change the password, the change will not propagate to the old programs?
Yik
09-10-2010 10:33 AM
Correct. A type definition defines only the data type, not the actual value. You could make a global variable instead and set its default value to the desired password.
09-10-2010 11:01 AM - edited 09-10-2010 11:05 AM
You could create a typedef enum, with each value being a password, then in your programs Create a Property Node:Strings[] which will give you the various strings in the enum. You could then do an "search 1D array" to find a comparison, which will output the index into the string array which matches, or a -1 in none match.The number returned could also be used for "security levels. Encapsulate all of this in a vi that you use through out the program and then updating the enum will propagate to everywhere it is used, if they all point to the same type def. But this does require that you edit code, which as I said before always has risk. There is a temptation while you have the code open to make this change to make that other "small change" and then come the calls from the users in the middle of the night or over the weekend that some part that "you didn't even touch" isn't working.