User Tools

Site Tools


preprocessor

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Last revisionBoth sides next revision
preprocessor [2018/02/13 17:03] – created wolfgangriedmannpreprocessor [2018/02/13 20:06] wolfgangriedmann
Line 1: Line 1:
 ====== The Preprocessor ====== ====== 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:
 +<code>#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.>)</code>
 +to be used like this:
 +<code>USE "C:\dbf\customer.dbf" VIA "DBFCDX" ALIAS test</code>
 +Source: [[https://www.xsharp.info/forum/public-chit-chat/561-managed-dbf-using-x-language?start=12|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:
 +<code>#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 </code>
 +and to be used like this:
 +<code>PROPERTY x AS INT SET _x NOTIFY CHANGE</code>
 +Source: [[https://www.xsharp.info/forum/pearls/216-snippets-in-vs-2017-rc-some-success?start=5|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|https://www.xsharp.info/help/x-preprocessor-directives.html]]
 +
 +
  
preprocessor.txt · Last modified: 2018/02/14 04:52 by wolfgangriedmann