$CPU 8086 ' make compatible with XT systems $LIB ALL OFF ' turn off all PowerBASIC libraries $ERROR ALL OFF ' turn off all PowerBASIC error checking $OPTIMIZE SIZE ' optimize for smaller code $COMPILE UNIT ' compile to a UNIT (.PBU) '$COMPILE EXE ' compile to a UNIT (.PBU) DEFINT A-Z ' Required for all numeric functions, forces PB to not ' include floating point in UNIT (makes it smaller) '/*------------------------------------------------------------------*/ $CODE SEG "MLIB1" '/*------------------------------------------------------------------*/ ' Create Temp File ' This function creates a temporary file with a unique filename, closes ' the file, and returns the name of the file (including the path) as the ' return value of the function. If an error occurred, a null string is ' returned, and the DOS error code is returned. ' Path$ is the path in which the temp file is to be created; it must be ' terminated with a \ ' DOS error codes ' 0 = Ok ' 3 = path not found ' 4 = too many open files (increase the FILES= line in CONFIG.SYS) ' 5 = access denied (user does not have create rights in the specified path) FUNCTION MKUFILE(Path$) PUBLIC AS STRING LOCAL TempPath$, Flags%, FileHan% TempPath$ = Path$ + STRING$(13, CHR$(0)) '/* append 13 nulls to the path name REG 1, &H5A00 '/* set AH to 5Ah REG 3, 0 '/* set CX to 0 (file attribute for temp file) REG 8, STRSEG(TempPath$) '/* set DS to segment of path string REG 4, STRPTR(TempPath$) '/* set DX to offset of path string CALL INTERRUPT &H21 '/* call DOS services Flags% = REG(0) '/* assign value of the flags value to a temporary register '/*-- File Creation NOT Successful - set error message code --- IF BIT(Flags%, 0) THEN ECode% = REG(1) CreateTemp$ = "" CreateTemp$ = LTRIM$(STR$(ECode%)) '/*-- File Creation was Successful ---*/ ELSE FileHan% = REG(1) '/*--- close the temporary file (so the calling program can open it with a PB file handle) ---*/ REG 1, &H3E00 ' set AH to 3Eh REG 2, FileHan% ' set BX to file handle CALL INTERRUPT &H21 ' call DOS services ECode% = 0 CreateTemp$ = RTRIM$(TempPath$, CHR$(0)) END IF FUNCTION = CreateTemp$ END FUNCTION '/*-------------------------------------------------------------------*/ ' $INCLUDE "C:\CODE\MLIB\MLIB.INC" ' Path$ = "c:\ZIP\TEP" ' T$ = MKUFILE(Path$) ' SAY 20,1,T$,29 ' Y$ = GETKEY