Varsub

Qedit 5.7 for HP-UX

Home Previous Next


Varsub

Set Varsub ON | OFF

(Default: Off)

When this option is enabled, Qedit parses entered commands looking for variable names. If a variable name is found and currently exists, its value is substituted before the command is executed. If the variable does not exist, the variable name is left unchanged.

Qedit commands are added to the Redo stack before the substitution occurs i.e. with the variable name. So, if the variable value changes between the time the command is entered and the time it is retrieved from the stack, the results may be different. It's also important to note that commands related to Redo stack operations such as Listredo, Do, Before can not have trailing comments enclosed in curly braces anymore. The comments are not removed and likely cause a syntax error.

/listredo  { see which commands I have entered so far }
Bad option, expecting ;UNN ;ABS ;REL or ;OUT
/listredo
     1) t testisql
     2) l "$myvar"
     3) s varsub on
     4) l "$myvar"
     5) setvar myvar "qed"
     6) l "$myvar"
     7) LISTREDO  { SEE WHICH COMMANDS I HAVE ENTERED SO FAR }

Variable names are identified by a leading dollar sign "$". For example, $HOME is replaced with the current value of the HOME environment variable. Some Qedit commands such as List have an extensive series of $-options which, as their name implies, also start with a dollar sign. These options have precedence over environment variables. In other words, if a variable has the same name as a $-option, the substitution does not occur. The only workaround is to change the name of the variable to something that does not conflict.

If you wish to prevent variable substitution and have Qedit interpret the dollar sign at face value, insert a backslash immediately in front of it as in \$HOME.

The tilde is a special character with different meanings in Qedit. Among other things, it can be a string delimiter or a shortcut pointing to the most recent current line in full-screen mode. In HP-UX shells, it's also commonly used to designate the user's home directory.

Here's how Qedit handles the tilde character. If it's still part of the string delimiter list (Verify Stringdelimiter), it is used as such. If it's not part of the list and is entered by itself on a line, it's interpreted as the most recent current line of full-screen mode. If it's not part of the list, Set Varsub is enabled and is used anywhere else in a command, it's replaced with $HOME. The Varsub feature would then substitute the appropriate value.

Set Varsub On automatically removes the tilde from the string delimiter list.


Home Previous Next