TIP: Click on subject to list as thread! ANSI
echo: power_bas
to: LAWRENCE GORDON
from: DOUG BULMER
date: 1996-06-27 18:07:00
subject: Reading Pascal files

 > Anyone know how to read a Pascal data file and convert the file
 > structure to PB?  The first data byte of a string is usually the length
 > of the string, and I'm supposing that numeric variables don't contain a
 > string length.
 > An example would be appreciated.
 > Thanks.
Below is an example.
-- Doug
  UlRec = RECORD
    Name : STRING[39];
    Filename : STRING[8];
    DlPathname,
    UlPathName : STRING[30];
    Password : STRING[15];
    Flags : UlRecFlagSet;         'UlRecFlagSet is a set of 8 bits
    DSL,
    SeeNames : BYTE;
    ArLvl : ArFlagType;
    NoRatioGroupNum : BYTE;
  END;
  Type UlRec
    aName AS STRING * 40
    Filename AS STRING *9
    DlPathname AS STRING * 31
    UlPathName AS STRING * 31
    Password AS STRING * 16
    Flags AS BYTE
    DSL AS BYTE
    SeeNames AS BYTE
    ArLvl AS STRING * 1
    NoRatioGroupNum AS BYTE
  END;
'ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
'³ FUNCTION: TP2PB$        ³ Converts a Pascal string to a PowerBasic  ³
'³                         ³ string.                                   ³
'ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
'
' TPString$ = Turbo Pascal string to convert
' MaxLen    = Max Lenght of the returned PowerBasic string.
'
Function TP2PB$ (TPString$, MaxLen as Byte) PUBLIC as string
  If ASCII(TPStirng$) > MaxLen Then
    TP2PB$=Mid$(TPString$,2,MaxLen)
  Else
    TP2PB$ =Mid$(TPString$,2,ASCII(TPString$))
  End If
End Function
'ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
'³ FUNCTION: PB2TP$        ³ Converts a PowerBasic string to a         ³
'³                         ³ Pascal string                             ³
'ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
'
' PBString$ = PowerBasic string to convert.
' MaxLen    = Max Lenght of the returned Turbo Pascal string.
'
Function PB2TP$ (PBString$, MaxLen as byte) PUBLIC
    If Len(PBString$) > MaxLen Then     'If String is longer then MaxLen then
      PBString$ = Left$(PBString$,MaxLen)
    End if
    'Now convert the string to Pascal format.
    PB2TP$= CHR$(LEN(PBString$)) + PBString$
End Function
--- GEcho 1.20/Pro
---------------
* Origin: * The War Zone * Wayne, Mi (313)467-9950 (1:2410/805)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.