A89: Re: A Address book With Some Real Problems


[Prev][Next][Index][Thread]

A89: Re: A Address book With Some Real Problems




Hi!

> ok, i am trying to get a address book written in c for the 
> calc, but my main problem right now is that i can not get 
> the request dialogs working right, what am i doing wrong?

What is wrong? You mis-understand usage of last three parameters
in DialogAddRequest. Corrected source is given below (some
unelegant details are also changed, like unnecessary usage of
some global variables, etc.), but anyway you will learn how
to use request boxes correctly. Examine parameters for
DialogAddRequest carefully!

> Also, how can i disable the help messages when i call a dialog,
> ie i want to disp my own instead of the use the arrow keys 
> and enter or esc stuff.

Using a callback function, you can overwrite the status line
with whatever you want. Look about DialogNew in tigcclib doc
for description what is callback function (said simply, this is
an user function which is called internally from the dialog
applet; for example callback is called whenever an item in the
dialog gets a focus).

> Any help would be welcomed.

I hope that I helped. The source follows:

#define SAVE_SCREEN

#include <nostub.h>
#include <all.h>

int _ti89,_ti92plus;

static char FName[100][15]={{}};
static char LName[100][15]={{}};
static char Phone[100][10]={{}};
static char Fax[100][10]={{}};
static char Email[100][30]={{}};
static char Address[100][30]={{}};
static char CSZ[100][30]={{}};

int MyCallBack(int a,long b)
{
  ST_helpMsg("Whatever you want...");
}

int editen(int en)
{
  char buffer[140];
  HANDLE handle;
  int dummy;
  en--;
  memcpy(buffer,FName[en],15);
  memcpy(buffer+15,LName[en],15);
  memcpy(buffer+30,Phone[en],10);
  memcpy(buffer+40,Fax[en],10);
  memcpy(buffer+50,Email[en],30);
  memcpy(buffer+80,Address[en],30);
  memcpy(buffer+110,CSZ[en],30);
  handle=DialogNew(140,93,MyCallBack);
  DialogAddTitle(handle,"Add/Edit Entry",BT_OK,BT_CANCEL);
  DialogAddRequest(handle,3,13,"First Name:",0,15,10);
  DialogAddRequest(handle,3,23,"Last Name:",15,15,10);
  DialogAddRequest(handle,3,33,"Phone Number:",30,10,10);
  DialogAddRequest(handle,3,43,"Fax Number:",40,10,10);
  DialogAddRequest(handle,3,53,"Email Address:",50,30,10);
  DialogAddRequest(handle,3,63,"Address:",80,30,10);
  DialogAddRequest(handle,3,73,"City State Zip:",110,30,10);
  dummy=DialogDo(handle,CENTER,CENTER,buffer,NULL);
  if(dummy==13)
    {
      memcpy(FName[en],buffer,15);      // I did this
      memcpy(LName[en],buffer+15,15);   // for you...
      memcpy(Phone[en],buffer+30,10);
      memcpy(Fax[en],buffer+40,10);
      memcpy(Email[en],buffer+50,30);
      memcpy(Address[en],buffer+80,30);
      memcpy(CSZ[en],buffer+110,30);
      ST_helpMsg("Changes Saved");
      ngetchx();
    }
  else
    {
      ST_helpMsg("Changes Not Saved");
    }
}

void ab(void)
{
  editen(1);
}

void cal(void)
{
}

int _main()
{
  int result=1;
  HANDLE handle;
  ST_helpMsg("Welcome to Address book 2K Plus");  
  while(result!=0&&result!=9)
    {
      handle=PopupNew("Address book 2K PLUS",0);
      PopupAddText(handle,-1,"Calender",1);
      PopupAddText(handle,-1,"Address Book",2);
      PopupAddText(handle,-1,"Quit",9);
      result=PopupDo(handle,CENTER,CENTER,0);
      if(result==2)
        ab();
      if(result==1)
        cal();
    }
  return 0;
}

Cheers,

Zeljko Juric



Follow-Ups: