PDA

View Full Version : displaying variables in a paragraph


dthompson16
12-28-2003, 10:03 PM
I'm a newbie and have searched the AMS online help and forum for an answer to my question but so far haven't found it. In an application I am creating, I have an input object where the user inputs a number. I would like to do some math operations on the number in the script for the input box and then display the result within the text of a paragraph or label on the same page, actually right in the middle of a sentence. I'm stuck as to how to do this. I'd appreciate any help. Thanks.

TJ_Tigger
12-28-2003, 10:37 PM
You will have to concatenate the string with the variable.

"The sum of the values you have entered is " .. sumvariable .. "."

The double periods concatenates the two items together. So if the value of sumbariable is equal to 5 the string would read

The sum of the values you have entered is 5.

I hope this helps.

Paragraph.SetText(Paragraph1, "The sum of the values you have entered is " .. sumvariable .. ".");

Ted Sullivan
12-29-2003, 11:15 AM
The great thing about AutoPlay Media Studio 5.0 is that there are lots of different ways to approach a solution!

Tigger's method is really compact, and definitely what the "power user" would do.

On the flip-side, you might find it helpful to break your problem and solution up into multiple steps. It's often the case when working with variables and concatenating strings that doing something in two or three steps is easier to understand than using only one line.


-- get a value from an Input field named Input1
result = Input.GetText("Input1");

-- perform a calculation
newresult = result + 5;

-- create a text string to display result
outputtext = "Your anser is " .. newresult;

-- set the paragraph text for object Paragraph1
Paragraph.SetText("Paragraph1", outputtext);


That should give you lots to go on. You should also take an hour or two to go through the User's Guide and Scripting Guide. There is a lot of great information there - you'll be surprised how much you can accomplish once you've spent a little time with those books!

dthompson16
01-06-2004, 03:18 PM
Thank you both for those excellent perspectives that helped me to implement the solution.

Having a new problem with tooltips. Searching forum for "tooltips" did not answer my question. I am creating an educational application. On a page (say, "Page2") I have a button to which I have added a tooltip. When running the executable, the user clicks on the button and the button is erased (Button.SetVisible and Button.SetEnabled both set to false on the click). If the user stays on the same page, the tooltip does not appear if you run your mouse so cursor is over the location of the hidden button, but if you Page.Navigate to Page1 and then return to Page2, when the mouse rolls over the hidden button, the tooltip appears. Am I doing something wrong? Thank you in advance for your help once again.