Announcement

Collapse
No announcement yet.

Structure

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

  • Lance Edmonds
    replied
    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>

    Leave a comment:


  • Mel Bishop
    replied
    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.


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

    Leave a comment:


  • Michael Mattias
    replied
    *** 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

    Leave a comment:


  • Jose Antonio Esteva R
    Guest started a topic Structure

    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"



    ------------------
Working...
X