Source language: Translate to:

Text Entry Field

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

Text Entry Field

Postby Pat Baner » Mon Jan 03, 2011 4:29 pm

Hello All. This is my first post so please bear with me.

I am using the Neobook and attempting to control a text entry field with a button. I can't find a action that allows me to capture the contents of text field when the button is pushed.

Can anyone shed some light on how to capture the field's content and place it into the field's variable when a button is pushed? Do I have to write that variable directly to a text file or can I leave it in the variable until a later time?

Also, I am trying to use the DBpro plugin. What action would I use to do the same as above except place the contents of multiple fields into a record via a button push? I know I have to associate the variable with a field name, I just can't seem to figure out the button coding.

Thanks in Advance!
Pat Baner
 
Posts: 75
Joined: Tue Jan 04, 2011 9:21 am

Postby Gaev » Tue Jan 04, 2011 6:37 am

Travin69:

Welcome to the NeoBook ecosystem.

Can anyone shed some light on how to capture the field's content and place it into the field's variable when a button is pushed?

NeoBook makes it easy for developers to manage the contents of a Text Entry Field Tool ... by automatically storing it in a specified variable ... from the Help File ..
In order to keep track of the contents of a Text Entry object while your publication is running, you will need to assign the object a unique variable name. NeoBook will automatically assign a variable name that matches the Object Name, but you may change this if you like by modifying the Variable (to store Text Entry contents) field. At runtime, the variable will contain whatever has been typed into the field. You can modify the contents of the Text Entry object by manipulating the variable using a simple Action Command. For example:

SetVar "[TextEntry1]" "Have a nice day!"

Similarly, you can clear the contents of the Text Entry object like this:

SetVar "[TextEntry1]" ""

What action would I use to do the same as above except place the contents of multiple fields into a record via a button push?
Use the same SetVar commands ... once for each Text Entry Box / Record Field Combo ... take a look at the Help file for NeoBookDBPro for the syntax for specifying the fields within Tables of a Database.
User avatar
Gaev
 
Posts: 3728
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby Pat Baner » Tue Jan 04, 2011 7:05 pm

So, am I supposed to use the code "SetVar" as the button's action?

Thanks again for your help. This program is amazing.
Pat Baner
 
Posts: 75
Joined: Tue Jan 04, 2011 9:21 am

Postby Gaev » Wed Jan 05, 2011 6:33 am

Travin69:
So, am I supposed to use the code "SetVar" as the button's action?
You use SetVar (short for Set the Variable's content to) to alter the contents of any Variable within your Application (except some read-only Global Variables that NeoBook conveniently makes available to you) ... but remember that when you use a Text Entry box/object, all you need to do is tell NeoBook (at Design time) what variable is to contain the contents of that box/object ... after that, NeoBook always makes sure that the variable is up to date with each keystroke by the user ... so the only thing you need to do in your Button is "copy the contents of this specified variable to your Database fields using (guess what) SetVar.
User avatar
Gaev
 
Posts: 3728
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby Pat Baner » Wed Jan 05, 2011 6:11 pm

Ok. I am still confused. Here is my basic example:

So, I have a field. I am asking a user to input their last name into that field so I can capture it in my program. I am going to capture it in a variable named "lastname". I want to place the info into the variable when the user pushs a button that is located on the side the field. Lets call the button lastnamebutton.

So, now what code do I use to get the typed value into the variable lastname when the button is pushed. It seems like "SetVar" but how do I tell the program to capture the contents that have been typed into field if I don't know what they are until the user types it in?

The way I read the "SetVar" command is that I kinda have to know what to set the variable to ahead of time. I have to put 2 variables into the "SetVar" command. The variable name and value to store the variable. As I said, I don't know ahead of time what the value will be. Is there some kind of code like "contents" that tells the program to capture the contents of the field on the button push?

I am really confused. Thanks for the help.
Pat Baner
 
Posts: 75
Joined: Tue Jan 04, 2011 9:21 am

Postby beno » Wed Jan 05, 2011 7:02 pm

Hi,

Sometimes, when you are stuck, it is a good idea to create a little pub that isolates the problem, one little example easy to share with the NeoFriends Gang so we can play with it and fix problems.

In other words, its easier to work with code than human text.

My mexican cent,

beno
User avatar
beno
 
Posts: 678
Joined: Fri Apr 01, 2005 9:03 am
Location: México

Postby Pat Baner » Wed Jan 05, 2011 8:45 pm

Ok. I have created a publication that annotates my question the best I can.

You can download it from here:

http://www.craigslistproducts.com/publi ... cation.pub

thanks.
Pat Baner
 
Posts: 75
Joined: Tue Jan 04, 2011 9:21 am

Postby Gaev » Wed Jan 05, 2011 9:10 pm

Travin69:

I have not looked at your publication ... but here is the way it works ...

a) let us say that you have a Text Entry Box named TextEntry45 and have its variable to contain the contents of this Box called [TextEntry45] ... this all set at Design Time

b) So when you run this pub ... as the user enters each keystroke in this Box, Neobook automatically updates the specified variable ... YOU DO NOT NEED TO SCRIPT ANYTHING FOR THIS TO HAPPEN.

c) If you want to design your pub such that when a Button is clicked, the contents of this box (i.e. the content of the variable [TextEntry45]) is copied to another variable (say [LastName]) ... then, in the Button's Click section you say ...
Code: Select all
SetVar "[LastName]" "[TextEntry45]"
... and the variable [LastName] will now contain the same content as was in the TextEntry Box when the user clicked on the button.

Note that the Setvar command is a very powerful/flexible command ... e.g. you can do ...
Code: Select all
SetVar "[abc]" "xyz"
SetVar "[abc]" "123"
SetVar "[abc]" "[anotherVar]xyz[yetanotherVar]"
... and much more.

I suggest you spend a good two hours or so going through the comprehensive Help file ... then, as beno suggested, just try out things (perhaps using the debug facilities to see what neobook is doing in response to your commands).
User avatar
Gaev
 
Posts: 3728
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby Pat Baner » Thu Jan 06, 2011 4:21 pm

Thank you. I understand now. I have reviewed the help file for the last few weeks. Here was my confusion:

The following excerpt is from the help file on Text Field Entry Tool:

"It’s generally not the best place to process data, since the Action may execute many times before the reader finishes entering the requested information. The preferred method is to place a Push Button next to the field for the user to click when the data entry is complete."

So I was looking for action code to use but couldn't find any action that would accomplish this feat other than SetVar. The only problem is it requires two variables and that didn't seem to be user friendly when I have over 100 variables in my software now to have to effectively double the number of variables in use.

Maybe I am misinterpretting what they advised? Any thoughts?

Thanks.
Pat Baner
 
Posts: 75
Joined: Tue Jan 04, 2011 9:21 am

Postby Odd » Fri Jan 07, 2011 12:16 am

Travin69 wrote:The only problem is it requires two variables and that didn't seem to be user friendly when I have over 100 variables in my software now to have to effectively double the number of variables in use.

No, this is not the case. You can use your variable from the Text Entry - for instance [TextEntry1] - in the button action as well. No need to setvar the [TextEntry1] as [TextEntry2] or [lastname]. You may even name the Text Entry variable [lastname] and use it anywhere else you like.
User avatar
Odd
 
Posts: 81
Joined: Sat Apr 02, 2005 3:34 am
Location: Norway

Postby Gaev » Fri Jan 07, 2011 8:05 am

You may even name the Text Entry variable [lastname] and use it anywhere else you like.
I not only agree with this but strongly suggest that this kind of practice be deployed ... because six months later, you will have a hard time remembering that [TextEntry45] is the box for Last Name ... after I create any object, I immediately change its given Name as well as any associated variable names to something "mere humans can relate to" ... so reviewing your script six months later sounds more like a story book than !@#$ code.
User avatar
Gaev
 
Posts: 3728
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada


Return to NeoBook Action Commands

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest