TIP: Click on subject to list as thread! ANSI
echo: power_bas
to: TOM PHILLIPS
from: STEVEN WILLIAMS
date: 1996-05-21 11:11:00
subject: L.O.R.D Program

On , Tom Phillips wrote to All :
TP> Greetings All,
TP> 
TP> I am attempting to do some L.O.R.D. IGM's and a Monster editor but am 
TP> having
TP> some trouble with the structures.. I am not a seasoned programmer but 
ave
TP> written 3 doors and have had good success at creating other utilities..
TP> 
TP> Here is a small do nothing program that should list the first monster in 
TP> LENEMY.DAT but I get blank strings and 0 values returned when I run it.. 
TP> I am obviously missing something :-/  Is anyone out there familiar with 
TP> the data files for the L.O.R.D. game??
TP> 
TP>     DEFINT A-Z
TP> 
TP> DIM strng AS LONG
TP> DIM gld AS LONG
TP> DIM expe AS LONG
TP> DIM hitp AS LONG
TP> 
    Get rid of the DIM statements.  There not needed.
TP> TYPE MonsterRec
TP>   MName AS STRING * 60
TP>   Strength AS LONG
TP>   Gold AS LONG
TP>   Weapon AS STRING * 60
TP>   ExPoints AS LONG
TP>   HitPoints AS LONG
TP>   Death AS STRING * 100
TP> END TYPE
    Here's what you need:
    TYPE MonsterRec
        sl1 as byte
        mName as string * 60
        strength as long
        gold as long
        sl2 as byte
        weapon as string * 60
        exPoints as long
        hitPoints as long
        sl3 as byte
        death as string * 100
    END TYPE
    Pascal stores strings differently than BASIC.  The first byte is the 
string length.  Example; if mName = "Test", then sl1 = 4.
TP> DIM MonRec AS MonsterRec
TP> 
TP> OPEN "LENEMY.DAT" FOR RANDOM ACCESS READ SHARED AS #1 LEN = LEN(MonRec)
TP> P! = 1
TP> REM DO
TP>  GET #1, P!
TP>    A$ = MonRec.MName
TP>    strng = MonRec.Strength
TP>    gld = MonRec.Gold
TP>    B$ = MonRec.Weapon
TP>    expe = MonRec.ExPoints
TP>    hitp = MonRec.HitPoints
TP>    C$ = MonRec.Death
TP>  P! = P! + 1
TP> REM LOOP WHILE NOT EOF(1)
TP> CLOSE #1
TP> 
    Don't assign the fields to other variables.  It wastes space and such.
TP> CLS
TP> LOCATE 7, 1: COLOR 14, 0: PRINT "MonsterName: " + A$
    Locate 7, 1: color 14, 0: print "MonsterName: "; MonRec.mName
TP> PRINT "MonsterPower =" + STR$(strng): PRINT "Experience =" + STR$(expe)
    Print "MonsterPower"; MonRec.strength
    Print "Experience"; MonRec.exPoints
    You get the idea.
TP>  PRINT "Gold =" + STR$(gld): PRINT "WeaponName: " + B$
TP>  PRINT "HitPoints =" + STR$(hitp): PRINT "DeathCry: " + C$
TP>  COLOR 7, 0: PRINT "------------------------------------"
TP>  PRINT "RecLen =" + STR$(LEN(MonRec))
    Why convert to a string?  Just Print "RecLen ="; len(MonRec)
TP> END
TP> 
TP> The record length is coming up as 236.. Is this correct?  Are these files 
    The record length should be 239, due to the sl1, sl2, sl3 added about.
TP> indeed, Random Access files?  Also in my OPEN "player.dat" etc., I come 
TP> up with a record length of 248.. Is this correct or do I have something 
TP> formatted incorrectly?
    More than likely you didn't take the string length bytes into 
consideration as in the above example.
    I have tested the above and it does work.
TP> 
TP> It all looks correct but it's not :-/
TP> 
TP> 
TP> ... Tom Phillips
TP> Internet: T.Phillips@phil.node99.com
TP> 
TP> --- -=[RA 2.02/pro]=-
TP> (1:2607/303)
---
---------------
TP> * Origin: Phil's Place IV {RIP Graphics} [610] 252-6223 or 8633
* Origin: the River Styx, Killeen, TX (817)618-5823 {V.34} (1:395/61)

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™.