Popup Lists

Discuss and publish sample code and applications written in OrbC (OrbForms Designer or PocketC Architect)

Postby MN OrbUser on Wed Feb 15, 2006 2:57 pm

I am writing a program where I would like the user to select 2 numbers, the second one should always be less than or equal to the first one. I have a popup list for the first number which is always from 1 to 5. If the user selects 4, then I want the second popup list to show 1 to 4. That part pretty much works. Now if the user switches the first number to 2 I would like the second list to replace the 4 with 2 and when the user clicks on the second popup it only offers a choice of 1 to 2.

I get the error message : OrbFormsRT (4.0.1) just read from memory location 0x0003DD22, which is an unallocated chunck of memory." which is usually triggered by the app calling MemPtrNew or MemHandleNew.

Perhaps it can't be done with popups and I may have to approach it with a menu and submenu, but my first preference would be to go the popup route.

I am including the code if that helps:

// Draw3D.ocp
// PocketC Architect Application
// Draw3D - implements a 3 dimensional Drawing
// (c)2006 by Jim Kaiser
// jimkaiser@mn.rr.com

// app definition
@app UIApp Draw3D {
name = "Draw3D"
dbname = "Draw3D"
creator = "JAKd"
version = "1.00"

icon {
smallres = "OrbCSampleRes,tAIB,1001"
largeres = "OrbCSampleRes,tAIB,1000"
}

form UIForm mainForm {
id = 100
text = "Draw3D" //name on title bar
x = 0, y = 0, w = 160, h = 160
menuid = 101

menubar UIMenuBar mbarMain {
id = 101
menu UIMenu menuOptions {
text = "Options"
menuitem UIMenuItem miOptionsAbout {
id = 102, sysid = 0, text = "About...", shortcut = "A"
} //end menu item
} //end menu options
} //end MenuBar

label UILabel Level {
id = 103
x = 50, y = 1 //x was 58
text = "level"
}

//popup UIPopup LevelList {
popup LevelList {
id = 104
x = 70, y = 1, w = 18, h = 12
}

list UIList LevelCount {
id = 105
x = 80, y = 1, w = 8, h = 60
triggerid = 104
}

label UILabel Color {
id = 106
x = 92, y = 1
text = "color"
}

//popup UIPopup ColorList {
popup ColorList {
id = 107
x = 112, y = 1, w = 12, h = 12
}

list UIList ColorCount {
id = 108
x = 122, y = 1, w = 8, h = 60 // x was 127
triggerid = 107
}

button UIButton Go {
id = 109
x=139, y=1, w=20, h=11, text="Go"
}

} //end form
} //end @app

// source files
#include "Draw3D.oc"
#include "mainform.oc"

// mainform.oc

handler mainForm.onopen() {

alertc("Draw 3D"," Draw 3D (c) 2006\n by Jim Kaiser\n\n A PocketC Architect \n application\n\n jimkaiser@mn.rr.com","OK",0);
LevelCount.setitems(5, Levels);
LevelCount.selitem = 2; //s/b 2 for release
LevelList.text = LevelCount.gettext(LevelCount.selitem);
ColorCount.setitems(LevelCount.gettext(LevelCount.selitem), Colors);
ColorCount.selitem = 0; // s/b 0 for release
ColorList.text = ColorCount.gettext(ColorCount.selitem);
ColorCount.h = 12 * (int) LevelCount.gettext(LevelCount.selitem);
}

handler LevelList.onlistselect() {
LevelList.text = LevelCount.gettext(LevelCount.selitem);
ColorCount.setitems(LevelCount.gettext(LevelCount.selitem), Colors);
ColorCount.h = 12 * (int) LevelCount.gettext(LevelCount.selitem);
if (ColorCount.selitem > LevelCount.selitem) {
ColorCount.selitem = LevelCount.selitem;
ColorList.text = ColorCount.gettext(ColorCount.selitem);
}
ColorCount.redraw();
}

handler Go.onselect(){
//LevelCount.selitem returns the index of the selected item from the popup
// the index starts at 0.
//LevelCount.gettext returns the value at the position of the index in .selitem
alert("index of level is "+(int)LevelCount.selitem);
alert("index of color is "+(int)ColorCount.selitem);
ColorCount.setitems(LevelCount.gettext(LevelCount.selitem), Colors);
ColorCount.redraw();
}

handler miOptionsAbout.onselect() {
alertc("About","Draw 3D (c) 2006\nby Jim Kaiser\n\nA PocketC Architect application\n\njimkaiser@mn.rr.com","OK",0);
}

// Draw3D.oc

Database CheckForMathlib;

string Levels[5] = {1, 2, 3, 4, 5};

string Colors[5] = {1, 2, 3, 4, 5};


handler Draw3D.onstart() {
// Is mathlib present?
if (CheckForMathlib.open("MathLib",0)==0) {
alert("You need MathLib installed!");
Draw3D.abort();
}
else
mainForm.load();
}



Thanks in advance for any help.
MN OrbUser
 
Posts: 12
Joined: Wed Feb 01, 2006 4:52 pm
Location: USA

Postby MN OrbUser on Thu Feb 16, 2006 12:25 pm

Never mind. I figured it out myself.

I ended up setting the text of the second popup to the new lower value before setting the number of elements in the second popup to the new lower value. The old text must have thrown off the memory allocation.

BTW, Dewey is there any sort of prize for having been the 15,000th poster? Say a free copy of OrbForms Designer <G>?
MN OrbUser
 
Posts: 12
Joined: Wed Feb 01, 2006 4:52 pm
Location: USA


Return to OrbC User Samples

Who is online

Users browsing this forum: No registered users and 3 guests

cron