skip to main content

Library Routines : CBL_SPLIT_FILENAME

CBL_SPLIT_FILENAME
The CBL_SPLIT_FILENAME splits a filename into its component parts; that is, the pathname, basename and extension.
Syntax:
 CALL "CBL_SPLIT_FILENAME" USING cbltSplitjoinBuf
Parameters:
01 cblt-splitjoin-buf.
   03 param-length pic x(2comp-x.
   03 split-join-flag1 pic x comp-x.
   03 split-join-flag2 pic x comp-x.
   03 device-offset pic x(2comp-x.
   03 device-length pic x(2comp-x.
   03 basename-offset pic x(2comp-x.
   03 basename-length pic x(2comp-x.
   03 extension-offset pic x(2comp-x.
   03 extension-length pic x(2comp-x.
   03 total-length pic x(2comp-x.
   03 split-buf-len pic x(2comp-x.
   03 join-buf-len pic x(2comp-x.
   03 first-component-length pic x(2comp-x.
param-lenght is the length of the structure in bytes. It should be set to 24. The value 0 is treated as if it were the structure dimension.
splitjoin-flg1’s bit 1 says that the strings are null-terminated if set to 1, while they are space-terminated if set to 0.
splitjoin-flg1’s bit 2 says that the filename is folded to upper case if set to 1, while the original case is preserved if set to 0.
split-buf-len specifies the length in bytes of splitBuffer.
splitjoin-flg2’s bit 2 is set if there is a significant space in the filename.
splitjoin-flg2’s bit 1 is set if there is a wildcard in the path.
splitjoin-flg2’s bit 0 is set if there is a wildcard in basename or extension.
basename-offset returns the start of basename in splitBuffer, from one.
basename-length returns the length of the basename.
extension-offset returns the start of extension in splitBuffer, from one.
extension-length returns the length of the extension.
total-length returns the total number of characters in splitBuffer.
first-component-length returns the number of characters up to and including the first backslash or slash or colon in splitBuffer.
Return code:
returnCode can be any numeric data item and provides additional information:
Examples:
Example - Get the extension in a full pathname
move "C:\temp\print_01.pdf" to the-path. |the-path is a pic x(n) data-item
call "CBL_SPLIT_FILENAME" using cblt-splitjoin-buf, the-path.
display the-path(extension-offset:extension-length)|it will display ‘pdf’

Copyright (c) 2017 Veryant
Contact us
Please share your comments on this manual or on any
Veryant product documentation with the email button at the top left