NeoSoft Support Forum Forum Index  Your source for Plug-Ins, sample publications, source code and more...

Source Language:
Translate to:

NeoSoft Support Forum
NeoSoft Community Support Forum
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   SmartFeedSmartFeed   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How do I determine variables associated with an object?

 
Post new topic   printer-friendly view   Reply to topic    NeoSoft Support Forum Forum Index -> NeoBook Knowledgebase
View previous topic :: View next topic  
Author Message
agilefalcon
NeoBooker


Joined: 06 Jan 2007
Posts: 2

PostPosted: Sun Oct 04, 2009 2:22 pm    Post subject: How do I determine variables associated with an object? Reply with quote

I would like to create a generic subroutine that utilizes globally defined variable to pass the name of the calling object. The subroutine now has the name of the object with which to work: How do I obtain the name of the variable associated with the object?

I was hoping a built in function like GetObjectInfo would do this but it doesn't.
Any ideas how I can find the name of a variable (the variable named when an object is created).

thank you,
Chris
Back to top
View user's profile Send private message Yahoo Messenger
Gaev
NeoBooker


Joined: 01 Apr 2005
Posts: 4322
Location: Toronto, Canada

PostPosted: Sun Oct 04, 2009 2:33 pm    Post subject: Reply with quote

Chris:

I am not sure what you are looking for ... but try and insert ...
Code:
AlertBox "Calling Object" "[self]"
... as the first command in your Subroutine.

If this is not what you were looking for ... perhaps you can explain with specific examples.
_________________
Gaev
http://www.scriptedlogic.com/
Back to top
View user's profile Send private message Visit poster's website
agilefalcon
NeoBooker


Joined: 06 Jan 2007
Posts: 2

PostPosted: Sun Oct 04, 2009 4:15 pm    Post subject: Reply with quote

Hello Gaev,
Oh, very good. I wasn't that familiar with the predefined variables such as [self]. So, that saved me a step of creating a variable for the calling object (hard coded).

So, now that I have determined the value of the [self] variable, in this case the object is "TextEntry1"

So, when I put the object on the form and it was given the object name of TextEntry1, it was also given the variable name APR. APR in my program will hold the interest rate. I am performing some validation of this field and other fields to ensure they are all numeric (without limiting them to 0-9 as a preformatted field). Therefore, 9.2 would be valid.

Since I would like this validation routine to be common to all fields in the program I want to put the routine in a single place and call it from each of the objects requiring validation. Therefore, I need to know the calling object so that I can clear or otherwise edit the variable that the contains the data (for that specific object) the user has entered.

Once I know the object (as determined by the [self] variable, how do I find the name of the variable associated with it.

What I find interesting is this:

{NeoBook 5 Objects}
NeoBookVer=5.60
ObjectType=9
Name=TextEntry1
X=8
Y=8
W=80
H=24
Anchor=0
Hint=Enter Annual Percentage Rate
VarName=[APR]
EditLen=0

In the above, I have copied and pasted the object into my Notepad (text editor). Lo and behold, the variable is enumerated there: "VarName=[APR]"

How do I retrieve this and use it in my program?

Thank you!

Chris.
Back to top
View user's profile Send private message Yahoo Messenger
Gaev
NeoBooker


Joined: 01 Apr 2005
Posts: 4322
Location: Toronto, Canada

PostPosted: Sun Oct 04, 2009 4:35 pm    Post subject: Reply with quote

Chris:

I don't think the Object Name is relevant for what you are attempting to do.

A simple technique would be to ...
Code:
SetVar "[Var_Routine]" "[APR]"
GoSub "Routine"
SetVar "[APR]" "[Var_Routine]"
... and use a different variable (in place of [APR]) when calling it from another Text Entry Object.

Also helps to maintain a discipline where the Object Name (which you can also rename) matches the associated Variable Name.

But a better way is to use Functions instead of Subroutines ... where you can pass Variable Names as parameters.
_________________
Gaev
http://www.scriptedlogic.com/
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    NeoSoft Support Forum Forum Index -> NeoBook Knowledgebase All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group

Forum content © 2008 NeoSoft Corp. All rights reserved.