Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

When you’re ready to pop up a window, first save the current screen image so you can restore it when you make the window disappear. For example:

Code Block
        char *scnsav;
        :
        movmem(frzseg(),scnsav=alcmem(SCNSIZ),SCNSIZ);

This allocates 4000 bytes and moves the current screen image to it. When done with the window, just restore the saved image back, as in:

Code Block
        movmem(scnsav,frzseg(),SCNSIZ);
        free(scnsav);

Pop-up windows can be popped on top of one another. This means you’ll need to have a series of saves and restores nested in one another, like this:

...

If you don’t want to depend on the CRT offline option, you could compute color automatically by some other method as in:

Code Block
        color=(FP_SEG(frzseg()) != 0xB000);

Don’t define your own color variable — use the global variable from GCOMM.LIB.

...

Put a default value in the sval buffer if you want one (the cursor will start at the right end of the value), or fill sval with a zero-length string to start from scratch. Either way, you have to have maxlen bytes available at sval. Here are the bit flag options for the last parameter of edtval():

Code Block
        #define MCHOICE  1  /* multiple choice question, hide cursor */
        #define ALLCAPS  2  /* convert all chars to capital letters  */
        #define USEPOFF  4  /* use proff() x,y base coord offsets    */
        #define MULTIEX  8  /* allow multiple field-exit conditions  */

The operator can type in a new value, move the cursor right or left, ins or del characters, hit home or end, and when finally done, press enter, tab, shift+tab, up, or down to save or esc to abort. Actually it’s up to you how you handle the difference between all these exit methods. You can tell whether it was esc or not by edtval()’s return value. You can distinguish among the other cases using the edtvalc global variable:

...

Here’s the source code for these routines:

Code Block
int
validig(c,sval);   /* is c a valid decimal digit?          */
int c;
char *sval;
{
     return(c >= '0' && c <= '9');
}

Editor's note (not part of Fountain's text): This sample validig(c,sval) is illustrative only. The name collides with the real engine routine validig(int c) declared in GCOMM.H (one parameter, not two); do not present this sample as the engine API, and do not compile it into a module alongside GCOMM.H. (Source: analysis/wg1/FINDINGS.md.)

Code Block
int
validyn(c,stg)     /* validate c as yes/no (for edtval())  */
int c;
char *stg;
{
     if (tolower(c) == 'y') {
          strcpy(stg,"Yes");
     }
     else if (tolower(c) == 'n') {
          strcpy(stg,"No");
     }
     return(0);
}

Notice how you can allow a single character to change the entire entry string — just write to the buffer pointed to by the sval parameter.

...

Here you get the best of choose() and choowd() in kit form, with some assembly required. Here’s the equivalent of choose() (with an optional starting point like choowd()):

Code Block
supchc(nchoices,choices,upx,upy,lox,loy,escok);
jmp2chc(first); <- this line is optional
dspchc();
cursiz(NOCURS);
do {
     choice=hdlchc(getchc());
while (choice == nchoices);
rstcur();

The jmp2chc() routine establishes the default or starting point, as does the first parameter in choowd(). The new routine dspchc() displays the background of the choice window after startup. Notice it’s polite to turn the cursor off for the choosing session. The hdlchc() routine handles operator keystrokes. Of course, you could set things up to be doing other things while kbhit() is false, and only call getchc() when kbhit() is true. The hdlchc() routine has the same return value as choose() and choout(), except it may return nchoices to indicate that the choosing session isn’t over yet.

...

1. In your language .MDF file (page 32), use the name of your .DLL file in the language editor command line, as in:

Code Block
        Language Editor:  TESTIT.DLL %s

This one directive can do up to three different things. First it declares that this editor is a .DLL editor (as opposed to an editor that’s an .EXE file or a .BAT file). Second, it specifies TESTIT.DLL as the .DLL that should be loaded in order to run the editor. And third, your language editor handler routine may be able to use it to recognize when text should be edited in your language. When it comes time to edit something, the language editor command will be passed to all editor handler routines, and your editor handler routine will need to decide between “I’m supposed to edit the text,” or “No, some other editor is supposed to edit the text, not me.” More on this later.

...

  1. Create an editor handler routine. A simple example:
Code Block
        int
        tstedt(
        char *command,
        char *txtbuf,
        unsigned sizbuf)
        {
             If (!sameto("TESTIT.DLL",command)) {
                  return(EONOTME);
             }
             return(edit(txtbuf,sizbuf) ? EOSAVE : EONOCHG);
        }

In this example, edit() is your function for editing the text, and it returns 1 if it wants to change the text or 0 if it doesn’t.

...

Your editor handler routine and associated code will need to be in a C source file that includes:

Code Block
        #include "gcomm.h"
        #include "edtoff.h"
  1. Register your editor handler routine. Make a function whose name starts with init__. It gets passed the address of the routine to register editor handler routines, and should be declared EXPORT. The function doesn’t return anything.

For example:

Code Block
        void EXPORT
        init__testit(regrou)
        void (*regrou)(EDTHANDLER *edthdl);
        {
             (*regrou)(tstedt);
        }

This function will get called the first time someone tries to use your editor, so you may want to include some more initialization code here.

...

4. Compile your program using CTPH.BAT, for example:

Code Block
        CTPH TESTIT
  1. Make a linker response file. For example, TESTIT.LNK:
Code Block
%PHARLAP%\bc4\lib\c0phdll     +
%MBBS%\phobj\testit
%MBBS%\testit
nul
plhide phapi cnfimp /Twd /s /n
%MBBS%\dlib\nodef

And use it to make your .DLL file:

Code Block
        LTDLL TESTIT

If you get undefined symbols for Borland Library routines, you may have to find alternatives to using those routines. See page 23 about the perils of linking BCH286.LIB in a .DLL.

...

value=msgscan(filnam,name);
Read a CNF option from an .MSG file

Code Block
char *value; value of option (or NULL=can’t find)
char *filnam; file (include .MSG extension)
char *name; name of option (not including types **S** or **T**)

To read the option from the .MCV file, use the getmsg() and xxxopt() routines, described starting on page 89. It’s usually more convenient to use getmsg() or the xxxopt() routines if you are reading a .MSG file that’s part of the same product release. That is, if your .MSG file and your offline utility are sold and updated as a package.

...

Here’s an example of using these routines to set the values of several CNF options in different .MSG files.

Code Block
        setcnf("GROUP3","MODEM");
        setcnf("BAUD3","19200");
        setcnf("LOCK3","YES");
        setcnf("INIT3","AT&FE0S0=0S2=255X6&R0B1");
        setcnf("SUPCLS","PROSPECT");
        applyem("BBSMAJOR.MSG");
        applyem("BBSSUP.MSG");

When you bring the Major BBS server up again, new .MCV files will automatically be generated by WGSMSX.

...

You can change the value of any type of CNF option with setcnf() and applyem(). But if you change the value of a type T text option, only the language 0 version will be affected.

...

Previous: Major BBS v10: 09 Databases  |  Contents  |  Next: Major BBS v10: 11 More Routines And Variables