' com_scripting.pb — Scripting Runtime simulation (FileSystemObject)
#COMPILE EXE
#DIM ALL

FUNCTION PBMAIN() AS LONG
    LOCAL driveIDs(10) AS LONG
    LOCAL driveTypes(10) AS LONG
    LOCAL driveFreeSpace(10) AS LONG
    LOCAL driveTotalSize(10) AS LONG
    LOCAL folderIDs(30) AS LONG
    LOCAL folderSizes(30) AS LONG
    LOCAL fileIDs(40) AS LONG
    LOCAL fileSizes(40) AS LONG
    LOCAL i AS LONG
    LOCAL j AS LONG
    LOCAL totalSpace AS LONG
    LOCAL freeSpace AS LONG
    LOCAL usedSpace AS LONG
    LOCAL numDrives AS LONG
    LOCAL numFolders AS LONG
    LOCAL numFilesHere AS LONG
    LOCAL iter AS LONG
    LOCAL driveID AS LONG
    LOCAL folderID AS LONG
    LOCAL fileID AS LONG
    LOCAL sz AS LONG
    LOCAL dType AS LONG

    PRINT "=== Scripting Runtime: FileSystemObject ==="

    numDrives = 3

    driveIDs(0) = 1
    driveTypes(0) = 2
    driveFreeSpace(0) = 204800
    driveTotalSize(0) = 512000

    driveIDs(1) = 2
    driveTypes(1) = 2
    driveFreeSpace(1) = 409600
    driveTotalSize(1) = 1024000

    driveIDs(2) = 3
    driveTypes(2) = 3
    driveFreeSpace(2) = 0
    driveTotalSize(2) = 0

    PRINT "Drives: " + STR$(numDrives)
    FOR i = 0 TO numDrives - 1
        driveID = driveIDs(i)
        dType = driveTypes(i)
        IF dType = 2 THEN
            totalSpace = driveTotalSize(i)
            freeSpace = driveFreeSpace(i)
            usedSpace = totalSpace - freeSpace
            IF driveID = 1 THEN PRINT "  C: " + STR$(usedSpace) + "MB used / " + STR$(totalSpace) + "MB total"
            IF driveID = 2 THEN PRINT "  D: " + STR$(usedSpace) + "MB used / " + STR$(totalSpace) + "MB total"
        END IF
        IF dType = 3 THEN
            IF driveID = 3 THEN PRINT "  E: (CD-ROM)"
        END IF
    NEXT i

    numFolders = 4
    folderIDs(0) = 1
    folderSizes(0) = 32000
    folderIDs(1) = 2
    folderSizes(1) = 85000
    folderIDs(2) = 3
    folderSizes(2) = 12000
    folderIDs(3) = 4
    folderSizes(3) = 4500

    PRINT "Folders:"
    FOR i = 0 TO numFolders - 1
        folderID = folderIDs(i)
        sz = folderSizes(i)
        IF folderID = 1 THEN PRINT "  Windows (" + STR$(sz) + " KB)"
        IF folderID = 2 THEN PRINT "  Program Files (" + STR$(sz) + " KB)"
        IF folderID = 3 THEN PRINT "  Users (" + STR$(sz) + " KB)"
        IF folderID = 4 THEN PRINT "  Temp (" + STR$(sz) + " KB)"
    NEXT i

    numFilesHere = 6
    fileIDs(0) = 1
    fileSizes(0) = 256
    fileIDs(1) = 2
    fileSizes(1) = 128
    fileIDs(2) = 3
    fileSizes(2) = 512
    fileIDs(3) = 4
    fileSizes(3) = 4096000
    fileIDs(4) = 5
    fileSizes(4) = 3072000
    fileIDs(5) = 6
    fileSizes(5) = 65536

    PRINT "System Files:"
    FOR i = 0 TO numFilesHere - 1
        fileID = fileIDs(i)
        sz = fileSizes(i)
        IF fileID = 1 THEN PRINT "  autoexec.bat (" + STR$(sz) + " bytes)"
        IF fileID = 2 THEN PRINT "  config.sys (" + STR$(sz) + " bytes)"
        IF fileID = 3 THEN PRINT "  boot.ini (" + STR$(sz) + " bytes)"
        IF fileID = 4 THEN PRINT "  pagefile.sys (" + STR$(sz) + " bytes)"
        IF fileID = 5 THEN PRINT "  hiberfil.sys (" + STR$(sz) + " bytes)"
        IF fileID = 6 THEN PRINT "  swapfile.sys (" + STR$(sz) + " bytes)"
    NEXT i

    PRINT "FSO released"
    PRINT "=== End Scripting ==="
    FUNCTION = 0
END FUNCTION
