- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- Accessing Labels outside the subroutine in DCL
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-16-2007 03:35 PM
тАО04-16-2007 03:35 PM
main_prog:
...
...call sub1
...
sub1 : subroutine
...
...
goto main_prog
...
...
when goto main_prog executes in the subroutine..i'm getting an error.
%DCL-W-USGOTO, target of GOTO not found - check spelling and presence of label.
Appreciate any tips to resolve this.
Thanks in Advance.
Pradeep Nair.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-16-2007 03:39 PM
тАО04-16-2007 03:39 PM
Re: Accessing Labels outside the subroutine in DCL
$ ENDSUBROUTINE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-16-2007 03:43 PM
тАО04-16-2007 03:43 PM
Re: Accessing Labels outside the subroutine in DCL
Sorry i didn't mentioned endsubroutine in the script structure.
With endsubroutine also give the same result unfortunately.
Thanks
Pradeep Nair.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-16-2007 04:03 PM
тАО04-16-2007 04:03 PM
Re: Accessing Labels outside the subroutine in DCL
What I meant is this;
$main_prog:
$!...
$ call sub1
$ goto main_prog
$
$sub1 : subroutine
$!...
$endsubroutine
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-16-2007 04:04 PM
тАО04-16-2007 04:04 PM
SolutionThe USGOTO warning is correct. The scope of the subroutine is strictly between the label and the ENDSUBROUTINE. Subroutines have their own symbol and label spaces. In some ways it's like having a procedure within a procedure.
From a program structure perspective, jumping to an external label would be a very bad thing, as you would leave a dangling CALL on the stack. If you did it in a loop, you'd eventually exhaust command procedure levels and get:
%DCL-W-STKOVF, command procedures too deeply nested - limit to 32 levels
To achieve what you want, you need to EXIT the subroutine cleanly, passing back a status that the caller can use to branch on. For example:
$ main_prog:
...
$ CALL SUB1
$ IF $STATUS.EQ.3 THEN GOTO main_prog
...
$ SUB1 : SUBROUTINE
...
$ EXIT 3 ! tell caller to branch
...
$ EXIT 1 ! tell caller to not branch
$ ENDSUBROUTINE
You should use odd numbers as exit status values so DCL doesn't interpret them as error or warning conditions.
Another, more powerful mechanism is to use a global symbol to return an operation to perform on return. Note the "==" as it MUST be a global symbol. For example:
$ MAIN_PROG:
...
$ SUB1_RETURN_OP==""
$ CALL SUB1
$ 'SUB1_RETURN_OP'
...
$ SUB1 : SUBROUTINE
...
$ SUB1_RETURN_OP=="GOTO MAIN_PROG"
...
$ SUB1_RETURN_OP=="WRITE SYS$OUTPUT ""SUB1 OK"""
...
$ EXIT
$ ENDSUBROUTINE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-16-2007 04:09 PM
тАО04-16-2007 04:09 PM
Re: Accessing Labels outside the subroutine in DCL
A CALL invokes another procedure level; it works just like a @ procedure invocation.
Put another way, you have to EXIT your way back out of a CALL'd subroutine; either an EXIT explicitly issued, or implicitly via reaching the ENDSUBROUTINE.
You cannot GOTO your way out of the CALL'd routine.
The DCL procedure level is analogous to a stack frame in a compiled language; symbols and such can be passed in, but are not passed back out by default. In the case of a CALL'd routine, you can think of the DCL commands between the entry point and the EXIT or ENDSUBROUTINE as being located in a private DCL procedure file.
Stephen Hoffman
HoffmanLabs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-16-2007 04:26 PM
тАО04-16-2007 04:26 PM
Re: Accessing Labels outside the subroutine in DCL
We need to take care of Exit status from the subroutine rather branching to the main procedure.
Now i changed the script to new structure.
main_prog
...
...
call sub1
if $status.eq.3 then goto main_prog
...
...
sub1:subroutine
...
...
goto exit_me
...
...
exit 1
exit_me:
exit 3
endsubroutine
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-16-2007 04:31 PM
тАО04-16-2007 04:31 PM
Re: Accessing Labels outside the subroutine in DCL
Thanks for all the support.
Pradeep Nair.