Validate Null input

(imported topic written by jdonlin)

All,

Below is partial code from a custom task we use to correct an environmental variable:

// Prompt for new InstallShare

action parameter query “CorrectLPRROOT” with description “Please enter the correct LPRROOT share (example: \server\share):”

//Change the registry value to what was entered

regset "

HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager\Environment

" “LPRROOT”="{escapes of (parameter “CorrectLPRROOT” of action)}"

Can I validate the “CorrectLPRROOT” to prevent a null entry? If there is a null entry, the task should end.

Is this possible? In what document would I find this information?

Thanks!

Jim

(imported comment written by jessewk)

Jim,

You could use a continue if statement…

action parameter query “foo” …

continue if {parameter “foo” of action != “” }

regset …

Instead of matching against a null string you could match against a regex for more granularity.

-Jesse

(imported comment written by jdonlin)

Thanks Jesse, I’ll try that.

The problem is I might have many “foo” entries to check against. I already had a check going on in the relevance, listing all the valid “foo”'s to check against but it got ugly.

In addition, I could not rely on the data that was given to me and that data is subject to change with no notification.

Thanks again.

Jim

(imported comment written by jessewk)

Hi Jim,

You can at least just check the syntax. This will make sure the value starts with 2 backslashes followed by at least 1 character, followed by 1 backslash, followed by at least 1 character, and no trailing whitespace:

continue if {exists match (regex "^\\.

\.

^\s

$") of parameter “foo” of action}

-Jesse

(imported comment written by jdonlin)

Jesse,

That rocks! Thanks for the effort!

Jim