Announcement

Collapse
No announcement yet.

Random Data Files

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Random Data Files

    Hi all. Got my copy of PowerBASIC 3.5 for DOS yesterday and am in a little bit of a bind with a database project I am working on.

    I was wondering if the DOS version can handle record structure definitions in the following format:
    Code:
    Type MyRec
      Name as String * 30
      Date as String * 10
    End Type
    
    Dim mydata As MyRec 
    
    mydata.Name = "John Doe"
    mydata.Date = DATE$
    If not, what would be the PBDOS way of handling this?
    Last edited by Gary Beene; 25 Jul 2014, 11:30 PM. Reason: Code: tags

  • #2
    What happened when you tried?

    (Hint: It should have worked just fine).
    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      Robert,
      NAME is a reserved word in PBDOS. Try changing NAME to something else.

      Paul.

      Comment


      • #4
        Originally posted by Paul Dixon View Post
        Robert,
        NAME is a reserved word in PBDOS. Try changing NAME to something else.

        Paul.
        Paul, that was just sample code, I don't actually use NAME in my actual code. Will post more information when I get home this evening.

        Comment


        • #5
          Originally posted by Michael Mattias View Post
          What happened when you tried?

          (Hint: It should have worked just fine).
          Here is my actual code:
          Code:
          ----- CODE -----
          Type itemRec
            Name as String * 30
            UPC as String * 30
            Desc as String * 30
            Qty as Integer
            Bin as String * 10
          End Type
          
          DIM item AS itemRec, Record AS QUAD
          
          OPEN "database.db" FOR RANDOM AS #1 LEN = LEN(itemRec)
          
          If Command$ = "init" or Command$ = "INIT" Then
            For Record = 1 To 32767
              item.Name = "<<< EMPTY >>>"
              item.UPC  = "000000000000"
              item.Desc = "NULL"
              item.Qty  = 0
              item.Bin  = "NULL"
              PUT #1, Record, item
            Next Record
          End If
          
          Close #1
          
          ----- CODE -----
          Now, when I go to compile the code, I get this "Error 421: String operand expected". But, looking back, I _think_ I see the problem here.

          [...changes some code...]

          Ok changed the 'Name' variable to iName and it compiled fine. Thanks to the poster who kindly reminded me that 'NAME' is a reserved word/variable
          Last edited by Gary Beene; 25 Jul 2014, 11:31 PM. Reason: Code: tags

          Comment

          Working...
          X