TGC Codebase Backup



X to DBO Batch Converter by Kayl669

14th Feb 2008 17:07
Summary

A batch Xfile to DBOfile converter.



Description

This program will convert up to 255 files in the Xfile format into the DBOfile format quickly and easily. Ideal for those large projects. Al you need to do is compile the source, copy and paste the executable into the folder where Xfiles reside and run the program. It will convert all Xfiles in the folder automatically.



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    //////////////////////////////////////////////////////////////////////////////////////////
// Desc:
// A batch program which converts X files into DBO files.
//
// Usage:
// Copy and paste this executable into the directory where you want to convert files,
// then run the executable.
//
// Project:
// X-to-DBO Batch. by: Benjamin Warren Smith.
//
// Copyright: Benjamin Warren Smith 2008
//////////////////////////////////////////////////////////////////////////////////////////


// Initial Setup
CLS RGB(0,0,255)

// Variables
MAX_FILES AS BYTE = 255
DIM Files$(MAX_FILES)       // Stores only X file-filenames
ArrayIndex AS INTEGER = 0
TempFilename$ = ""
Filename$ = ""


// Sort through files in current directory
PERFORM CHECKLIST FOR FILES     // Fill checklist with files

FOR Index = 1 TO CHECKLIST QUANTITY()
    Filename$ = CHECKLIST STRING$(Index)
    INC ArrayIndex, 1
    IF RIGHT$(Filename$, 2) = ".x" || RIGHT$(Filename$, 2) = ".X"
        Files$(ArrayIndex) = Filename$
    ELSE
        DEC ArrayIndex, 1
    ENDIF
NEXT Index
        
// Load Files, one at a time
FOR Index = 1 TO MAX_FILES
    IF Files$(Index) = "" THEN GOTO SKIP_FILE
    LOAD OBJECT Files$(Index), Index
    // Strip away file extension...
    TempFilename$ = left$(Files$(Index), len(Files$(Index))-2)
    // Convert each file...
    SYNC
    SET CURSOR 100, 100 : PRINT "Converting...";Files$(Index)
    SAVE OBJECT TempFilename$+".dbo", Index
    DELETE OBJECT Index
    SKIP_FILE:
NEXT Index

SYNC
CENTER TEXT SCREEN WIDTH()/2, SCREEN HEIGHT()/2, "Press any key to exit"

WAIT KEY