MKDIR function

Purpose:

MKDIR creates a directory.

Syntax:

RetVal = MKDIR(DirectoryName AS STRING)

Return Value:

  • Data type: INTEGER
    RetVal If the creation of the directory is successful, 0 is returned. If not successful, -1 is returned.

Parameters:

  • Data type: STRING
    DirectoryName A string literal or variable containing name of the directory to be created.

Remarks:

👉 MKDIR can create only one directory each time it is invoked. In the following example, only the directory "BCX" can be created.

Example:

DIM DirectoryName$
DIM RetVal%

DirectoryName$ = "C:\Temp\BCX"

RetVal% = MKDIR(DirectoryName$)
IF RetVal% = 0 THEN
  PRINT "MKDIR created the directory " & DirectoryName$
ELSEIF RetVal% = -1 THEN
  PRINT "MKDIR could not create the directory."
END IF

Result:

MKDIR created the directory C:\Temp\BCX

MKPATH statement

Purpose:

MKPATH creates a multi-level directory path all at once. If any part of the path already exists, MKPATH will add the remaining parts.

Syntax:

MKPATH(PathToMake AS STRING)

Parameters:

  • Data type: STRING
    PathToMake A string literal or variable containing name of the directory path to be created.

Example:

$BCXVERSION "7.5.2"

DIM PathToMake$
 
PathToMake$ = "C:\Temp\BCX\Does it ALL"

MKPATH(PathToMake$)

IF EXIST(PathToMake$) THEN
  PRINT "MKPATH created the directory path" & PathToMake$
ELSE
  PRINT "MKPATH could not create the directory path."
END IF

Result:

MKPATH created the directory C:\Temp\BCX\Does it ALL