[SOLVED] information about a variable - or - blind man urgently seeks ophthalmologist or optician

Post your Gambas programming questions here.
Post Reply
User avatar
PJBlack
Posts: 184
Joined: Tuesday 9th June 2020 10:26pm
Location: Florstadt, Hessen, Germany

[SOLVED] information about a variable - or - blind man urgently seeks ophthalmologist or optician

Post by PJBlack »

ok ... i know it's easy ...
ok ... i know i didn't see a tree in the woods ...

my problem is:

i iterate trough
For Each sProp As String In Class.Load(oParent.Name).Symbols
and get (in sProp) a string value starting with ":" (Events), "$" (Private), "_" (Hidden) or 'nothing' (Var) and i'm fine with that.

with
        Object.GetProperty(Me, sProp)
i get the current value ... ok nice but what i have to do to get for example the typeof the variable ... means what to do to get the object(?) from a string value?
Last edited by PJBlack on Tuesday 16th March 2021 11:28pm, edited 2 times in total.
User avatar
cogier
Site Admin
Posts: 1118
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: blind man urgently seeks ophthalmologist or optician

Post by cogier »

Run the following code in a new "Graphical" application. I think this is what you are looking for.
ValueBox1 As ValueBox
TextArea1 As TextArea

Public Sub _new()

  Setup
  ValueBox1_Change()

End

Public Sub ValueBox1_Change()

  Dim oObj As Object = ValueBox1
  Dim sType As String[] = ["NULL", "Boolean", "Byte", "Short", "Integer", "Long", "Single", "Float", "Date", "String", "Object", "Pointer", "Function", "Class"]
  Dim sProperty As String = "Value"

  TextArea1.Clear

  TextArea1.Text = Object.Type(oObj) & gb.NewLine
  TextArea1.Text &= Object.GetProperty(oObj, sProperty) & gb.NewLine
  TextArea1.Text &= sType[TypeOf(Object.GetProperty(oObj, sProperty))]

End

Public Sub Setup()

  With Me
    .Arrangement = Arrange.Vertical
    .H = 300
    .W = 500
    .Padding = 5
    .Text = "Change the value, use Integer, Float and Long"
  End With

  With ValueBox1 = New ValueBox(Me) As "ValueBox1"
    .H = 28
    .W = 100
  End With

  With TextArea1 = New TextArea(Me) As "TextArea1"
    .H = 50
    .W = 50
    .Expand = True
  End With

End
User avatar
PJBlack
Posts: 184
Joined: Tuesday 9th June 2020 10:26pm
Location: Florstadt, Hessen, Germany

Re: blind man urgently seeks ophthalmologist or optician

Post by PJBlack »

thank you but maybe i'm not able to make clear what i'm looking for ...
cogier wrote: Tuesday 16th March 2021 5:56pm
Dim oObj As Object = ValueBox1
i'm here:
Dim oObj As Object = "ValueBox1"
and i'm looking for:
Dim oObj As Object = ConvertThisStringToAnObject("ValueBox1")
User avatar
BruceSteers
Posts: 1523
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: blind man urgently seeks ophthalmologist or optician

Post by BruceSteers »

PJBlack wrote: Tuesday 16th March 2021 7:06pm thank you but maybe i'm not able to make clear what i'm looking for ...
cogier wrote: Tuesday 16th March 2021 5:56pm
Dim oObj As Object = ValueBox1
i'm here:
Dim oObj As Object = "ValueBox1"
and i'm looking for:
Dim oObj As Object = ConvertThisStringToAnObject("ValueBox1")
FMain["ValueBox1"]

also
Me.Window.Controls["ValueBox1"]
If at first you don't succeed , try doing something differently.
BruceS
User avatar
PJBlack
Posts: 184
Joined: Tuesday 9th June 2020 10:26pm
Location: Florstadt, Hessen, Germany

Re: blind man urgently seeks ophthalmologist or optician

Post by PJBlack »

thanks bruce but
    Dim test As Integer = 0

    Print FMain["test"]
give NULL

EDIT:
sometimes it's hard not to be an native english speaker :roll:

to be more detailed ... i have
For Each sProp As String In Class.Load(oParent.Name).Symbols
and i would like to have "sProp" converted back to something that i can use further
User avatar
BruceSteers
Posts: 1523
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: blind man urgently seeks ophthalmologist or optician

Post by BruceSteers »

PJBlack wrote: Tuesday 16th March 2021 7:20pm thanks bruce but
    Dim test As Integer = 0

    Print FMain["test"]
give NULL

EDIT:
sometimes it's hard not to be an native english speaker :roll:

to be more detailed ... i have
For Each sProp As String In Class.Load(oParent.Name).Symbols
and i would like to have "sProp" converted back to something that i can use further
You said Object.
that's not an Object that's a Variable.

myClass = Class.Load(oParent.Name)

For Each sProp As String In myClass.Symbols
Debug myClass[sProp].Type
Debug myClass[sProp].Value
Next

If at first you don't succeed , try doing something differently.
BruceS
User avatar
BruceSteers
Posts: 1523
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: blind man urgently seeks ophthalmologist or optician

Post by BruceSteers »

BruceSteers wrote: Tuesday 16th March 2021 7:39pm
PJBlack wrote: Tuesday 16th March 2021 7:20pm thanks bruce but

EDIT:
sometimes it's hard not to be an native english speaker :roll:
You said Object.
that's not an Object that's a Variable.
I'm not sure if speaking English helps ,
in that last statement I "Objected" to you saying "Object" ?!?
2 same words with completely different meaning?? it makes no sense at all !!

English can be crazy
:lol:
Last edited by BruceSteers on Saturday 20th March 2021 7:09pm, edited 1 time in total.
If at first you don't succeed , try doing something differently.
BruceS
User avatar
BruceSteers
Posts: 1523
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: blind man urgently seeks ophthalmologist or optician

Post by BruceSteers »

Did I help a blind man see the light?
😉
😇
If at first you don't succeed , try doing something differently.
BruceS
User avatar
PJBlack
Posts: 184
Joined: Tuesday 9th June 2020 10:26pm
Location: Florstadt, Hessen, Germany

Re: blind man urgently seeks ophthalmologist or optician

Post by PJBlack »

BruceSteers wrote: Tuesday 16th March 2021 7:39pm You said Object.
that's not an Object that's a Variable.
isn't in OOP everything an object ???
BruceSteers wrote: Tuesday 16th March 2021 7:39pm
myClass = Class.Load(oParent.Name)

For Each sProp As String In myClass.Symbols
Debug myClass[sProp].Type
Debug myClass[sProp].Value
Next
crazy ... how smart things work if they done right ... :roll:
BruceSteers wrote: Tuesday 16th March 2021 9:23pm Did I help a blind man see the light?
😉
😇
ah bruce ... what would I do without you?
it looks like my brain memory capacity is no longer sufficient to store more than three things ...

I knew it was that simple... and I've used this before... but unfortunately it seems to have fallen victim to my dementia/stupidity.

so many thanks to you bruce but also to charlie (i'll add steve here), always quick replies and VERY helpful !!!!

i'm off to search the forest among the trees with my 2¼ dogs
User avatar
BruceSteers
Posts: 1523
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: blind man urgently seeks ophthalmologist or optician

Post by BruceSteers »

PJBlack wrote: Tuesday 16th March 2021 11:24pm
BruceSteers wrote: Tuesday 16th March 2021 7:39pm You said Object.
that's not an Object that's a Variable.
isn't in OOP everything an object ???
BruceSteers wrote: Tuesday 16th March 2021 7:39pm
myClass = Class.Load(oParent.Name)

For Each sProp As String In myClass.Symbols
Debug myClass[sProp].Type
Debug myClass[sProp].Value
Next
crazy ... how smart things work if they done right ... :roll:
BruceSteers wrote: Tuesday 16th March 2021 9:23pm Did I help a blind man see the light?
😉
😇
ah bruce ... what would I do without you?
it looks like my brain memory capacity is no longer sufficient to store more than three things ...

I knew it was that simple... and I've used this before... but unfortunately it seems to have fallen victim to my dementia/stupidity.

so many thanks to you bruce but also to charlie (i'll add steve here), always quick replies and VERY helpful !!!!

i'm off to search the forest among the trees with my 2¼ dogs
whoop whoop :)

Gonna have to say OOP is only "orientated" like Objects but no. Ask the wrong questions get the wrong answers ,hehe ;) :lol:

I'm sure you would have figured it out :)
Happy to help dude :)
If at first you don't succeed , try doing something differently.
BruceS
Post Reply