Announcement

Collapse
No announcement yet.

Structure

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

  • Structure

    *** It is possible create with PB an structure like this: ***

    type MyReg

    Name as string * 20
    Address as string * 30
    Phone as string * 12

    end type

    type MyLlist

    Count as integer
    Register(100) as MyReg

    end type

    Dim aList as MyList

    *** And add a record to the list using this syntax: ***

    Incr aList.Count

    List1.Register(aList.Count).Name = "Joseph"
    List1.Register(aList.Count).Address = "Mexico 10"
    List1.Register(aList.Count).Phone = "1234567890"



    ------------------

  • #2
    *** It is possible create with PB an structure like this: ***
    Code:
    type MyReg
      Name as string * 20
      Address as string * 30
      Phone as string * 12
    end type
    type MyLlist
      Count as integer
      Register(100) as MyReg
    end type
    
    Dim aList as MyList
    Yes.
    *** And add a record to the list using this syntax: ***
    Incr aList.Count
    List1.Register(aList.Count).Name = "Joseph"
    Yes. But you may not be able to use subscripts with periods in them (alist.count may not be allowed. It's been a while since I worked with PB/DOS).

    I know it will work with subscripts not including a period.

    (Also, "name" may not be a permitted UDT member name. I know in the Windows compilers there are a bunch of dopey restrictions on UDT member names like this, but I'm not so sure those restrictions are in PB/DOS)

    MCM

    Michael Mattias
    Tal Systems Inc. (retired)
    Racine WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      NAME is a reserved word. Try using LName (last name) or something
      similar.

      The use of periods in subscripts, labels, array names, etc. is
      is okay SOME OF THE TIME. When I was using PB2.1F, I used periods
      all the time with no problem. Switching to 3.5 however, forced me
      to discontinue using them as it would work some times and not in
      other times.


      ------------------
      There are no atheists in a fox hole or the morning of a math test.
      If my flag offends you, I'll help you pack.

      Comment


      • #4
        Folks, in code above, "aList.Count" is a valid member of a UDT variable, so that name should work fine. Lets try not to confuse, ok? <grin>

        However, there are two problems with the code in the 1st message above.[list=1][*]the UDT definition is called "MyLlist" not "MyList",[*]"name" is a reserved word.[/list=a]
        The following runs fine for me:
        Code:
        type MyReg
         sName as string * 20
         Address as string * 30
         Phone as string * 12
        end type
         
        type MyList
         Count as integer
         Register(100) as MyReg
        end type
         
        Dim aList as MyList, List1 as MyList
        Incr aList.Count
         
        List1.Register(aList.Count).sName = "Joseph"
        List1.Register(aList.Count).Address = "Mexico 10"
        List1.Register(aList.Count).Phone = "1234567890


        ------------------
        Lance
        PowerBASIC Support
        mailto:[email protected][email protected]</A>
        Lance
        mailto:[email protected]

        Comment

        Working...
        X