如何於 CL 中產生 UUID ?(Command GENUUID with MI GENUUID)
How to Generate UUID in CL ? (Command GENUUID with MI GENUUID)
File : QCLSRC
Member: GENUUIDC
Type : CLLE
/* */
/* \\\\\\\ */
/* ( o o ) */
/*------------------------oOO----(_)----OOo-----------------------*/
/* */
/* Program : GENUUIDC */
/* System : IBM i V7R2 */
/* Author : Vengoal Chang */
/* Date : 2023/11/10 */
/* Description : Generate Universal Unique Identifier (GENUUID)*/
/* GENUUID command CPP */
/* */
/* ooooO Ooooo */
/* ( ) ( ) */
/*----------------------( )-------------( )-------------------*/
/* (_) (_) */
/* */
/* */
/* To compile : */
/* The source type must be "CLLE" (and not CLP). */
/* Compile with STRPDM option 14 or use the */
/* CRTBNDCL command. */
/* */
/*----------------------------------------------------------------*/
Pgm Parm(&UUIDP &UUIDHEX)
Dcl &UUIDP *Char 16
Dcl &UUIDHEX *Char 32
Dcl &TMPL *Char 32
Dcl &LEN *Uint 4 VALUE(32)
Dcl &BytPrv *Uint Stg(*DEFINED) +
Len(4) DefVar(&TMPL)
Dcl &BytAvl *Uint Stg(*DEFINED) +
Len(4) DefVar(&TMPL)
Dcl &Reserved *Char Stg(*DEFINED) +
Len(8) DefVar(&TMPL 10)
Dcl &UUID *Char Stg(*DEFINED) +
Len(16) DefVar(&TMPL 17)
Dcl &RcvHexLen *Int 4 32
CallPrc Prc('_PROPB') Parm((&TMPL *ByRef) +
(X'00' *ByVal) +
(&LEN *ByVal))
ChgVar &BytPrv 32
CallPrc Prc('_GENUUID') Parm((&TMPL *ByRef))
ChgVar &UUIDP &UUID
CallPrc PRC('cvthc') +
PARM((&UUIDHEX *ByRef) +
(&UUID *ByRef) +
(&RcvHexLen *ByVal))
/* DmpClPgm */
End: EndPgm
File : QCMDSRC
Member: GENUUID
Type : CMD
/*****************************************************************/
/* */
/* Command name: GenUUID */
/* */
/* Author : Vengoal Chang */
/* */
/* Date written: 2023/11/10 */
/* */
/* Description : Generate Universal Unique Identifier (GENUUID) */
/* */
/* To compile: */
/* CRTCMD CMD( GenUUID ) */
/* PGM( GenUUIDC ) */
/* SRCMBR( GenUUID ) */
/* ALLOW( *Ipgm *Bpgm ) */
/* */
/*****************************************************************/
Cmd Prompt('Generate Universal Unique ID')
Parm Kwd( UUID ) +
Type(*CHAR) +
Len(16) +
RtnVal(*YES) +
Prompt('CL var for UUID (16)')
Parm Kwd( UUIDHEX ) +
Type(*CHAR) +
Len(32) +
RtnVal(*YES) +
Prompt('CL var for UUID HEX STR (32)')
A blog about IBM i (AS/400), MQ and other things developers or Admins need to know.
星期五, 11月 10, 2023
2023-11-10 如何於 CL 中產生 UUID ?(Command GENUUID with MI GENUUID)
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言