PDA

View Full Version : field to list to DB questions


bianchirider
07-20-2004, 10:47 AM
I am trying to take a number from a field and put it into a list when you hit the an add button. I have an error alert set to go off if the field is null, and a general debugging alert that pops up with your entered value if a number is present in the field. This seems to work the first time around. If you enter a number and hit the add button (the debug alert pops up with your entered
value). If you leave the field blank and hit the add button, you get the error alert.

The problem is after hitting the add button once,you can't go back and edit the field to put another number in. The cursor is there the field is blank, and you can't enter anything. On top of that, hitting the add button a second time gets you the Gen Debug alert with the first value you entered, instead of the empty field error alert. It seems like the field is not displaying the current pointer text after you hit the Add button, nor can you edit the text. Does this have something to do with handles? (which I am not using at this time??). I tried using one but got an error on a line like this:
Handle h;
so I gave up on that.

I would also like to put this number in a list that is on the same form, and eventually in a database. concerning the list part, I am guessing that I need to add this value from the field to an array. I tried setting up an array or intergers just to play around with like this:
int[5] practice;
But that got me an error too. Do I need a character array for this particular app. What is the syntax? Also concerning the list, I am getting an error on this line:
ListType listP;

One last quick question, in Oreilly book as a note:
C doesn't require an explicit typecast when casting from a void * such as the FrmGetObjectPtr. It automatically typecasts for you. C++, on the other hand, requires and explicit typecast in that situation.
what does this mean, example...???

Now on to the code...
all trouble spots are in bold red

Boolean TableADFormDoButtonCommand(UInt16 command) {

Boolean handled = false;
Char *fldTextP;
Char *listTextP, *newline = "\n";
FormPtr frm = FrmGetActiveForm();
FieldPtr fld = FrmGetObjectPtr(frm,FrmGetObjectIndex(frm,TableADT
ableNumField));
fldTextP = FldGetTextPtr(fld);
// ListType *listP;
// ListType listP;

switch (command) {
case TableADDoneButton:
FrmGotoForm (MainForm);
handled = true;
break;

case TableADAddBtnButton:

// FrmAlert(EnteraTableNumberAlert);
if (fldTextP ==NULL){
FrmAlert(EnteraTableNumberAlert);
}
else{

FrmCustomAlert(GenDebugAlert,fldTextP," "," ");
fldTextP = NULL;

// listP = GetObjectPtr(TableADTableListList);
// listTextP = LstGetSelectionText(listP, LstGetSelection(listP));

// FldGetTextPtr(fldP,);

if (listTextP != NULL) { /* If NULL, nothing is selected. */
FldGrabFocus(fld);
FldInsert(fld, listTextP, StrLen(listTextP));
FldInsert(fld, newline, StrLen(newline));
}
else

FrmAlert(EnteraTableNumberAlert);

// FrmAlert(ChooseErrandAlert);
handled = true;
break;

default:
break;
}

return (handled);
}

//using Codewarrior C++ and PEG-615C POSE

Thanks in advance... - C-YA!!
CliAce ~ BianchiRider