PDA

View Full Version : Listbox calculus


Georges
08-18-2004, 12:35 PM
Hi,

I have to make calculations with lisboxes that are spread over several pages. The user selects a text-item from the listbox (that is internally associated with a data item). These data items are numbers that have to be added to a running total. I take it that the data item is also a string ? How to convert it to an integer ?
So I have to get the item that the user has selected and then from that item get the index and then the corresponding dataitem and then the numeric value of that data iitem. Seems rather complicated. What is the best way to do this ? (I have 20 listboxes ). AMS 5.0 pro.

Sincerely,

Georges

Corey
08-18-2004, 12:49 PM
Hi. Using functions you can encompass all those procedures into a single code block which can then be called with a single command, i.e. doCalc(); or getValue("Listbox1");

For a solid intro to functions in AMS check out the free video clip on this page:

http://speedytraining.com/site/cd3.php

By clicking where it says, "Functions : An Easy Explanation [11:29] (Click here to view this video now!)"

Hope that helps. :) :yes

Corey Milner
Creative Director, Indigo Rose Software (http://www.indigorose.com)

TJ_Tigger
08-18-2004, 12:57 PM
George,

First variables are global in nature. Once your user makes a selection in a listbox, you can get the selected items data and store that in a variable to be used later. Make sure that each variable is unique between your listboxes so you don't overwrite the value in the variable. maybe something like this

nPage1LB1
nPage2LB1
nPage3LB1
nPage4LB1
nPage5LB1
nPage6LB1
nPage7LB1
nPage8LB1

To answer your question about coverting to an interger, there is an action String.ToNumber (http://www.indigorose.com/webhelp/ams50/Program_Reference/Actions/String.ToNumber.htm) that will convert your data from a string to a number.

then you can just add the items together.

value = nPage1LB1 + nPage2LB1 + nPage3LB1 + nPage4LB1 + nPage5LB1 + nPage6LB1 + nPage7LB1 + nPage8LB1

Of I just had another thought where you could store all the values you have captured in a table and use a for loop to add them together.

I hope these ideas help to get you started.

Tigg

Hi,

I have to make calculations with lisboxes that are spread over several pages. The user selects a text-item from the listbox (that is internally associated with a data item). These data items are numbers that have to be added to a running total. I take it that the data item is also a string ? How to convert it to an integer ?
So I have to get the item that the user has selected and then from that item get the index and then the corresponding dataitem and then the numeric value of that data iitem. Seems rather complicated. What is the best way to do this ? (I have 20 listboxes ). AMS 5.0 pro.

Sincerely,

Georges

Georges
08-19-2004, 04:13 AM
Whaw,

I am impressed with the speed , friendlyness and quality of the support on this forum. I was not aware of the power of this scripting engine in AMS. I worked with other form development systems before but once it comes to speed and flexibility (:=power) AMS beats them all especially in large multipage projects. I am amazed and impressed and will be delving deeper in the LUA like language for further developments.
I am now working on a system that captures data and saves them in a database. I see that there is a SQL plugin available that could accomodate this (is that right ?). I have ordered the CD's that will simplify these early steps and if I got stuck somewhere well this forum is a fine place to come back to. maybe one day I will be able to post some things myself and contribute to the ongoing efforts.

Really gratefull,

Georges

Corey
08-19-2004, 04:57 AM
Cool! :yes :)

Corey Milner
Creative Director, Indigo Rose Software (http://www.indigorose.com)