The CodeShop

Clipper

How to make a Clipper Screensaver

The kind of thing you need to do is as follows:

Make a copy of \clipper5\include\std.ch as mystd.ch

Edit mystd.ch and add the line:

    #translate inkey(0) => scrsaver()
Create a scrsaver() function that does whatever it should, but exits on INKEY().
e.g.
FUNCTION scrsaver
    LOCAL oldscr:=SAVESCREEN(0,0,24,79),i:=0,key:=0
    CLEAR
    DO WHILE key=0
        @ 0,i SAY CHR(0)
        key:=INKEY(1)
        @ 0,i SAY " "
        IF ++i>79
            i:=0
        ENDIF
    ENDDO
RETURN key
Compile this as normal.

Re-compile all your source code with a /umystd.ch switch

Compile getsys.prg with a /umystd.ch switch and explicitly link it into your application.

This will catch all uses of INKEY(0), including the GET system. If you want to trap the MENU TO system, then you will need to write a replacement system and add it into mystd.ch as

#command SET MESSAGE TO         => ss_setmess()

#command SET MESSAGE TO            => ss_setmess(0)

#command @ ,  PROMPT  [MESSAGE ]                 ;
                                 => ss_prompt(,,,)

#command MENU TO                => :=ss_menu()
where ss_setmess(), ss_prompt() and ss_menu() are your new functions.

Click here for my versions of these three functions. You are free to use these, provided you leave my copyright header in the code. Of course, you may need to comment out some bits that require the rest of my library to work, but that's part of the joy of using someone else's code, isn't it?

C++ (Usually MFC)

No code so far, but I've a screensaver you may like. It's written for Win 3.1, but does work with W95. It's called the Physicist's Desk because You need the .scr and .ini files in your Windows directory. You set up the .ini with the text and .bmp files you want to display and that's it.

Have fun.

A CRecordset SQL count(*) class

Sometimes all you want to know is how many records match certain criteria, without returning them all. In the normal CRecordset classes, you have to get all the records and then see how many there are (usually by scrolling through them all first). In SQL, you use "select count(*) where...". This class does the SQL for you in a CRecordset wrapper. It also helps you see what's going on inside and therefore how you might tweak it further. (I put it on Code Project as they have a much larger audience!)

Frequently Asked Questions

Not a full list, but a gradually-incresing set of questions I've answered, normally on UseNet.

Why does my Access MBD keep on growing?

Access (in common with other RDBMs) doesn't do garbage collection unless told to (via it's "Compact & Repair" option). So each deleted record is still hogging space.

If you're going to do a lot of adding & deleting, then you can add an extra field to your table which indicates whether the record is "alive" or "dead". Then, instead of deleting, you set the flag to "dead". When adding, you find a "dead" record & overwrite it. If there isn't a "dead" record, then add a new one.


What does "Too few parameters" mean?

The "Too few parameters. Expected 1." error means that there is one term (normally a field name) in your query that's not in your table.

When you do CRecSet->Open(), it will create a SELECT query using all the field names in DoFieldExchange or DoBulkFieldExchange. If you've changed a field name in the database but not in here, that would cause this error message.


When I try to add a new class, VC claims the files already exist

If the files are already there, why are you trying to add a new class via ClassWizard? If it's because something went wrong the first time (which is what happened to me), then you need to delete the files (from explorer) and then remove the files from your project (by highlighting the file in file view and pressing "Del").

If you then add the class via classwizard, it should work.


How can I delete all records from a CRecordset?

There are two ways:

  1. write a loop to step through the recordset, deleting each one in turn
  2. write an sql statement and use ExecuteSQL() to run it

To use method 2, you need (or maybe just best) to have created your CDatabase and attached your CRecordset to it.

e.g. for method 2:

sql="delete from map";
TRY
{
        db.ExecuteSQL(sql);
}

CATCH(CDBException, e)
{
        AfxMessageBox("Failed to clear map: "+e->m_strError);
}

END_CATCH

Why might some of my classes dissappear from the Class View?

Not sure about VS2005, but in VS6 this was a common problem. If you delete the *.clw file (or rename it - much safer!), then when you run Class Wizard it will prompt you for all the classes in your project.

Other files that get corrupted and can safely be deleted are *.aps, *.ncb and *.opt
Back to the home page