473,395 Members | 1,678 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Event driven GUI, looping through an array, help

I have an associative array that I need to loop through, allbills,
however, each element in this array requires processing by the user and
I need to capture the users actions on the element and then return to
the next element in the list but suspend looping until I have the users
desired action...

For example,

for(mybill in allbills)
{
GetWhatToDo(mybill); // gets the information about what user wants to
do with the currentBill
}

The problem is that the function "GetWhatToDo" doesn't "block" so the
loop completes without waiting for the users input from GetWhatToDo...

So, my thought was I need to design things more 'event-driven' and
handle things like so:

function handleABill() {
mybill=GetNextBill();
GetWhatToDo(mybill);
}

A "Next" button inside the popup generated by GetWhatToDo will have an
onclick event that calls handleABill again...

The problem is that I can't figure out how to write GetNextBill so that
it maintains the state of the loop through 'allbills', especially since
'allbills' is an associative array and I can't keep track of the array
index. The only thing I can think of is to initialize a regular array
from the associative array and keep track of the index number.

Any other ideas?

Cliff.

http://www.websitenotify.com

Sep 9 '06 #1
1 1413
VK
The only thing I can think of is to initialize a regular array
from the associative array and keep track of the index number.
Universally that seems as the best way. You can also re-iterate
through the object properties every time until you find the
current property and then return the next one:

function returnNext(current) {
var gocha = false;
for (var p in allbills) {
if (gocha) {
return p;
}
else if (p == current) {
gocha = true;
}
else {
// NOP
}
}
}

....but with a lot of properties it gets uneffective (and ugly from the
very start :-)

JScript has Enumerator wrapper to create an navigable associative
array:
var aaAllBills = new Enumerator(allbills)
with fixable pointer and methods atEnd, item, moveFirst, moveNext
Method

JScript also has Dictionary constructor to create full-qualified
associative
array a la Perl.

But what JScript has - it doesn't help too much to other UA's :-(

Sep 9 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: alanrn | last post by:
For all you seasoned VB programmers this is going to be a no brainer. However, as a C programmer learning VB I'm having trouble getting my arms around the event-driven nature of VB. Suppose I...
6
by: WebMatrix | last post by:
Hello, Here's the situation (I'll try to be brief as possible) I am working on the control which is created dynamically based on XML string. This control consists of a table with number of rows...
0
by: kamlesh.bafna | last post by:
Hi , I am trying to design an event manger class for my Windows application. It is sort of smart client application but doe not depend on any external factors to update itself. Better term would...
14
by: Snor | last post by:
I'm attempting to create a lobby & game server for a multiplayer game, and have hit a problem early on with the server design. I am stuck between using a threaded server, and using an event driven...
4
by: AzizMandar | last post by:
C++ Event Coding Questions I have done some simple programs in C++ and read a lot of good C++ books (Including The C++ Programing Language, and C++ Primer) I am trying to understand and...
2
by: Richard Drysdall | last post by:
Hi. In C/C++, I'm used to using a table-driven approach for some problems to avoid large case statements. For example (off the top of my head, may contain syntax errors and error checking...
2
by: John Kotuby | last post by:
Hi guys, I am converting a rather complicated database driven Web application from classic ASP to ASP.NET 2.0 using VB 2005 as the programming language. The original ASP application works quite...
3
by: assgar | last post by:
Hi I am having problem with my loping. I don't know if I have chosen the correct approach. GOAL: I need to insert into a table event types for a specific date range. The calendar the event...
8
by: Brad Walton | last post by:
Hello. First post, but been doing a bit of reading here. I am working on a project in Java, but decided to switch over to C# after seeing some of the additional features I can get from C#. One of...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.