Data and Dialogs
Passing data to and from dialogs
Issue: 15.2 (March/April 2017)
Author: Marc Zeedar
Author Bio: Marc taught himself programming in high school when he bought his first computer but had no money for software. He's had fun learning ever since.
Article Description: No description available.
Article Length (in bytes): 16,672
Starting Page Number: 65
Article Number: 15207
project15207.zip Updated: 2017-03-01 11:14:08
Related Link(s): None
Excerpt of article text...
One of the first problems I encountered when I started using REALbasic many eons ago, was how to pass data to dialogs and windows. As you probably know, a window can have properties that store data, but once that window/dialog is closed, the data goes away. You need to save it some way—pass it back to the main application—and that's where things get tricky.
The thing is, there are
lotsof ways to do this. Some are better than others. Some techniques are just fine for simple needs, but don't scale well and are bad habits to get into. Others are inefficient and a poor use of resources. A huge problem is creating a system that makes your app difficult to upgrade and enhance because you aren't managing the data very well.
Today we'll explore a few of these approaches and discuss the advantages and disadvantages of each.
A Simple Approach
Let's look at a bare bones example. Say you want to ask the user a simple yes/no question. A typical way might be to throw up a dialog with a couple of choices. In the "yes" and "no" pushbutton's
Actionevents you could store their choice in a global property. Your main code would show the modal dialog and then look at the global property to see which choice was made. Something like this:
...End of Excerpt. Please purchase the magazine to read the full article.