-
-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathFoxProCmd.xh
More file actions
750 lines (615 loc) · 40 KB
/
Copy pathFoxProCmd.xh
File metadata and controls
750 lines (615 loc) · 40 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
///////////////////////////////////////////////////////////////////////////
// FoxProCmd.xh
//
// XSharp FoxPro Preprocessor Directives
//
// Copyright (c) XSharp BV. All Rights Reserved. Licensed under the Apache License, Version 2.0.
// See License.txt in the project root for license information.
//
// Caution: do not modify this file. It will be overwritten during product updates
//
// Note we have added support for FIELDS LIKE and FIELDS EXCEPT for most DB Commands
// even for commands that do not support that in FoxPro
//
#ifndef FOXPROCMD_XH
#define FOXPROCMD_XH
// These keywords are now defined in the compiler. But we still need them here to remove same line comments
#xcommand ENDDEFINE <*any*> => ENDDEFINE
#xcommand ENDFOR <*any*] => ENDFOR
#xcommand ENDFUNC <*any*> => ENDFUNC
#xcommand ENDPROC <*any*> => ENDPROC
#xcommand ENDSCAN <*any*> => ENDSCAN
#xcommand ENDTRY <*any*> => ENDTRY
#xcommand ENDWITH <*any*> => ENDWITH
#xcommand STORE <value> TO ARRAY <VAR> => __FoxFillArray( <VAR>, <value> )
// FoxPro specific TEXT rules
// These rules store the settings in the runtime state and __TextEnd is responsible
// for the textmerge (when needed) and for applying the noshow, flags and pretext
// __TextLine only adds a CRLF at this moment. That is why the Text Delimiter is empty in the #text directive
// __TextEnd has to be marked with NeedsAccessToLocals() to make sure it can
// expand LOCAL variables.
#xcommand TEXT TO <varname> [<tm:TEXTMERGE>] [<noshow:NOSHOW>] [FLAGS <flags>] [PRETEXT <expression> ] ;
=> __TextInit( iif(<.tm.>,TRUE, SetTextMerge()), <.noshow.>, iif(<.flags.>, <!flags!>, 0), <!expression!> ) ;;
#if <.tm.> .and. ! __MEMVAR__ ;;
#error TEXTMERGE support requires the /memvar compiler option ;;
#endif ;;
#text := <varname>, ,__TextLine , __TextEnd
#xcommand TEXT TO <varname> ADDITIVE [<tm:TEXTMERGE>] [<noshow:NOSHOW>] [FLAGS <flags>] [PRETEXT <expression> ] ;
=> __TextInit(iif(<.tm.>,TRUE, SetTextMerge()), <.noshow.>, iif(<.flags.>, <!flags!>, 0), <!expression!> ) ;;
#if <.tm.> .and. ! __MEMVAR__ ;;
#error TEXTMERGE support requires the /memvar compiler option ;;
#endif ;;
#text += <varname>, ,__TextLine , __TextEnd
// todo
// SET TEXTMERGE [TO [FileName] MEMVAR VarName [ADDITIVE]]
// We ignore the SET BELL TO <file> command since we do not support WAV
#command SET BELL TO [<*any*>] =>
// Rules for FIELD matches that are used in several other commands
// Note that the FoxPro fields rule is different from the generic rule in dbcmd.xh because of the memo clause
// and because we also have to support LIKE and EXCEPT
// Fields List
#translate __FOXFIELDS__ <f1> [,<fn> ] [<memo: MEMO>] => ;
__FOXLIST__ __DbFieldList( {<(f1)>[, <(fn)> ]}, <.memo.>)
// FIELDS LIKE and optionally EXCEPT
#translate __FOXFIELDS__ LIKE <%include%> [EXCEPT <%exclude%>] [<memo: MEMO>] => ;
__FOXWILD__ __DbFieldWild(#<include>, #<exclude>, <.memo.>)
// FIELDS EXCEPT
#translate __FOXFIELDS__ EXCEPT <%exclude%> [<memo: MEMO>] => ;
__FOXWILD__ __DbFieldWild(/*include*/, #<exclude>, <.memo.>)
// FIELDS EXCEPT .. LIKE clause is reversed
#translate __FOXFIELDS__ EXCEPT <%exclude%> LIKE <%include%> => ;
__FOXFIELDS__ LIKE <include> EXCEPT <exclude>
// scatter to array
#command SCATTER [__FOXLIST__ <fldlist>] [__FOXWILD__ <fldwild> ] [<blank: BLANK>] [<memo: MEMO>] TO <arrayName> ;
=> <arrayName> := __ScatterArray( <arrayName>, iif( <.fldlist.>, <!fldlist!>, <!fldwild!>), <.blank.>, <.memo.> )
// Note that the objectName parameter is passed as a string because objectName may not have been created yet (when it is a MEMVAR).
// For SCATTER NAME to work with LOCALS and the ADDITIVE clause we have marked __ScatterObject with the
// attribute that it needs access to locals
#command SCATTER [__FOXLIST__ <fldlist>] [__FOXWILD__ <fldwild> ] [<blank: BLANK>] NAME <objectName> [<add: ADDITIVE>] [<memo: MEMO>] ;
=> <objectName> := __ScatterObject( IIF( <.fldlist.>, <!fldlist!>, <!fldwild!>), <.blank.> , <"objectName">, <.add.>, <.memo.>)
// SCATTER MemVar must be last. DO NOT USE TO MEMBER !
#command SCATTER [__FOXLIST__ <fldlist>] [__FOXWILD__ <fldwild> ] [<blank: BLANK>] [<memo: MEMO>] MEMVAR ;
=> __ScatterMemVar( IIF( <.fldlist.>, <!fldlist!>, <!fldwild!>), <.blank.>, <.memo.> )
#command GATHER FROM <arrayName> [__FOXLIST__ <fldlist>] [__FOXWILD__ <fldwild> ] [<memo: MEMO>] ;
=> __GatherArray(<arrayName>, IIF( <.fldlist.>, <!fldlist!>, <!fldwild!>), <.memo.> )
#command GATHER NAME <objectName> [__FOXLIST__ <fldlist>] [__FOXWILD__ <fldwild> ] [<memo: MEMO>] ;
=> __GatherObject(<objectName>, IIF( <.fldlist.>, <!fldlist!>, <!fldwild!>), <.memo.> )
//GATHER MemVar must be last, otherwise the compiler thinks that MEMVAR is the name of an array
#command GATHER MEMVAR [__FOXLIST__ <fldlist>] [__FOXWILD__ <fldwild> ] [<memo: MEMO>] ;
=> __GatherMemVar( IIF( <.fldlist.>, <!fldlist!>, <!fldwild!>), <.memo.> )
// Variations of the database commands for the FoxPro Dialect
#command CLOSE IN <(a)> => (<(a)>)->(DbCloseArea())
#command USE IN <(area)> => (<(area)>)->(DbCloseArea())
#command USE <(db)> ;
[IN <(area)>] ;
[<on: ONLINE> ] ;
[<ad: ADMIN>] ;
[<ag: AGAIN>] ;
[<nr: NOREQUERY> <nSession>] ;
[<nd: NODATA> ] ;
[INDEX <(index1)> [, <(indexn)>]] ;
[<ord: ORDER> [<tag: tag>] <ordername> [OF <bagname>]] ;
[<asc: ASCENDING>] ;
[<desc: DESCENDING>] ;
[ALIAS <ALIAS>] ;
[<ex: EXCLUSIVE>] ;
[<sh: SHARED>] ;
[<ro: NOUPDATE>] ;
[CONNSTRING <connection> ] ;
=> ;
; DbUseAreaFox( <(area)>, <(db)>, <(ALIAS)>, iif(<.sh.> .or. <.ex.>, !<.ex.>, NIL), <.ro.>, ;
<.on.>, <.ad.>, <.ag.>, <.nd.>, <.nr.>, <nSession>, <connection>) ;
[; DbSetIndex( <(index1)> )] [; DbSetIndex( <(indexn)> )] ;
[; IIF( <.ord.>, OrdSetFocus( <(ordername)>, <(bagname)>) , NIL )] ;
[; IIF( <.desc.>, OrdDescend(<(ordername)>, <(bagname)>, <.desc.>) , NIL )] ;
[; IIF( <.asc.> , OrdDescend(<(ordername)>, <(bagname)>, <.desc.>) , NIL )]
#command INDEX ON <(key)> ;
[tag <ORDER>] ;
[<To:TO,OF> <file>] ;
[FOR <fo>] ;
[<ALL:ALL>] ;
[WHILE <wh>] ;
[NEXT <nx>] ;
[RECORD <rec>] ;
[<rs:REST>] ;
[<u:UNIQUE>] ;
[<asd:ASCENDING>] ;
[<dsd:DESCENDING>] ;
[<lCur:USECURRENT>] ;
[<lAdd:ADDITIVE>] ;
[<lCus:CUSTOM>] ;
[<lNop:NOOPTIMIZE>] ;
[Binary <bin>] ;
[COLLATE <coll>] ;
[<cmp:COMPACT>] ;
[<cand:CANDIDATE>] ;
=> OrdCondSet( <"fo">, , [<.all.>], <{wh}>, NIL, NIL, ;
RecNo(), <nx>, <rec>,[<.rs.>],[<.dsd.>],<.lAdd.>, ;
[<.lCur.>], [<.lCus.>], [<.lNop.>] , ;
[<.bin.>], [<"coll">], [<.cand.>], [<.cmp.>] ) ;; ;
OrdCreate(<(file)>,<(ORDER)>,<(key)>,,IIF(<.u.>,.T., NIL))
#command DIR <*any*> => __VfpDir( <"any"> )
#command DIRECTORY <*any*> => __VfpDir( <"any"> )
#command CLEAR => __VfpUnsupported(<"udc">)
#command DIR => __VfpDir( "" )
#command DIRECTORY => __VfpDir( "" )
// WAIT
#xcommand WAIT <msg> [<win:WINDOW> [AT <nRow>, <nCol>]] [<now:NOWAIT>] [<nclr:NOCLEAR>] [TIMEOUT <secs>] ;
=> __VfpWait(<msg>, <.win.>, <!nRow!>, <!nCol!>, <.now.>, <.nclr.>, <!secs!>)
#xcommand WAIT <msg> TO <v> [<win:WINDOW> [AT <nRow>, <nCol>]] [<now:NOWAIT>] [<nclr:NOCLEAR>] [TIMEOUT <secs>] ;
=> <v> := __VfpWait(<msg>, <.win.>, <!nRow!>, <!nCol!>, <.now.>, <.nclr.>, <!secs!>)
#xcommand WAIT [<win:WINDOW> [AT <nRow>, <nCol>]] [<now:NOWAIT>] [<nclr:NOCLEAR>] [TIMEOUT <secs>] ;
=> __VfpWait(NIL, <.win.>, <!nRow!>, <!nCol!>, <.now.>, <.nclr.>, <!secs!>)
#xcommand WAIT TO <v> [<win:WINDOW> [AT <nRow>, <nCol>]] [<now:NOWAIT>] [<nclr:NOCLEAR>] [TIMEOUT <secs>] ;
=> <v> := __VfpWait(NIL, <.win.>, <!nRow!>, <!nCol!>, <.now.>, <.nclr.>, <!secs!>)
#xcommand WAIT CLEAR => __VfpWaitClear()
// Commands with IN clause, commands without are defined in DBCMD.XH
#command REINDEX IN <(a)> => (<(a)>) -> (OrdListRebuild())
#command SET ORDER TO <n> IN <(a)> => (<(a)>) -> (DbSetOrder( <n> )) // No overload with area param
#command SET ORDER TO IN <(a)> => (<(a)>) -> (DbSetOrder(0)) // No overload with area param
#command APPEND BLANK IN <(a)> => (<(a)>) -> (DbAppend())
#command PACK IN <(a)> => (<(a)>) -> (DbPack())
#command ZAP IN <(a)> => (<(a)>) -> (DbZap())
#command COMMIT IN <(a)> => (<(a)>) -> (DbCommit())
#command UNLOCK [RECORD <rcd>] IN <(a)> => (<(a)>) -> (DbUnLock(<rcd>))
#command GOTO <n> IN <(a)> => (<a>)->(DbGoto(<n>))
#command GO [RECORD] <n> IN <(a)> => (<a>)->(DbGoto(<n>))
#command GOTO TOP IN <(a)> => (<a>)->(DbGoTop())
#command GO TOP IN <(a)> => (<a>)->(DbGoTop())
#command GOTO BOTTOM IN <(a)> => (<a>)->(DbGoBottom())
#command GO BOTTOM IN <(a)> => (<a>)->(DbGoBottom())
#command SKIP IN <(a)> => (<a>)->(DbSkip(1))
#command SKIP <n> IN <(a)> => (<a>)->(DbSkip(<n>))
#command SET FILTER TO IN <(a)> => (<(a)>) -> (DbClearFilter())
#command SET FILTER TO <xpr> IN <(a)> => (<(a)>) -> (DbSetFilter( <{xpr}>, <"xpr"> ))
#command SET FILTER TO <x:&> IN <a> ;
=> IF ( Empty(<(x)>) ) ;
; (<(a)>) -> (DbClearFilter()) ;
; ELSE ;
; (<(a)>) -> (DbSetFilter( <{x}>, <(x)> )) ;
; END
// Multiple record operations with IN Clause. Commands without are defined in DBCMD.XH
#command REPLACE <(f1)> WITH <x1> [, <(fn)> WITH <xn>] ;
[FOR <lfor>] ;
[WHILE <lwhile>] ;
[NEXT <nnext>] ;
[RECORD <rec>] ;
[<rest:REST>] ;
[<noopt: NOOPTIMIZE>] ;
[ALL] ;
IN <(a)> ;
;
=> (<(a)>)->(DbEval( ;
{||DbAutoLock(), __FieldSet(<(f1)>,<x1>) [, __FieldSet(<(fn)>, <xn>)], DbAutoUnLock()}, ;
<{lfor}>, <{lwhile}>, <nnext>, <rec>, <.rest.>, <.noopt.>;
))
// This variant moves the ALL clause to the end. This is needed because the WITH clause is declared as non optional
#command REPLACE <*clauses*> ALL <*moreclauses*> => REPLACE <clauses> <moreclauses> ALL
#command COPY MEMO <field> TO <(file)> <add:ADDITIVE> [AS <nCP>] ;
=> DbCopyMemo( <"field">, <(file)>, <ADD>[, <nCP>] )
// Scoped REPLACE — without IN clause
// Note: no nested optional ADDITIVE inside the repeated clause: the preprocessor
// drops the whole output repetition when the nested marker has no matches
#command REPLACE <(f1)> WITH <x1> [, <(fn)> WITH <xn>] ;
[FOR <lfor>] [WHILE <lwhile>] [NEXT <nnext>] [RECORD <rec>] ;
[<REST:REST>] [<noopt:NOOPTIMIZE>] [all] ;
=> DbEval( ;
{|| DbAutoLock(), ;
__FieldSet(<(f1)>, <x1>) ;
[, __FieldSet(<(fn)>, <xn>)], ;
DbAutoUnLock() }, ;
<{lfor}>, <{lwhile}>, <nnext>, <rec>, <.rest.>, <.noopt.> ;
)
// Scoped REPLACE, single field with ADDITIVE — without IN clause
#command REPLACE <(f1)> WITH <x1> ADDITIVE ;
[FOR <lfor>] [WHILE <lwhile>] [NEXT <nnext>] [RECORD <rec>] ;
[<REST:REST>] [<noopt:NOOPTIMIZE>] [ALL] ;
=> DbEval( ;
{|| DbAutoLock(), ;
__FieldSetAdd(<(f1)>, <x1>, .T.), ;
DbAutoUnLock() }, ;
<{lfor}>, <{lwhile}>, <nnext>, <rec>, <.rest.>, <.noopt.> ;
)
// Single record REPLACE — no scope clauses: current record only (VFP default)
// Note: no nested optional ADDITIVE inside the repeated clause: the preprocessor
// drops the whole output repetition when the nested marker has no matches
#command REPLACE <(f1)> WITH <v1> [, <(fn)> WITH <vN>] ;
=> DbAutoLock(); __FieldSet(<(f1)>, <v1>) ;
[; __FieldSet(<(fn)>, <vN>)]; DbAutoUnLock()
// Single record, single field with ADDITIVE — current record only
#command REPLACE <(f1)> WITH <v1> ADDITIVE ;
=> DbAutoLock(); __FieldSetAdd(<(f1)>, <v1>, .T.); DbAutoUnLock()
// Scoped REPLACE IN workarea
#command REPLACE <(f1)> WITH <x1> [, <(fn)> WITH <xn>] ;
[FOR <lfor>] [WHILE <lwhile>] [NEXT <nnext>] [RECORD <rec>] ;
[<REST:REST>] IN <(a)> [<noopt:NOOPTIMIZE>] [ALL] ;
=> (<(a)>)->(DbEval( ;
{|| DbAutoLock(), ;
__FieldSet(<(f1)>, <x1>) ;
[, __FieldSet(<(fn)>, <xn>)], ;
DbAutoUnLock() }, ;
<{lfor}>, <{lwhile}>, <nnext>, <rec>, <.rest.>, <.noopt.> ;
))
// Scoped REPLACE, single field with ADDITIVE, IN workarea
#command REPLACE <(f1)> WITH <x1> ADDITIVE ;
[FOR <lfor>] [WHILE <lwhile>] [NEXT <nnext>] [RECORD <rec>] ;
[<REST:REST>] IN <(a)> [<noopt:NOOPTIMIZE>] [all] ;
=> (<(a)>)->(DbEval( ;
{|| DbAutoLock(), ;
__FieldSetAdd(<(f1)>, <x1>, .T.), ;
DbAutoUnLock() }, ;
<{lfor}>, <{lwhile}>, <nnext>, <rec>, <.rest.>, <.noopt.> ;
))
#command DELETE ;
[FOR <lfor>] ;
[WHILE <lwhile>] ;
[NEXT <nnext>] ;
[RECORD <rec>] ;
[<rest:REST>] ;
[<noopt: NOOPTIMIZE>] ;
[ALL] ;
IN <(a)> ;
;
=> (<(a)>)->(DbEval( ;
{|| __DbDelete()}, ;
<{lfor}>, <{lwhile}>, <nnext>, <rec>, <.rest.>, <.noopt.>;
))
#command RECALL ;
[FOR <lfor>] ;
[WHILE <lwhile>] ;
[NEXT <nnext>] ;
[RECORD <rec>] ;
[<rest:REST>] ;
[<noopt: NOOPTIMIZE>] ;
[ALL] ;
IN <(a)> ;
;
=> BEGIN SCOPE ; VAR __saveDeleted := SetDeleted(); ;
IF RuntimeState.Dialect == XSharpDialect.FoxPro; SetDeleted(FALSE); ENDIF ;;
(<(a)>)->(DbEval( ;
{|| __DbRecall()}, ;
<{lfor}>, <{lwhile}>, <nnext>, <rec>, <.rest.>, <.noopt.>;
)) ;SetDeleted(__saveDeleted); END SCOPE
#command LOCATE ;
[FOR <lfor>] ;
[WHILE <lwhile>] ;
[NEXT <nnext>] ;
[RECORD <rec>] ;
[<rest:REST>] ;
[<noopt: NOOPTIMIZE>] ;
[ALL] ;
IN <(a)> ;
;
=> (<(a)>)->(DbLocate( <{lfor}>, <{lwhile}>, <nnext>, <rec>, <.rest.>, <.noopt.> ))
#command CONTINUE IN <(a)> => (a)->(DbContinue())
// Single record operations with IN Clause
#command REPLACE <(f1)> WITH <v1> [, <(fN)> WITH <vN> ] ;
IN <(a)> ;
=> DbAutoLockArea(<(a)>), __FieldSetWa(<(a)>, <(f1)>,<v1>) [,__FieldSetWa(<(a)>,<(fn)>,<vN>)], DbAutoUnLockArea(<(a)>)
// Single record REPLACE IN workarea — current record only (VFP default)
#command REPLACE <(f1)> WITH <v1> [, <(fn)> WITH <vN>] IN <(a)> ;
=> DbAutoLockArea(<(a)>), ;
(<(a)>)->(__FieldSet(<(f1)>, <v1>) [, __FieldSet(<(fn)>, <vN>)]), ;
DbAutoUnLockArea(<(a)>)
// Single record, single field with ADDITIVE, IN workarea — current record only
#command REPLACE <(f1)> WITH <v1> ADDITIVE IN <(a)> ;
=> DbAutoLockArea(<(a)>), ;
(<(a)>)->(__FieldSetAdd(<(f1)>, <v1>, .T.)), ;
DbAutoUnLockArea(<(a)>)
#command DELETE IN <(a)> => (<(a)>)->(__DbDelete())
#command RECALL IN <(a)> => (a)->(__DbRecall())
// Set Relation command with IN clause
#command SET RELATION ;
[TO <key1> INTO <(alias1)> [, [TO] <keyn> INTO <(aliasn)>]] ;
IN <(a)> ;
[ADDITIVE] ;
=> (<(a)>)->(DbSetRelation( <(alias1)>, <{key1}>, <"key1"> )) ;
[; (<(a)>)->(DbSetRelation( <(aliasn)>, <{keyn}>, <"keyn"> ))]
#command SET RELATION ;
[TO <key1> INTO <(alias1)> [, [TO] <keyn> INTO <(aliasn)>]] ;
IN <(a)> ;
=> (<(a)>)->(DbClearRelation()) ;
; (<(a)>)->(DbSetRelation( <(alias1)>, <{key1}>, <"key1"> )) ;
[; (<(a)>)->(DbSetRelation( <(aliasn)>, <{keyn}>, <"keyn"> ))]
#command SET RELATION TO IN <(a)> ;
=> (<(a)>)->(DbClearRelation())
#command SET INDEX TO => OrdListClear()
#command SET INDEX TO [ <(index1)> [, <(indexN)>]] ;
[<ord: ORDER> [<tag: tag> <ordername> [OF <bagname>]]] ;
[<asc: ASCENDING>] ;
[<desc: DESCENDING>] ;
=> OrdListClear() ;
[; OrdListAdd( <(index1)> )] [; OrdListAdd( <(indexn)> )] ;
[; IIF( <.ord.>, OrdSetFocus( <(ordername)>, <(bagname)>) , NIL )] ;
[; IIF( <.desc.>, OrdDescend(<(ordername)>, <(bagname)>, <.desc.>) , NIL )] ;
[; IIF( <.asc.> , OrdDescend(<(ordername)>, <(bagname)>, <.desc.>) , NIL )]
#command SET INDEX TO [ <(index1)> [, <(indexN)>]] ;
[<ord: ORDER> [<tag: TAG> <ordername> [OF <bagname>]]] ;
[<asc: ASCENDING>] ;
[<desc: DESCENDING>] ;
<add:ADDITIVE> ;
=> [; OrdListAdd( <(index1)> )] [; OrdListAdd( <(indexn)> )] ;
[; IIF( <.ord.>, OrdSetFocus( <(ordername)>, <(bagname)>) , NIL )] ;
[; IIF( <.desc.>, OrdDescend(<(ordername)>, <(bagname)>, <.desc.>) , NIL )] ;
[; IIF( <.asc.> , OrdDescend(<(ordername)>, <(bagname)>, <.desc.>) , NIL )]
#command SEEK <xpr> ;
[<ord: ORDER> [<tag: tag> <ordername> [OF <bagname>]]] ;
[<asc: ASCENDING>] ;
[<desc: DESCENDING>] ;
=> DbSeekFox( <xpr>, IIF( <.ord.>, <(ordername)>, NIL), ;
IIF( <.bagname.>, <(bagname)>, NIL), <.desc.> )
#command SEEK <xpr> ;
[ORDER] [tag] [<ordername> [OF <bagname>]] ;
[<asc: ASCENDING>] [<desc: DESCENDING>] ;
=> DbSeekFox( <xpr>, <(ordername)>,<(bagname)>, <.desc.> )
#command SEEK <xpr> ;
IN <(a)> ;
[ORDER] [tag] [<ordername> [OF <bagname>]] ;
[<asc: ASCENDING>] [<desc: DESCENDING>] ;
=> (<(a)>)->DbSeekFox( <xpr>, <(ordername)>,<(bagname)>, <.desc.> )
// STRUCTURE and EXTENDED keyword can be optional, so it can be anywhere in the command. Same for TO <(file)>
// The normal Copy and COPY STRUCTURE commands are declared later and will take precedence when the keywords are omitted
#command COPY <*clauses*> FIELDS <*moreclauses*> => ;
COPY <clauses> __DBFIELDS__ <moreclauses>
#command COPY [STRUCTURE] [EXTENDED] [TO <(file)>] ;
=> DbCopyXStructFox( <(file)>)
#command COPY [STRUCTURE] [EXTENDED] [TO <(file)>] ;
DATABASE <dbname> [NAME <longtablename>] ;
=> DbCopyXStructFox( <(file)>) ; DbAdd(<(dbname)>, <(longtablename)>)
#command COPY [STRUCTURE] [TO <(file)>] ;
[__FOXLIST__ <fldlist>] ;
[WITH <cdx:CDX, PRODUCTION>] ;
=> DbCopyStructFox( <(file)>, <!fldlist!> , <.cdx.>)
#command COPY [STRUCTURE] [TO <(file)>] ;
[__FOXLIST__ <fldlist>] ;
[WITH <cdx:CDX, PRODUCTION>] ;
DATABASE <dbname> [NAME <longtablename>] ;
=> DbCopyStructFox( <(file)>, <!fldlist!>, <.cdx.> ); DbAdd(<(dbname)>, <(longtablename)>)
#command SORT TO <(file)> ON <fields,...> ;
[<asc:ASCENDING>] ;
[<desc:DESCENDING>] ;
[For <lfor>] ;
[While <lwhile>] ;
[Next <nNext>] ;
[RECORD <rec>] ;
[<rest:REST>] ;
[<noopt: NOOPTIMIZE>] ;
[__FOXLIST__ <fldlist>] ;
[__FOXWILD__ <fldwild> ] ;
[ALL] ;
;
=> DbSortFox( ;
<(file)>, { <(fields)> }, ;
<{lfor}>, <{lwhile}>, <nNext>, <rec>, <.rest.>, <.noopt.> ;
, Iif(<.asc.> .or. <.desc.>, <.desc.>, Nil), ;
Iif( <.fldlist.>, <!fldlist!>, <!fldwild!>) )
#command SCAN ;
[FOR <lfor>] ;
[WHILE <lwhile>] ;
[NEXT <nnext>] ;
[RECORD <rec>] ;
[<rest:REST>] ;
[<noopt: NOOPTIMIZE>] ;
[ALL] ;
;
=> IIF( <.lfor.>, DbLocate( <{lfor}>, <{lwhile}>, <nnext>, <rec>, <.rest.>, <.noopt.> ), ;
DbLocate( {||TRUE}, <{lwhile}>, <nnext>, <rec>, <.rest.>, <.noopt.> ) ); ;
DO WHILE found()
#command END SCAN => DbContinue(); ENDDO
#command ENDSCAN => DbContinue(); ENDDO
#command COPY TO ARRAY <arrayName> ;
[__FOXLIST__ <fldlist>] ;
[__FOXWILD__ <fldwild> ] ;
[FOR <lfor>] ;
[WHILE <lwhile>] ;
[NEXT <nNext>] ;
[RECORD <rec>] ;
[<rest:REST>] ;
[<noopt: NOOPTIMIZE>] ;
[ALL] ;
;
=> <arrayName> := DbCopyToArray( <arrayName>, ;
iif( <.fldlist.>, <!fldlist!>, <!fldwild!>), ;
<{lfor}>, <{lwhile}>, <nnext>, <rec>, <.rest.>, ;
<.noopt.> ;
)
// Todo FoxPro clauses
// Implementation of CSV,SDF,FOXPLUS, FOX2X is implemented. Rest not yet.
#command COPY [TO <(file)> ] ;
[DATABASE <dbname> [NAME <longtablename>]] ;
[[WITH] <cdx: cdx, PRODUCTION> ] ;
[__FOXLIST__ <fldlist>] [__FOXWILD__ <fldwild> ] ;
[FOR <lfor>] ;
[WHILE <lwhile>] ;
[NEXT <nNext>] ;
[RECORD <rec>] ;
[<rest:REST>] ;
[<noopt: NOOPTIMIZE>] ;
[ALL] ;
[TYPE] [<type: FOXPLUS,FOX2X,DIF,MOD,SDF,SYLK,WK1,WKS,WR1,WRK,CSV,XLS,XL5 >] ;
[AS <nCodePage>] ;
=> DbCopyFox( ;
<(file)>, iif( <.type.>,#<type>,"DBF"), ;
iif( <.fldlist.>, <!fldlist!>, <!fldwild!>), ;
<{lfor}>, <{lwhile}>, <nNext>, <rec>, <.rest.>, ;
<nCodePage>, <(dbname)>, <(longtablename)>, ;
<.cdx.>, <.noopt.> ;
)
#command COPY [TO <(file)> ] ;
[__FOXLIST__ <fldlist>] [__FOXWILD__ <fldwild> ] ;
[FOR <lfor>] ;
[WHILE <lwhile>] ;
[NEXT <nNext>] ;
[RECORD <rec>] ;
[<rest:REST>] ;
[<noopt: NOOPTIMIZE>] ;
[ALL] ;
[TYPE] DELIMITED WITH <delim> ;
[WITH CHARACTER <char>] ;
[AS <nCodePage>] ;
;
=> DbCopyDelimFox( ;
<(file)>, <(delim)>,<char>, ;
iif( <.fldlist.>, <!fldlist!>, <!fldwild!>), ;
<{lfor}>, <{lwhile}>, <nNext>, <rec>, <.rest.>, ;
<nCodePage>, <.noopt.> ;
)
#command COPY [TO <(file)> ] ;
[__FOXLIST__ <fldlist>] [__FOXWILD__ <fldwild> ] ;
[FOR <lfor>] ;
[WHILE <lwhile>] ;
[NEXT <nNext>] ;
[RECORD <rec>] ;
[<rest:REST>] ;
[<noopt: NOOPTIMIZE>] ;
[ALL] ;
[TYPE] DELIMITED ;
[WITH <tab: TAB, BLANK> ] ;
[AS <nCodePage>] ;
;
=> DbCopyDelimFox( ;
<(file)>, "\" + #<tab>, /* no char */ , ;
IIF( <.fldlist.>, <!fldlist!>, <!fldwild!>), ;
<{lfor}>, <{lwhile}>, <nNext>, <rec>, <.rest.>, ;
<nCodePage>, <.noopt.> ;
)
#command APPEND [FROM <(file)>] ;
[__FOXLIST__ <fldlist>] ;
[__FOXWILD__ <fldwild> ] ;
[FOR <lfor>] ;
[WHILE <lwhile>] ;
[NEXT <nNext>] ;
[RECORD <rec>] ;
[<rest:REST>] ;
[ALL] ;
[TYPE] DELIMITED WITH <delim> ;
[WITH CHARACTER <char>] ;
;
=> DbAppDelimFox( ;
<(file)>, <(delim)>, <char>, ;
iif( <.fldlist.>, <!fldlist!>, <!fldwild!>), ;
<{lfor}>, <{lwhile}>, <nNext>, ;
<rec>, <.rest.> ;
)
#command APPEND [FROM <(file)>] ;
[__FOXLIST__ <fldlist>] ;
[__FOXWILD__ <fldwild> ] ;
[FOR <lfor>] ;
[WHILE <lwhile>] ;
[NEXT <nNext>] ;
[RECORD <rec>] ;
[<rest:REST>] ;
[ALL] ;
[TYPE] DELIMITED ;
[WITH <tab: TAB, BLANK> ] ;
;
=> DbAppDelimFox( ;
<(file)>, "\" + #<tab>, , ;
iif( <.fldlist.>, <!fldlist!>, <!fldwild!>), ;
<{lfor}>, <{lwhile}>, <nNext>, ;
<rec>, <.rest.> ;
)
#command APPEND [FROM <(file)> ] ;
[__FOXLIST__ <fldlist>] ;
[__FOXWILD__ <fldwild> ] ;
[FOR <lfor>] ;
[WHILE <lwhile>] ;
[NEXT <nNext>] ;
[RECORD <rec>] ;
[<rest:REST>] ;
[ALL] ;
[TYPE] [<type: FOXPLUS,FOX2X,DIF,MOD,SDF,SYLK,WK1,WKS,WR1,WRK,CSV,XLS,XL5,XL8 >] ;
[SHEET <sheet>] ;
[AS <nCodePage>] ;
;
=> DbAppFox( ;
<(file)>, IIF( <.type.>,#<type>,"DBF"), ;
iif( <.fldlist.>, <!fldlist!>, <!fldwild!>), ;
<{lfor}>, <{lwhile}>, <nNext>, ;
<rec>, <.rest.> , ;
<(sheet)>, <nCodePage> ;
)
#command APPEND FROM ARRAY <arrayName> [_DBFIELDLIST_ <fldlist>] ;
[__FOXWILD__ <fldwild> ] ;
[FOR <lfor>] ;
;
=> DbAppendFromArray(<arrayName>, IIF( <.fldlist.>, <!fldlist!>, <!fldwild!>), <{lfor}> )
#command OPEN DATABASE <(db)> ;
[<ex: EXCLUSIVE >] ;
[<sh: SHARED> ] ;
[<ro: NOUPDATE> ] ;
[<val: VALIDATE>] ;
;
=> XSharp.RDD.Dbc.Open( <(db)>, iif(<.sh.> .or. <.ex.>, !<.ex.>, .T.), <.ro.>, <.val.>)
#command SET DATABASE TO [<(db)>] => XSharp.RDD.Dbc.Select( <(db)>)
#command CREATE DATABASE <(db)> => XSharp.RDD.Dbc.Create( <(db)>)
#command DELETE DATABASE <(db)> [<del:DELETETABLES>] [<rec:RECYCLE>] => XSharp.RDD.Dbc.Delete( <(db)>, <.del.>, <.rec.>)
// CLOSE DATABASES [ALL] and CLOSE TABLES [ALL]
// Implemented in XSharp.VFP\Database\DatabaseCommands.prg
#command CLOSE DATABASES [<all:ALL>] => __VFPCloseDatabases( <.all.> )
#command CLOSE TABLES [<all:ALL>] => __VFPCloseTables( <.all.> )
// ADD TABLE TableName [NAME LongTableName]
// Links an existing free .DBF to the currently active database.
// Implemented in XSharp.VFP\Database\DatabaseCommands.prg
// The NAME variant is defined last (tried first) to correctly consume the NAME clause.
#command ADD TABLE <(file)> => __VFPAddTable( <(file)>, "")
#command ADD TABLE <(file)> NAME <(name)> => __VFPAddTable( <(file)>, <(name)>)
// REMOVE TABLE TableName [DELETE] [RECYCLE]
// Unlinks a table from the active database; optionally deletes the .DBF file.
// Implemented in XSharp.VFP\Database\DatabaseCommands.prg
// Precedence: most-specific forms defined last = tried first.
#command REMOVE TABLE <(name)> => __VFPRemoveTable( <(name)>, .F., .F.)
#command REMOVE TABLE <(name)> DELETE => __VFPRemoveTable( <(name)>, .T., .F.)
#command REMOVE TABLE <(name)> RECYCLE => __VFPRemoveTable( <(name)>, .F., .T.)
// RENAME TABLE OldName TO NewName
// Changes the logical name in the DBC; does not rename the physical .DBF.
// Implemented in XSharp.VFP\Database\DatabaseCommands.prg
#command RENAME TABLE <(old)> TO <(new)> => __VFPRenameTable( <(old)>, <(new)>)
// connection commands
#command CREATE CONNECTION <(conn)> ;
[DATASOURCE <(Dsn)>] ;
[USERID <(user)>] ;
[PASSWORD <(pwd)>] ;
[DATABASE <(db)>] =>XSharp.RDD.Dbc.CreateConnection( <(conn)>, <(Dsn)>, <(user)>, <(pwd)>, <(db)>)
#command CREATE CONNECTION <(conn)> ;
CONNSTRING <(CONNSTRING)> =>XSharp.RDD.Dbc.CreateConnection( <(conn)>, <(CONNSTRING)>)
#command DELETE CONNECTION <(conn)> => XSharp.RDD.Dbc.DeleteConnection( <(conn)>)
// Redirect FIELDS clauses to __FOXFIELDS__ rules
#command <cmd:SCATTER,GATHER,COPY,APPEND,SORT> <*clauses*> FIELDS <*moreclauses*> => ;
<cmd> <clauses> __FOXFIELDS__ <moreclauses>
// Unsupported (combinations) of commands
#command <cmd:SCATTER,GATHER,COPY,APPEND,SORT> <*clauses*> __FOXLIST__ <aFields> ;
<*optionalclauses*> <clause:LIKE,EXCEPT> <*otherclause*> => ;
#error You cannot combine Fields List and Wildcards in a command
#command MD <(dir)> => _cmdDirMake (<(dir)>)
#command MKDIR <(dir)> => _cmdDirMake (<(dir)>)
#command CD <(dir)> => _cmdDirChange (<(dir)>)
#command CHDIR <(dir)> => _cmdDirChange (<(dir)>)
#command RD <(dir)> => _cmdDirRemove (<(dir)>)
#command RMDIR <(dir)> => _cmdDirRemove (<(dir)>)
// CAST AS Expression
// types in the order of the FoxPro docs!
#translate CAST ( <expression> AS <type:W,C,Y,D,T,B,F,G,I,L,M,N,Q,V>) => __FoxCast(<expression>,<(type)>, -1, -1)
#translate CAST ( <expression> AS <type:W,C,Y,D,T,B,F,G,I,L,M,N,Q,V>(<width> ) ) => __FoxCast(<expression>,<(type)>, <width>,-1)
#translate CAST ( <expression> AS <type:W,C,Y,D,T,B,F,G,I,L,M,N,Q,V>(<width> ,<dec>) ) => __FoxCast(<expression>,<(type)>, <width>,<dec>)
#command LABEL <*any*> => __VfpUnsupported(<"udc">)
#command CREATE <cmd:CLASS, CLASSLIB, COLOR, CONNECTION, FORM, LABEL, MENU, PROJECT, QUERY, REPORT, SCREEN, STRUCTURE, TRIGGER> <*any*> ;
=> __VfpUnsupported(<"udc">)
// supported CREATE commands in FoxProSql.xh
// CREATE CURSOR
// CREATE DATABASE
// CREATE TABLE
// CREATE [SQL] VIEW
#command MODIFY <cmd:COMMAND, CLASS, DATABASE, CONNECTION, FILE, FORM, GENERAL, LABEL, MEMO, MENU, PROCEDURE, PROJECT, QUERY, REPORT, SCREEN, STRUCTURE, WINDOW> <*any*> ;
=> __VfpUnsupported(<"udc">)
#ifndef NOASSERT
#command ASSERT <expression> [MESSAGE <cMessageText>] ;
=> __FoxAssert( <expression> , <"expression">, <cMessageText> )
#endif
#translate VARTYPE(<v>) => __VfpVarType( {|| <v> } )
#translate VARTYPE(<v>,<1>) => __VfpVarType( {|| <v> }, <1> )
#include "FoxProSql.xh"
#command CLEAR <*any*> => __VfpUnsupported(<"udc">)
#command RELEASE <cmd:BAR,CLASSLIB,LIBRARY,MODULE,MENUS,PAD,POPUPS,PROCEDURE,WINDOWS> [<*any*>] => __VfpUnsupported(<"udc">)
#endif
// EOF