Commits

Anonymous committed ae83937

Telcom file header editor (Visual Basic)

Comments (0)

Files changed (6)

TelHdrEd/MAINFORM.FRX

Binary file added.

TelHdrEd/MainForm.frm

+VERSION 2.00
+Begin Form MainForm 
+   BackColor       =   &H80000000&
+   BorderStyle     =   1  'Fixed Single
+   Caption         =   "Telcom database header editor"
+   ClientHeight    =   5805
+   ClientLeft      =   2025
+   ClientTop       =   1650
+   ClientWidth     =   7365
+   Height          =   6225
+   Icon            =   MAINFORM.FRX:0000
+   Left            =   1965
+   LinkTopic       =   "Form1"
+   ScaleHeight     =   5805
+   ScaleWidth      =   7365
+   Top             =   1290
+   Width           =   7485
+   Begin CommonDialog CMDialog 
+      CancelError     =   -1  'True
+      DialogTitle     =   "Select the database"
+      Filter          =   "Telcom database|*.tel|Any file|*.*"
+      Left            =   1320
+      Top             =   240
+   End
+   Begin CommandButton BrowseBtn 
+      Caption         =   "Bro&wse..."
+      Height          =   495
+      Left            =   120
+      TabIndex        =   1
+      Top             =   240
+      Width           =   1215
+   End
+   Begin Label DisplayedFileLabel 
+      BackStyle       =   0  'Transparent
+      Caption         =   "Current file: -NONE-"
+      Height          =   195
+      Left            =   0
+      TabIndex        =   0
+      Top             =   0
+      Width           =   7335
+   End
+End
+Sub BrowseBtn_Click ()
+    On Error GoTo EndThis
+
+    CMDialog.Action = 1
+    If CMDialog.Filename = "" Then '// No filename
+        DisplayedFileLabel.Caption = "Current file: -NONE-"
+    Else '// A filename
+        DisplayedFileLabel.Caption = "Current file: " + CMDialog.Filename
+        '// Now to open the file and read the header
+        Close_Database DBHandle% '// Close the current database
+        DBHandle% = Open_Database((CMDialog.Filename)) '// Open DB and get handle
+    End If
+
+EndThis:
+    Resume Next
+End Sub
+
+Sub CentreOnScreen ()
+    Left = (Screen.Width / 2) - (Width / 2)
+    Top = (Screen.Height / 2) - (Height / 2)
+End Sub
+
+Sub Form_Load ()
+    CentreOnScreen
+    SetupComponents
+End Sub
+
+Sub Form_Resize ()
+    DisplayedFileLabel.Width = Width
+End Sub
+
+Sub SetupComponents ()
+    DisplayedFileLabel.Left = 0
+    DisplayedFileLabel.Width = Width
+End Sub
+

TelHdrEd/TELHDRED.ICO

Added
New image

TelHdrEd/TELHdrEd.bas

+Option Explicit
+'/* This is the main module for the Telcom database
+' header editor. */
+
+Global Const TEL_FILEHEADER_SIG = &H60A9
+
+Type FileHeaderType
+    sig As Integer
+    title As String * 254
+    Mver As String * 1
+    Iver As String * 1
+    flags As String * 1
+    securityflags As String * 1
+    author As String * 128
+    comments As String * 4096
+    psw As String * 128
+    programmer As String * 13
+    numrecs As Long
+    formatver As String * 1
+    '// Reserved section of header
+    Res8Flags1 As String * 1
+    Res16Flags1 As Integer
+    ResByte1 As String * 1
+    ResWord1 As Integer
+    ResByte64Arr1 As String * 16
+    '// End of reserved section of header
+    hchecksum As Integer
+End Type
+
+Global FileHeader As FileHeaderType '// This is the file header we keep in memory
+Global DBHandle% '// Holds handle of database during run-time
+
+Sub Close_Database (YourHandle%)
+    If YourHandle% Then
+
+        If WriteDBHeader(YourHandle, FileHeader) Then
+            MsgBox "Whoops!  Can't write the file header back!", MB_ICONSTOP + MB_OK, "Error"
+        End If
+
+        Close YourHandle%
+        YourHandle% = 0
+    End If
+End Sub
+
+Sub Main () '// Program entry point
+    MainForm.Show 1
+
+    If Not DBHandle = 0 Then '// Handle was used?
+        Close_Database DBHandle%'// Close the database again
+    End If
+End Sub
+
+Function Open_Database (FileName$) As Integer
+    Dim Handle%
+
+    Handle% = FreeFile '// Generate a handle for the file
+    Open FileName$ For Binary Access Read Write As Handle% '// Open using handle
+    Open_Database = Handle% '// Give handle to caller
+End Function
+
+Function ReadDBHeader (DBHandle%, TheHeader As FileHeaderType) As Integer
+    '// This function reads the header from a database into TheHeader and
+    '// returns a possible error number
+
+    On Error GoTo Bollocks '// Set up error handling
+
+    '/* NOTE: First byte is a pos 1, not 0 as in C (C's way is more logical, but enough moaning) */
+    Get DBHandle, 1, TheHeader '// Attempt to read entire header in one go
+
+    ReadDBHeader = 0 '// No error
+    Exit Function
+
+Bollocks: '// Oh-no, an error!
+    ReadDBHeader = Err '// Set error
+End Function
+
+Function WriteDBHeader (DBHandle%, YourFileHeader As FileHeaderType)
+    '// This function writes the header YourFileHeader to the database specifed
+    '// by DBHandle and returns a possible error number
+
+    On Error GoTo DamnIt '// Set up error handling
+
+    '/* NOTE: First byte is a pos 1, not 0 as in C (C's way is more logical, but enough moaning) */
+    Get DBHandle, 1, YourFileHeader '// Attempt to read entire header in one go
+
+    WriteDBHeader = 0 '// No error
+    Exit Function
+
+DamnIt: '// Oh-no, an error!
+    WriteDBHeader = Err '// Set error
+
+End Function
+

TelHdrEd/TelHdrEd.mak

+C:\PROGRA~1\VB3\PROJECTS\INCLUDE\DPNAVB0.RTL
+C:\PROGRA~1\VB3\PROJECTS\INCLUDE\DEBUG.BH
+C:\WINDOWS\SYSTEM\ANIBUTON.VBX
+C:\WINDOWS\SYSTEM\CMDIALOG.VBX
+C:\WINDOWS\SYSTEM\SPIN.VBX
+C:\WINDOWS\SYSTEM\THREED.VBX
+C:\WINDOWS\SYSTEM\GAUGE.VBX
+C:\WINDOWS\SYSTEM\SWITCH.VBX
+C:\WINDOWS\SYSTEM\BDT52CTL.VBX
+C:\WINDOWS\SYSTEM\CIRC1.VBX
+C:\WINDOWS\SYSTEM\CIRC2.VBX
+C:\WINDOWS\SYSTEM\CIRC3.VBX
+C:\WINDOWS\SYSTEM\CNTR.VBX
+C:\WINDOWS\SYSTEM\CRYSTAL.VBX
+C:\WINDOWS\SYSTEM\MCI.VBX
+C:\WINDOWS\SYSTEM\MCIWNDX.VBX
+C:\WINDOWS\SYSTEM\MHAL200.VBX
+C:\WINDOWS\SYSTEM\MHCD200.VBX
+C:\WINDOWS\SYSTEM\MHCL200.VBX
+C:\WINDOWS\SYSTEM\MHDC200.VBX
+C:\WINDOWS\SYSTEM\MHGA200.VBX
+C:\WINDOWS\SYSTEM\MHMQ200.VBX
+C:\WINDOWS\SYSTEM\MHSL200.VBX
+C:\WINDOWS\SYSTEM\MHSN200.VBX
+C:\WINDOWS\SYSTEM\MSCOMM.VBX
+C:\WINDOWS\SYSTEM\MSGHNDLR.VBX
+C:\WINDOWS\SYSTEM\MSMASKED.VBX
+C:\WINDOWS\SYSTEM\MSOLE2.VBX
+C:\WINDOWS\SYSTEM\MSOUTLIN.VBX
+C:\WINDOWS\SYSTEM\PAL.VBX
+C:\WINDOWS\SYSTEM\PICCLIP.VBX
+C:\WINDOWS\SYSTEM\PICT.VBX
+C:\WINDOWS\SYSTEM\PIX.VBX
+C:\WINDOWS\SYSTEM\PREVIEW.VBX
+C:\WINDOWS\SYSTEM\PUSH.VBX
+C:\WINDOWS\SYSTEM\SPUSH.VBX
+C:\WINDOWS\SYSTEM\VTSSONLY.VBX
+C:\WINDOWS\SYSTEM\WKSGRPH.VBX
+C:\WINDOWS\SYSTEM\WKSPAGES.VBX
+C:\WINDOWS\SYSTEM\XLIST.VBX
+MAINFORM.FRM
+TELHDRED.BAS
+C:\PROGRA~1\VB3\PROJECTS\INCLUDE\MSGBOXA.BH
+ProjWinSize=152,402,248,215
+ProjWinShow=2
+IconForm="MainForm"
+Title="TEL DB header editor"
+ExeName="TELHDRED.EXE"

bin/TELHDRED.exe

Binary file added.