Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 21 in printed book and digital formats -- plus a one-year subscription (beginning with 22.1) so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Article Preview

Buy Now

Issue 15.2 ('Xojo Power Tricks')
Instant purchase and download via GumRoad!


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
Resource File(s):

Download Icon 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 lots of 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 Action events 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.