开发者

DCL symbol syntax in OpenVMS

开发者 https://www.devze.com 2023-03-17 06:26 出处:网络
I am really confused by some syntax in the DCL of OpenVMS. For example, these are some of the lines which confused me:

I am really confused by some syntax in the DCL of OpenVMS. For example, these are some of the lines which confused me:

$    wo = "write sys$output"

Does it create a symbol wo for write sys$output?

$ billing_run_number   == p1

Is p1 a parameter passed to the .com file when it was executed? How many parameters can it be supplied with?

$ wo "BILLING_RUN_NUMBER   = ''billing_run_number'"

Is ''abc' substituted by the content of the symbol abc? Why is it ''abc' but not 'abc'? Can we use ""?

$ if ((status .nes. "P") .and. (status .nes. "M")) .or. (ftp_status .nes. "Y")

What does .nes. mean? equal? I've also seen .ne. , .eqs. too. What is the different of them?

Why are "and" and "or" su开发者_Go百科rrounded by two dots? A DCL specific syntax?


from memory: $ wo = "write sys$output" is as you say, assigning wo as an alias for "write sys$output", VMS's equivalent to Unix stdout.

.nes. is "not equal to string", compared to .ne. which is a numeric "not equals".

p1 is a (the first) parameter as you guessed. I can't remember if it goes p1 through p9, or more, or if there is no arbitrary limit. p0 might be the program name, like Python's sys.argv[0].

A command procedure accepts up to 8 parameters, called P1 .. P8.

a single quote (') interpolates the following variable name, so wo "BILLING_RUN_NUMBER = ''billing_run_number'" would output, for example, BILLING_RUN_NUMBER = '42', assuming p1 was equal to 42. I can't remember exactly how DCL knows what to do when it sees two single quotes in a row like that...

The official incantation is ''symbol' to have the actual DCL text replaced by the value of symbol

that'll get you started at least... most shops that use VMS have a few hundred pounds of documentation in 3-ring binders. ask around.


In addition to the documentation referenced above, there is also extensive information via the HELP HINTS, HELP :=, HELP =, and HELP @ commands. P9-P16 became available with OpenVMS V8.4, I believe.

Also, pay careful attention to the difference between global symbols (defined with a doubled equal sign {== or :==}) and local symbols (defined with a single equal sign {= or :=}). Like in case-sensitive languages a symbol defined A = 1 is a different symbol than one defined A == 1 and the local symbol can mask references to the global symbol - also some commands like READ and INQUIRE can create symbols, but I think they are always a local symbol - verify that since I'm working from memory.\

The command SET SYMBOL /SCOPE[={LOCAL|NOLOCAL},{GLOBAL|NOGLOBAL}) can also affect whether you can see certain types of symbols.

In general, stay with local symbols whenever you can - you usually only need a global symbol if a higher level (calling) command procedure needs access, or if you need the symbol still defined when you return to interactive DCL - the exception is any program that you run that specifically reads or write or creates a global symbol - rare, but I've run into a few.


Is p1 a parameter passed to the .com file when it was executed? How many parameter can it be supplied with?

You can pass up to 8 parameters. Each one are defined as P1, P2... P8

If you need more than 8 parameters, you can use trick like

@my_dcl "my_p1" "my_p2" "my_p3" "my_p4" "my_p5" "my_p6" "my_p7" "my_p8 my_p9 my_p10"

In my_dcl, P8 will contain value of "my_p8 my_p9 my_p10" in one single string.

$ wo "BILLING_RUN_NUMBER = ''billing_run_number'"

Is ''abc' substituded by the content of the symbol abc? Why is it ''abc' but not 'abc'? Can we use ""?

$ if ((status .nes. "P") .and. (status .nes. "M")) .or. (ftp_status .nes. "Y")

The single quote means translate the content of the string.

So,if you define wo = "write sys$output"

you can use

wo "Hello World!"

or

'wo "Hello World!"

But what if you want to show write sys$output Hello World

If you try,

wo "'wo Hello World!"

you'll get wo 'wo Hello World!

So, you have to surround it with single quote.

The first two are a escaped single quote, the last one means to stop translation.

wo "''wo' Hello World!"


Like other script language, you can have variable variable...

var_hidden = "Hello world!"
my_var = "var_hidden"
wo 'my_var'

will print Hello world!

0

精彩评论

暂无评论...
验证码 换一张
取 消