Structures & Uppercase

Discussion in 'Questions (Windows Mobile)' started by skipper, Feb 5, 2008.

  1. skipper

    skipper Member Licensed User

    Hello Erel,

    perhaps is something already know, but I noticed this behaviour in B4PPC.
    if you declare in Sub Global

    Dim Type(a,b,c,d) pippo

    the right panel displays under Global Variables
    pippo: Structure

    if you declare instead in Sub Global

    Dim Type(a,b,c,d) Pippo '(uppercase)

    the right panel displays under Global Variables
    pippo: Array

    Is any reason for that?

    May I use the declared structure (eg: pippo) as a standard Data Type to dim/redim other arrays?

    Many thanks
    Mimmo
     
  2. skipper

    skipper Member Licensed User

    I forgot one question:

    The help says (under DIM): "The same array can be declared many times and its size can be changed"

    I tried with an array of structure

    Sub Globals
    Dim Type(a,b,c,d) pippo(0) 'empty array
    End Sub

    then in AppStart I tried to redim the array

    Sub AppStart
    '--- Dim Type(a,b,c,d) pippo(50) '----> Syntax error
    Dim pippo(50) '----> works

    but when I assign a value

    pippo(10).a="xxxxx"

    i got an error message "Indices lenght does not match the array rank".

    Many thanks for your help

    Mimmo
     
  3. Erel

    Erel Administrator Staff Member Licensed User

    The Array description in the right panel is a bug. It should show Structure in both cases.
    One dimension structures are actually two dimensions arrays.
    To redim the structure you should use:
    Code:
    Dim pippo(50,4'4 is the number of fields.
     
  4. skipper

    skipper Member Licensed User

    Many thanks Erel!

    I did'nt tested it, but I hope the bug is only cosmetic and the defined structure will be treated as a structure along the source code.

    Your tip about redim is welcome. Just as a little remind for future B4P versions, I would suggest the possibility to define a structure of structures as in VB

    Dim Type (a,b,c) MyStruct
    Dim Type (c,d,e,MyStruct) NewStruct

    NewStruct.c=123
    .....
    NewStruct.MyStruct.a="xxxxxxxx"
    NewStruct.MyStruct.b="zzzzzzzz"
    NewStruct.MyStruct.c="yyyyyyy"

    Thanks again for your help.

    Mimmo
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    This bug only affects the description in the right panel. Not the actual behavior of the structure.
     
Loading...