Trouble populating My Little Grid with data from UDT

Started by Dan English, May 06, 2010, 11:29:26 AM

Previous topic - Next topic

Dan English

I'm having trouble getting data from a user-defined type into a My Little Grid control.

I have verified that the user-defined type is populated with correct data.  All members in the UDT are strings, so that shouldn't be an issue.  I can even populate a listview no problem with this data.

When I try assigning these values to cells in a MLG control, I keep getting an "Error 480: PARAMETER MISMATCHES DEFINITION".

Setting hard-coded test works fine:

MLG_Put HWND_MLGCONTROL, 1, 1, "testvalue1", 0
MLG_Put HWND_MLGCONTROL, 1, 2, "testvalue2", 0
MLG_Put HWND_MLGCONTROL, 1, 3, "testvalue3", 0


But setting values from a UDT does not work:

MLG_Put HWND_MLGCONTROL, 1, 1, MyUDT.Value1, 0
MLG_Put HWND_MLGCONTROL, 1, 2, MyUDT.Value2, 0
MLG_Put HWND_MLGCONTROL, 1, 3, MyUDT.Value3, 0


My UDT is defined similarly as follows:

Type MyUDT
    Value1 AS String * 5
    Value2 AS String * 10
    Value3 AS String * 1
End Type


Displaying MyUDT.Value1 in a MsgBox immediately before the first MLG_Put displays data, so I know it's there.

Am I missing something obvious??

Paul Squires

Not sure if Jim will see your message here but in case he does not, you should send any MLG support questions directly to James Klutho at  mlg@planetsquires.com

Paul Squires
PlanetSquires Software

Dan English


Elias Montoya


Try:

MLG_Put HWND_MLGCONTROL, 1, 1, TRIM$(MyUDT.Value1, chr$(0,32)), 0

Maybe the engine is not made for null characters.
Win7, iMac x64 Retina display 5K, i7-5820K 4.4 ghz, 32GB RAM, All updates applied. - Firefly 3.70.

Dan English

Thanks Elias... that seemed to work.  Seems a bit messy having to do that for each MLG_Put, but it gets the job done!

Paul Squires

I wonder if the problem is that you are sending a fixed length string to a parameter that expects to be a dynamic string?

Maybe try something like;

MLG_Put HWND_MLGCONTROL, 1, 1, ByCopy MyUDT.Value1, 0
Paul Squires
PlanetSquires Software

Dan English

Thanks -- ByCopy works too!  It never would have crossed my mind to use that.

Dan English

Just to finalize this -- Mr. Klutho kindly responded to my e-mail, and simply suggested wrapping the UDT string value with Trim$().  Worked!

Many ways to do this apparently.  Thanks to all!

Paul Squires

If you don't want to trim then you could change your udt to be asciiz.


Type MyUDT
    Value1 AS Asciiz * 5
    Value2 AS Asciiz * 10
    Value3 AS Asciiz * 1
End Type

Paul Squires
PlanetSquires Software

Brian Chirgwin

#9
 A UDT with fix length strings, or array of them, is to be fast. Adding code to automatically "Trim" or what ever one would want to do would add a lot of overhead when it might not be needed.

If you think about it, it would be difficult to impossible to tell when to add this code. For example, if you use Array Sort should it be added and how.

To get what you want, you could use an class/object. An object can have a dynamically sized string.

Code not tested

Class myClass
   instance m_sName as string
   interface myClassInterface
      property get Name() as string
         property = m_sName
     end property
   end interface

end class


A collection class would allow you to have multiple. In the end this might be more work to load into the grid, but it also may allow more flexibility.

Paul Squires

It would be even better if dynamic strings where allowed in UDT's, but they are not and I fought and lost that new feature suggestion many moons ago in the PB forum (some people just can't get past the "UDT's must be fixed length" argument).

Likewise, dynamic arrays in UDT's would be a great addition. These days, it is probably just as easy to convert your code to use classes rather than play with manually allocating/deallocating dynamic strings in UDT's (like I am doing in all my code).
Paul Squires
PlanetSquires Software