[quote=312867:@Neil Burkholder]Using your xojo script example with a dictionary you would do this:
[code]
Dim Field1, Result1 As String
Field1 = “Apple”
Dim expression as String
expression = “Field1”
Dim Dict as new dictionary
Dict(“Field1”) = Field1
Result1 = Dict.Value(expression)
msgbox Result1
[/code][/quote]
In actual fact, Field1 does not exist at all. I had indicated to try to tell you that Field1 value is “Apple” for better understanding.
[code]Dim Result1 As String
Dim expression as String
expression = “Field1”
Dim Dict as new dictionary
Dict(“Field1”) = ?
Result1 = Dict.Value(expression)
msgbox Result1[/code]
I do not know what should be placed in the Question mark.
Public Function AlvinEvaluate(DesiredField as string) as string
dim myField as TextField
for i as integer = 0 to self.ControlCount - 1
if window1.Control(i).Name=DesiredField then
myField=TextField(self.Control(i))
return myField.text
end if
next
End Function
The above method in a desktop app would let you write your code like this to display “Apple” in your example:
Hello Seth, thanks for your great effort. I had worked out a sample WebApp based on your methods but I am still getting syntax error. I would appreciate if you could take a look on it.link text
If Field1 does not exist, it can’t have a value to be extracted. (No apples at all!)
Did you mean it does not exist initially but is created during run time? How does field1 get its unknown value? I think we’re missing some key information about what field1 represents.
Neil, in the example he just posted, (“Field1” “Field2” etc.) are actually properties on the web page.
I’ve got to go into a series of meetings now, so I’ll leave it to others… I haven’t used introspection in a web app–does it work there? If so, that’s probably the direction he’s heading in now…
Alvin, please confirm or correct the following as it will help us to help you. Based on the example you sent me, it looks like:
You’re looking for a solution that would work in a web app.
The “fields” are actually properties on the web page.
[quote=312880:@Neil Burkholder]If Field1 does not exist, it can’t have a value to be extracted. (No apples at all!)
Did you mean it does not exist initially but is created during run time? How does field1 get its unknown value? I think we’re missing some key information about what field1 represents.[/quote]
Hello Neil, are you able to take a look at this sample app for better understanding?
One more thought before I have to run: If the ‘fields’ are actually properties on the web page, and their names are known while building the app, you can easily load their values into a dictionary, as suggested by several others earlier. The values could either be loaded into the dictionary once when the app runs, or, if the property values will change over time, load them into the dictionary right when you need to get the particularl value…
Or heck, if they’re properties defined when you’re building the app, you could just use a SELECT CASE statement.
[quote=312883:@Seth Ober]One more thought before I have to run: If the ‘fields’ are actually properties on the web page, and their names are known while building the app, you can easily load their values into a dictionary, as suggested by several others earlier. The values could either be loaded into the dictionary once when the app runs, or, if the property values will change over time, load them into the dictionary right when you need to get the particularl value…
Or heck, if they’re properties defined when you’re building the app, you could just use a SELECT CASE statement.[/quote]
This is just an example, in actual fact, it’s not from property and control. The String is input by user during runtime.
[quote=312881:@Seth Ober]Neil, in the example he just posted, (“Field1” “Field2” etc.) are actually properties on the web page.
I’ve got to go into a series of meetings now, so I’ll leave it to others… I haven’t used introspection in a web app–does it work there? If so, that’s probably the direction he’s heading in now…
Alvin, please confirm or correct the following as it will help us to help you. Based on the example you sent me, it looks like:
You’re looking for a solution that would work in a web app.
The “fields” are actually properties on the web page.[/quote]
Hello Seth, yes it is an WebApp. The String is input by user during runtime.
Sorry to be the bearer of bad news, but unless you put in some effort and give a good description of what you want to do and how you set it up (and not have people trying to guess all the time, even basic things like “is it desktop or web?”) you are simply wasting everyones time.
People here (not me) are very helpful, but this is ridiculous.
It sounds like you are lacking the basic concepts. One of the things that almost every app does is read user input.
Here is a working example. Change the text in any of the fields. Change the string of fields to be returned. See the results in the list box. Play around with it and try to grasp the basics so we can help you better. As Tim suggested a control set would be an even better way to accomplish this.
[quote=312900:@Neil Burkholder]It sounds like you are lacking the basic concepts. One of the things that almost every app does is read user input.
Here is a working example. Change the text in any of the fields. Change the string of fields to be returned. See the results in the list box. Play around with it and try to grasp the basics so we can help you better. As Tim suggested a control set would be an even better way to accomplish this.[/quote]
As mentioned, Field1 to Field5 are not controls. If It does exist, I will be able to use Seth’s method to locate the values:-
Public Function AlvinEvaluate(DesiredField as string) as string
dim myField as TextField
for i as integer = 0 to self.ControlCount - 1
if window1.Control(i).Name=DesiredField then
myField=TextField(self.Control(i))
return myField.text
end if
next
End Function
By removing the Field controls in your sample webapp, it will be bricked. Anyway I greatly appreciated your effort trying to help me out but that is still not what I am trying to achieve.
You still haven’t said how the user will enter the text at runtime. The most common way is via a control.
Do you have a thought reading helmet… (I don’t)?
Of course! That is the method for collecting the user input.
I can’t write your app for you, if you don’t say what you want!
That will cause a keynotfound exception if the value is not first set. I already gave him a similar answer and the response was: [quote=312872:@Alvin Lim]In actual fact, Field1 does not exist at all… I do not know what should be placed in the Question mark. (To set the value of field1)[/quote]