Page 1 of 1

PostPosted: Thu Jul 20, 2006 8:07 pm
by reh
I'm having some trouble moving from PocketC (where I wrote dozens of short, working apps) to PocketC Architect. So I've studied the examples in the documentation carefully. Here's one that baffles me -- my questions are listed as comments at the end of the code. Thanks in advance for any answers. (I will study some of the working sample apps as well, in hopes of understanding this software.)

-- Rachel Holmen, Berkeley, CA, USA

//from the Pocket C Architect documentation

@app myApp {
creator = "MyAp";
name = "App Name";
dbname = "AppName-MyAp";
}

@form myForm {
id = 1000
text = "My Form"
x = 0, y = 0, w = 160, h = 160

field nameField {
id = 1001
x = 10, y = 60, w = 140, h = 12
}

button alertButton {
id = 1002
x = 60, y = 80, w = 40, h = 12
text = "My Button"
}
}

// a global variable to hold the salutation.
string text;

// the handler for when the app is started
handler myApp.onstart() {
// load the main form
myForm.load();
}

// a function to build the text for the alert
string buildText(string name) {
return "Hello, " + name;
}

// the handler for the button, which displays the alert
handler alertButton.onselect() {
text = buildText(nameField.text);
alert(text);
}

// Comments by R Holmen -- why does the second iteration of the button show different text than the first?
// Is this to be an example? Or is it just sloppy programming?
// You cannot enter any data into the Namefield, even though a blinking cursor and an underscore appear on the form
// The dialog box, therefore, displays only the word "Hello, " without adding a name.
// What code is required to allow data entry into Namefield?
// What is needed to display "Hello, Jim." -- assuming you entered "Jim" into the Namefield?

===== end =====

-- Rachel Holmen, Berkeley, CA, USA, registered user of Pocket C and Pocket C Architect