User Tools

Site Tools


preprocessor

This is an old revision of the document!


The Preprocessor

The preprocessor is an unique feature of the X# compiler. In the Clipper times, the preprocessor was used to implement the commands (they were mapped to function calls), and in the VO times the preprocessor was present, but very few people used it.

Now, in the X# compiler it is again a very powerful tool. It can be used to implement commands for FoxPro compatibility:

#command USE <db>     ;
     [VIA <rdd>]        ;
     [ALIAS <a>]        ;
     [<sh:SHARED>]      ;
     [<ex:EXCLUSIVE>]           ;
     [<ro:READONLY>]            ;
     [<nw:NEW>]         ;
    ;
    => DBUseArea(<.nw.>, <rdd>, <(db)>, <(a)>, iif(<.sh.> .or. <.ex.>, !<.ex.>, FALSE), <.ro.>)

to be used like this:

USE "C:\dbf\customer.dbf" VIA "DBFCDX" ALIAS test

Source: https://www.xsharp.info/forum/public-chit-chat/561-managed-dbf-using-x-language?start=12 - the second message by Chris Pyrgas

But it can also be used to write less code for MVVM ViewModels:

#command PROPERTY <n> AS <t> GETSET <v> NOTIFY CHANGE =>;
PROPERTY <n> AS <t>;;
GET;;
RETURN SELF:<v>;;
END GET;;
SET;;
IF SELF:<v> <> VALUE;;
SELF:<v> := VALUE;;
SELF:NotifyPropertyChanged(<"n">);;
ENDIF;;
END SET;;
END PROPERTY 

and to be used like this:

PROPERTY x AS INT SET _x NOTIFY CHANGE

Source: https://www.xsharp.info/forum/pearls/216-snippets-in-vs-2017-rc-some-success?start=5 - first and second message by Johan Nel.

You can find the full documentation here:

https://www.xsharp.info/help/x-preprocessor-directives.html

preprocessor.1518552375.txt.gz · Last modified: 2018/02/13 20:06 by wolfgangriedmann