[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
The simple SOURCE\CMD\APP1.PRG example provides items (a) [main
window] and (e) [event loop]:
#include "windows.ch"
#define NO_C4WCLASS
#include "commands.ch"
function main()
local oApp
CREATE APPLICATION oApp ;
TITLE "Clip-4-Win Makes Windows Apps E-A-S-Y!"
return nil
which conveniently highlights the essentials.
The event loop has been standardised, and tucked away for now
- we'll look at it in a while.
From your CLIP4WIN directory, you can build the above like
this:
CD SOURCE\CMD
C4WBUILD APP1
You can run APP1.EXE if you want.
Clip-4-Win can be used to build OO applications very easily,
and most of the commands are also available in non-OO
(function) and OO versions. For example, if you change:
#define NO_C4WCLASS
into:
#include "TopClass.ch"
then it becomes an OO application, because it's the above
#define that controls the commands in COMMANDS.CH. In fact,
if you follow this section and also the OO tutorial section,
you may notice how similar the samples in the SOURCE\CMD and
SOURCE\OO\CMD directories are. (Naturally, they diverge as
the OO samples become less command-oriented.)
In the samples discussed, you'll see quite a number of
commands used to "simplify" things. This is, arguably, an
advantage for a beginner to Windows programming. If you
already know something about programming for Windows, perhaps
in C, you can use very much that approach in Clip-4-Win - but
with Clipper's advantages. There are plenty of sources you
can look at in the SOURCE directory. Sticking with the
Windows API means you're able to use the many books etc. on
Windows and your source should port to VO easily, as it
supports the API. You'll have more marketable skills, too.
Trying to provide "a #command for everything", however, causes
problems. Firstly, you end up with tens of them, each with
optional clause after optional clause after optional clause.
Secondly, you tend to get functions with ridiculous numbers of
parameters, easily 15-20. Apart from being tedious and error-
prone to maintain, such functions are a sure sign that
something important is wrong. This is hardly the way to code
re-use.
Consequently, Clip-4-Win aims to provide sensible #commands -
especially when used with objects. Inheriting classes whose
Init() methods have 15-20, or even 10, parameters just makes
for increased maintenance. Writing yet another long #command
is not very productive, either.
Online resources provided by: http://www.ClipX.Net --- NG 2 HTML conversion by Dave Pearson