Announcement

Collapse
No announcement yet.

Array question

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

  • Mike Burns
    replied
    Scott,

    I am not sure how DDT works but you may be able to create the listbox
    with an empty dynamic string array and then, using LB_ADDSTRING,
    populate the box from your UDT ... you would have to loop thru and
    maybe use (RTRIM$(bi(count).Address)+ CHR$(0)) to convert each item to
    an asciiz string or whatever is required ...

    Some combination of that should work and let you keep your UDT
    without using a second array.

    Mike

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

    Leave a comment:


  • Tom Hanlin
    replied
    The list box expects an array of dynamic strings, not an array of user-defined elements.
    Yes, you will need two arrays here.

    ------------------
    Tom Hanlin
    PowerBASIC Staff

    Leave a comment:


  • Scott Turchin
    replied
    Added a zero byte dummy, same effect:


    Control Add ListBox,hDlg,%IDMAIN_LISTBOX1,bi().Address,5,15,275,120

    Error 535 in H:\PBDLL\PITBULL\PITBULL.BAS(260:43): Dynamic String Variable Expected
    Line 260: Control Add ListBox,hDlg,%IDMAIN_LISTBOX1,bi().Address,5,15,275,120

    Doesn't look like I'm going to get around this without using 2 separate arrays....

    Any ideas?


    Scott

    ------------------
    Scott

    Leave a comment:


  • Peter Manders
    replied
    Scott,

    you might want to add a zero byte to the UDT, just in case Mr. Listbox expects ASCIIZ strings and the zero byte happens to get dropped somehow...

    Code:
    Type BrowserInfo
      hWnd As Long
      Address As String * 255
      Dummy As Byte
    End Type
    Peter


    ------------------
    [email protected]

    Leave a comment:


  • Scott Turchin
    replied
    Very cool, I did not know you could do that!


    Thanks!

    Scott

    ------------------
    Scott

    Leave a comment:


  • Eric Pearson
    replied
    Try adding BYCOPY.

    By the way, to avoid hard-to-find mistakes like that I always use this form...

    Code:
    DIM bi() AS GLOBAL BrowserInfo
    I tend to avoid the "GLOBAL something AS datatype" syntax. DIM your global arrays using AS GLOBAL in your WinMain function, and it accomplishes the same thing with fewer opportunities for errors (IMO).

    -- Eric

    ------------------
    Perfect Sync Development Tools
    Perfect Sync Web Site
    Contact Us: mailto:[email protected][email protected]</A>

    [This message has been edited by Eric Pearson (edited March 13, 2001).]

    Leave a comment:


  • Scott Turchin
    replied
    Ah! thanks!
    That problem licked we now tackle Mr Listbox...he's not very happy with this statement:

    Control Add ListBox,hDlg,%IDMAIN_LISTBOX1,bi().Address,5,15,275,120

    Dynamic string expected....

    Scott

    ------------------
    Scott

    Leave a comment:


  • Eric Pearson
    replied
    You need parens to tell the compiler it's an array...

    Code:
    Global bi()          As BrowserInfo
    -- Eric


    ------------------
    Perfect Sync Development Tools
    Perfect Sync Web Site
    Contact Us: mailto:[email protected][email protected]</A>



    [This message has been edited by Eric Pearson (edited March 13, 2001).]

    Leave a comment:


  • Scott Turchin
    replied
    I'm running into an issue here, perhaps you can help?


    Code:
    Type BrowserInfo
         hWnd As Long
         Address As String * 255
    End Type
    
    Global bi           As BrowserInfo  
    
    
    'OK That works so far, but this fails with Def Type required:
        Incr g_UrlIndex
        bi(g_UrlIndex).hWnd = hWndChild
        bi(g_UrlIndex).Address = Left$(wintext, wer)
    
    It's global and it's dimmed in Winmain as such:
    Dim bi(1 To %MAX_BROWSERS) As BrowserInfo
    ------------------
    Scott

    Leave a comment:


  • Scott Turchin
    replied
    Will this work with a Listbox?
    I'm still working on it but it's returning errors that it does not see my type, despite thatit's global and is dim'd....
    And then the Listbox expects a Dynamic string...


    Scott

    ------------------
    Scott

    Leave a comment:


  • Eric Pearson
    replied
    Arrays can only have a single data type. You would need a one-dimensional array of user-defined types to do that. The elements of various data types would be the "second dimension" of your array.

    Code:
    TYPE MyType
        lLong   AS LONG
        sString AS STRING
    END TYPE
     
    DIM MyArray(10) AS MyType
     
    MyArray(1).lLong = 1
    MyArray(1).sString = "Text"
    -- Eric

    ------------------
    Perfect Sync Development Tools
    Perfect Sync Web Site
    Contact Us: mailto:[email protected][email protected]</A>

    [This message has been edited by Eric Pearson (edited March 13, 2001).]

    Leave a comment:


  • Scott Turchin
    started a topic Array question

    Array question

    I've used multi-dimensional arrays in other languages etc before but really haven't used one in PB yet...

    I'd like to say something like this:

    g_Array(long value,string value)


    Can an array hold both types?

    ie
    g_Array(1,"place one")
    g_Array(2,"Place two")


    Thanks,

    ps smilies are now copyrighted, see this link: http://www.foxnews.com/foxlife/031301/frowny.sml

    Scott

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