|
If library_exists(my_library_name) then dltlib lib(my_library_name) end What is the CORRECT way of coding that in CL?
Not sure what you mean by "correct", but this is the easiest way:
PGM
DLTLIB LIB(my_library_name) MONMSG MSGID(CPF2110) /* IGNORE "NOT FOUND" ERROR */
ENDPGM
The above approach assumes success -- and only deals with failure if it needs to. If you expect the library to NOT exist more often than not, it would perform slightly better to check for the object first:
PGM
DCL VAR(&EXISTS) TYPE(*LGL)
CHGVAR &EXISTS VALUE('1') CHKOBJ OBJ(MYLIB) OBJTYPE(*LIB) MONMSG MSGID(CPF9801) EXEC(CHGVAR &EXISTS VALUE('0')
IF (&EXISTS *EQ '1') DO DLTLIB LIB(MYLIB) ENDDO
ENDPGM
IMHO, this code is more complex to read and to maintain, so unless it'll make a significant difference (or if you want to do something other than delete the library when it exists) I'd opt for the first technique.
_______________________________________________ This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/midrange-l or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/midrange-l.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.