-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadvpl.code-snippets
845 lines (844 loc) · 24.5 KB
/
advpl.code-snippets
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
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
{
"GDFieldPut": {
"prefix": "GDFieldPut",
"body": [
"GDFieldPut(\"${1:/*cCampo*/}\", ${2:/*xConteudo*/})"
],
"description": "GDFieldPut - Insere um valor em um campo do modelo"
},
"GDFieldGet": {
"prefix": "GDFieldGet",
"body": [
"GDFieldGet(\"${1:/*cCampo*/}\")"
],
"description": "GDFieldGet - Retorna o valor de um campo do modelo"
},
"FwExecStatement":{
"prefix": "FwExecStatement - Query",
"description": "Monta uma query ",
"body": [
"\tLocal cQuery as character",
"\tLocal oQuery as object ",
"\tLocal nRecno as numeric",
"\t",
"\tcQuery := \"SELECT R_E_C_N_O_ RECNO \"",
"\tcQuery += \"FROM \"+RetSqlName(\"${table}\")+\" ${table} \"",
"\tcQuery += \"WHERE ${table}.D_E_L_E_T_ = '' \"",
"\tcQuery += \"AND ${table}_FILIAL = ? \"",
"\tcQuery += \"AND ${table}_ID = ? \"",
"\t",
"\toQuery := FwExecStatement():New(cQuery)",
"\toQuery:SetString(1, FWxFilial(\"${table}\"))",
"\toQuery:SetString(2,/*PESQUISA*/)",
"\tcAliasTMP := oQuery:OpenAlias()",
"\t",
"\toQuery:Destroy()",
"\toQuery := NIL",
"\tFreeObj(oQuery)",
]
},
"FWExecScalar":{
"prefix": "FWExecScalar - RECNO",
"description": "Procura um determinado RECNO na base de dados conforme filtros que podem ser informados",
"body": [
"\tLocal cQuery as character",
"\tLocal oQuery as object ",
"\tLocal nRecno as numeric",
"\t",
"\tcQuery := \"SELECT R_E_C_N_O_ RECNO \"",
"\tcQuery += \"FROM \"+RetSqlName(\"${table}\")+\" ${table} \"",
"\tcQuery += \"WHERE ${table}.D_E_L_E_T_ = '' \"",
"\tcQuery += \"AND ${table}_FILIAL = ? \"",
"\tcQuery += \"AND ${table}_ID = ? \"",
"\t",
"\toQuery := FwExecStatement():New(cQuery)",
"\toQuery:SetString(1, FWxFilial(\"${table}\"))",
"\toQuery:SetString(2,/*PESQUISA*/)",
"\tnRecno := oQuery:ExecScalar(\"RECNO\")",
"\t",
"\toQuery:Destroy()",
"\toQuery := NIL",
"\tFreeObj(oQuery)",
]
},
"MVC Protheus Modelo 2": {
"prefix": "MVC Modelo 2",
"body": [
"#Include \"Protheus.ch\"",
"#Include \"FWMVCDEF.ch\"",
"",
"/*/{Protheus.doc} ${function}",
"${description}",
"${table}",
"${campo_identificado_unico}",
"@author Charles Reitz",
"@since $CURRENT_DATE/$CURRENT_MONTH/$CURRENT_YEAR",
"/*/",
"User Function ${function}()",
"\tLocal oBrowse",
"",
"",
"\toBrowse := FWMBrowse():New()",
"\toBrowse:SetAlias('${table}')",
"\toBrowse:SetMenuDef(\"${function}\")",
"\t//oBrowse:AddLegend(\"${table}_MSBLQL == '2' \",\"GREEN\",\"Ativo\")",
"\t//oBrowse:AddLegend( \"${table}_MSBLQL == '1' \",\"RED\",\"Inativo\")",
"\toBrowse:SetDescription(\"${description}\")",
"\toBrowse:Activate()",
"",
"Return NIL",
"",
"/*/{Protheus.doc} MenuDef",
"",
"Menus",
"",
"/*/",
"Static Function MenuDef()",
"\tLocal aRotina := {}",
"",
"\tADD OPTION aRotina TITLE \"Visualizar\" ACTION \"VIEWDEF.U_${function}\" OPERATION 2 ACCESS 0",
"\tADD OPTION aRotina TITLE \"Incluir\" ACTION \"VIEWDEF.U_${function}\" OPERATION 3 ACCESS 0",
"\tADD OPTION aRotina TITLE \"Alterar\" ACTION \"VIEWDEF.U_${function}\" OPERATION 4 ACCESS 0",
"\tADD OPTION aRotina TITLE \"Excluir\" ACTION \"VIEWDEF.U_${function}\" OPERATION 5 ACCESS 0",
"\tADD OPTION aRotina TITLE \"Imprimir\" ACTION \"VIEWDEF.U_${function}\" OPERATION 8 ACCESS 0",
"\tADD OPTION aRotina TITLE \"Copiar\" ACTION \"VIEWDEF.U_${function}\" OPERATION 9 ACCESS 0",
"Return aRotina",
"",
"",
"/*/{Protheus.doc} ModelDef",
"",
"Modelo",
"",
"/*/",
"Static Function ModelDef()",
"\tLocal oStruct \t:= \tFWFormStruct( 1,\"${table}\" ,{|a| cCampo:= a, aScan({\"${table}_FILIAL\",\"${campo_identificado_unico}\"}, {|x| x == Alltrim(cCampo) }) > 0, /*lViewUsado*/ )",
"\tLocal oStructGrid \t:= \tFWFormStruct( 1, '${table}', {|a| cCampo:= a, aScan({\"${table}_FILIAL\",\"${campo_identificado_unico}\"}, {|x| x == Alltrim(cCampo) }) == 0 /*bAvalCampo*/, /*lViewUsado*/ )",
"\tLocal oModel \t:= \tMPFormModel():New('${function}', /*bPreValidacao*/, {|oModel| ValTudoOK(oModel)} /*bPosValidacao*/, {|oModel| SaveModel(oModel)} /*bCommit*/,/*bCancel*/ )",
"",
"\toModel:AddFields( '${table}MASTER', /*cOwner*/, oStruct, /*bPreValidacao*/, /*bPosValidacao*/, /*bCarga*/ )",
"\toModel:AddGrid( '${table}DETAILS','${table}MASTER', oStructGrid, /*bPreValidacao*/, /*bPosValidacao*/,/*bCarga*/ )",
"\t//oModel:SetDescription( \"${description}\" )",
"",
"\taRelation := { {\"${table}_FILIAL\",\"FWXFilial('${table}')\"}, {\"${campo_identificado_unico}\",\"${campo_identificado_unico}\"} }",
"\toModel:SetRelation(\"${table}DETAILS\",aRelation,${table}->(IndexKey(1)))",
"\t",
"\t//aUnique := {\"${campo_identificado_unico}\"}",
"\t//oModel:GetModel( '${table}DETAILS' ):SetUniqueLine(aUnique)",
"\toModel:GetModel( '${table}DETAILS' ):SetDelAllLine(.T.)",
"",
"\taPrimary := {\"${table}_FILIAL\",\"${campo_identificado_unico}\",\"${campo_identificado_unico}\"}",
"\toModel:SetPrimaryKey(aPrimary)",
"",
"Return oModel",
"",
"",
"/*/{Protheus.doc} ViewDef",
"",
"ViewDef",
"",
"/*/",
"Static Function ViewDef()",
"\tLocal oModel \t:=\t ModelDef()",
"\tLocal oStruct \t:= \tFWFormStruct( 2, '${table}' ,{|a| cCampo:= a, aScan({\"${table}_FILIAL\",\"${campo_identificado_unico}\"}, {|x| x == Alltrim(cCampo) }) > 0)",
"\tLocal oStructGrid \t:= \tFWFormStruct( 2, '${table}',{|a| cCampo:= a, aScan({\"${table}_FILIAL\",\"${campo_identificado_unico}\"}, {|x| x == Alltrim(cCampo) }) == 0 /*, { |cCampo| Alltrim(cCampo) }*/ )",
"\tLocal oView \t:= \tFWFormView():New()",
"",
"\toView:SetModel( oModel )",
"\toView:AddField( 'VIEW_CABECALHO', oStruct, '${table}MASTER' )",
"\toView:AddGrid( 'VIEW_GRID', oStructGrid, '${table}DETAILS' )",
"",
"\toView:CreateHorizontalBox( 'SUPERIOR',10 )",
"\toView:CreateHorizontalBox( 'INFERIOR',90 )",
"",
"\toView:SetOwnerView( 'VIEW_CABECALHO', 'SUPERIOR' )",
"\toView:SetOwnerView( 'VIEW_GRID', 'INFERIOR' )",
"",
"Return oView",
"",
"/*/{Protheus.doc} SaveModel",
"",
"SaveModel - Salva os dados na transação",
"Nessa função não deve possuir mensagem que dependem de ação do usuário pois vai estar dentro de uma transação do banco de dados",
"Caso ficar muito tempo parado pode gerar lock",
"",
"/*/",
"Static Function SaveModel(oModel)",
"\tLocal nOperation\t:= oModel:GetOperation()",
"\tLocal lRet\t:= .F.",
"",
"\tBegin Transaction",
"",
"\t\tIf nOperation == MODEL_OPERATION_DELETE",
"\t\t\t//Alguma validação na exclusão do registro",
"\t\tElseIf nOperation == MODEL_OPERATION_INSERT",
"\t\t\t//Alguma validação na inclusão do registro",
"\t\tElseIf nOperation == MODEL_OPERATION_UPDATE",
"\t\t\t//Alguma validação na atualização do registro",
"\t\tEndif",
"",
"\t\tlRet := FwFormCommit( oModel )",
"",
"\t\tIf !lRet",
"\t\t\tDISARMTRANSACTION()",
"\t\t\tBreak",
"\t\tEndIf",
"",
"\tEnd Transaction",
"",
"Return lRet",
"/*/{Protheus.doc} ValTudoOK",
"",
"ValTudoOK - Validação total do modelo (Ao clicar no confirmar)",
"",
"/*/",
"Static Function ValTudoOK(oModel)",
"\tLocal nOperation := oModel:GetOperation()",
"",
"\tIf 1=2",
"\t\toModel:GetModel():SetErrorMessage(oModel:GetId(),\"\",oModel:GetId(),\"\",ProcName(3),\"\", \"Atenção\" )",
"\t\tReturn .F.",
"\tEndIf",
"",
"RETURN .T."
]
},
"MVC Protheus Modelo 1": {
"prefix": "MVC Modelo 1",
"body": [
"#Include \"Protheus.ch\"",
"#Include \"FWMVCDEF.ch\"",
"",
"/*/{Protheus.doc} ${function}",
"${description}",
"${table}",
"@author Charles Reitz",
"@since $CURRENT_DATE/$CURRENT_MONTH/$CURRENT_YEAR",
"/*/",
"User Function $function(nOpcAuto, xAuto) ",
"\tLocal oBrowse",
"",
"\tIf xAuto <> NIL",
"\t\tFWMVCRotAuto(FWLoadModel(\"${function}\"),\"${table}\",nOpcAuto, {\"MASTER${table}\",xAuto})",
"\tElse",
"\t\toBrowse := FWMBrowse():New()",
"\t\toBrowse:SetAlias(\"${table}\")",
"\toBrowse:SetMenuDef(\"${function}\")",
"\t\toBrowse:SetDescription(\"${description}\")",
"\t\toBrowse:Activate()",
"\tEndIf",
"",
"Return",
"",
"Static Function MenuDef()",
"\tLocal aRotina := {}",
"",
"\tADD OPTION aRotina TITLE \"Visualizar\" ACTION \"VIEWDEF.U_${function}\" OPERATION 2 ACCESS 0",
"\tADD OPTION aRotina TITLE \"Incluir\" ACTION \"VIEWDEF.U_${function}\" OPERATION 3 ACCESS 0",
"\tADD OPTION aRotina TITLE \"Alterar\" ACTION \"VIEWDEF.U_${function}\" OPERATION 4 ACCESS 0",
"\tADD OPTION aRotina TITLE \"Excluir\" ACTION \"VIEWDEF.U_${function}\" OPERATION 5 ACCESS 0",
"\tADD OPTION aRotina TITLE \"Imprimir\" ACTION \"VIEWDEF.U_${function}\" OPERATION 8 ACCESS 0",
"\tADD OPTION aRotina TITLE \"Copiar\" ACTION \"VIEWDEF.U_${function}\" OPERATION 9 ACCESS 0",
"",
"Return aRotina",
"",
"Static Function ModelDef()",
"\tLocal oModel",
"\tLocal oStruct := FWFormStruct(1,'${table}')",
"",
"\toModel := MPFormModel():New(\"MD_ALUNO\")",
"\toModel:SetDescription('Cadastro de Alunos')",
"",
"\toModel:addFields(\"MASTER${table}\",,oStruct)",
"\toModel:getModel(\"MASTER${table}\"):SetDescription(\"Dados do Aluno\")",
"",
"Return oModel",
"",
"Static Function ViewDef()",
"\tLocal oModel := ModelDef()",
"\tLocal oView",
"\tLocal oStruct:= FWFormStruct(2, \"${table}\")",
"",
"\toView := FWFormView():New()",
"\toView:SetModel(oModel)",
"\toView:AddField(\"FORM_MASTER\" , oStruct,\"MASTER${table}\" ) ",
"\toView:CreateHorizontalBox( \"BOX_MASTER\", 100)",
"\toView:SetOwnerView(\"FORM_MASTER\",\"BOX_MASTER\")",
"",
"Return oView"
],
"description": "MVC Modelo 1 - Protheus"
},
"LogMsg": {
"prefix": "LogMsg",
"body": [
"LogMsg(\"${2:/*Programa*/}\", 0, 6, 1, '', '', \"${1:/*Mensagem*/}\" )"
],
"description": "LogMsg - Define um log de mensagens"
},
"Doc Protheus Modelo 1": {
"prefix": "doc protheus modelo 1",
"body": [
"/*/{Protheus.doc} ${function}",
"${description}",
"@author Charles Reitz",
"@since $CURRENT_DATE/$CURRENT_MONTH/$CURRENT_YEAR",
"/*/",
],
"description": "Padrão de documentação inicio de fonte (Modelo 1)"
},
"Doc Protheus Modelo 2": {
"prefix": "doc protheus modelo 2",
"body": [
"/*/{Protheus.doc} ${function}",
"${description}",
"@author Charles Reitz",
"@Since \"$CURRENT_DATE/$CURRENT_MONTH/$CURRENT_YEAR\"",
"@link ${link-text}",
"@param ${parameter1}, ${Type1}, ${description1} ",
"@param ${parameter2}, ${Type2}, ${description2} ",
"@return ${return-type description}",
"/*/",
],
"description": "PPadrão de documentação inicio de fonte (Modelo 2)"
},
"TamSX3": {
"prefix": "TamSX3",
"body": [
"TamSX3(${1:/*cCampo*/})[${2:/*cParam*/}]"
],
"description": "Retorna o Tamanho/Decimal/Tipo de um Campo Informado cParam = 1:Tamanho/2:Decimal/3:Tipo "
},
"BeginSql": {
"prefix": "BeginSql - Exemplo",
"body": [
"\tLocal cAlias := GetNextAlias()",
"\t\tBeginSql Alias cAlias",
"\t\t\tSELECT B1_COD",
"\t\t\tFROM %Table:SB1% SB1",
"\t\t\t WHERE B1_FILIAL = %FWxFilial:SB1% ",
"\t\t\tAND SB1.%NotDel%",
"\t\t\tEndSql",
"\t\tWhile ! (cAlias)->(EoF())",
"\t\t\t(cAlias)->(DbSkip())",
"\t\tEndDo",
"\t\t(cAlias)->(DbCloseArea())"
],
"description": "Exemplo BeginSQl "
},
"Query": {
"prefix": "Query - snippet",
"body": [
"\tcAlias := GetNextAlias()",
"\t\tcQuery := \" SELECT B1_COD, B1_DESC \" ",
"\t\tcQuery += \" FROM \" + RetSqlName(\"SB1\") + \" SB1 \"",
"\t\tcQuery += \" WHERE \" + RetSqlCond(\"SB1\") ",
"\t\tcQuery += \" ORDER BY B1_COD\" ",
"\t\tcQuery := ChangeQuery(cQuery)",
"\t\tMpSysOpenQuery(cQuery, cAlias)",
"\t\tWhile (cAlias)->(!Eof())",
"\t\t\t(cAlias)->(DbSkip())",
"\t\tEndDo",
"\t\t(cAlias)->(DbCloseArea())"
],
"description": "Exemplo Query normal "
},
"x3uso": {
"prefix": "X3uso",
"body": [
"X3Uso(GetSx3Cache('${1:/*cCampo*/}','X3_USADO'))"
],
"description": "Verifica se o campo esta marcado como Usado, retorno Logico"
},
"Help": {
"prefix": "Help Advpl",
"body": [
"Help(NIL, NIL, \"${1:/*Titulo*/}\", NIL, \"${2:/*Texto*/}\", 1, 0, NIL, NIL, NIL, NIL, NIL, {\"${3:/*Texto da Solução*/}\"})"
],
"description": "Help padrao"
},
"Ascan": {
"prefix": "Ascan - Exemplo",
"body": [
"aScan(${1:/*array procurado*/},{|x|Alltrim(x[1]) == \" ${2:/*valor procurado*/}\"})"
],
"description": "Exemplo aScan procurando na posicao 1"
},
"FWxFilial": {
"prefix": "FWFWxFilial",
"body": [
" FWFWxFilial(\"${1:/*Alias*/}\")"
],
"description": "Busca FWxFilial posicionado"
},
"DbSelectArea": {
"prefix": "DbSelectArea",
"body": [
"DbSelectArea(\"${1:/*cAlias*/}\")",
"DbSetorder(${2:/*nOrden*/})"
]
},
"FindFunction": {
"prefix": "FindFunction",
"body": [
"FindFunction( ${cFunction})"
],
"description": "FindFunction() - Faz a busca de uma determinada função no rpo ou no binário"
},
"RpcSetEnv": {
"prefix": "RpcSetEnv - Snippet",
"body": [
"RpcSetEnv('99','01')",
"RpcClearEnv()"
]
},
"fwtemporarytable": {
"prefix": "fwtemporarytable - Snippet",
"body": [
"\tLocal aFields := {}",
"\tLocal oTempTable",
"\tLocal nI",
"\tLocal cAlias1 := GetNextAlias() ",
"\tlocal cAlias2 := GetNextAlias() ",
"\t//Local cQuery := \"\"",
"\t",
"\t//Criação do objeto",
"\toTempTable := FWTemporaryTable():New(cAlias1)",
"\t",
"\t//Monta os campos da tabela",
"\taadd(aFields,{\"COD\",\"C\",30,0})",
"\taadd(aFields,{\"DESCRI\",\"C\",50,0})",
"\taadd(aFields,{\"TIPO\",\"C\",3,0})",
"\t",
"\toTemptable:SetFields( aFields )",
"\toTempTable:AddIndex(\"indice1\", {\"COD\"} )",
"\toTempTable:AddIndex(\"indice2\", {\"TIPO\"} )",
"\t",
"\t//Criação da tabela",
"\toTempTable:Create()",
"\t",
"\t//Populando a tabela temporaria",
"\t",
"\tcAlias2 := GetNextAlias()",
"\t",
"\tBeginSql Alias cAlias2",
"\t\tSELECT B1_COD, B1_DESC, B1_TIPO",
"\t\tFROM %Table:SB1% SB1 ",
"\t\tWHERE B1_FILIAL = %FWxFilial:SB1%",
"\t\tAND SB1.%NotDel%",
"\t\tORDER BY B1_COD",
"\tEndSql",
"\t",
"\tWHILE !(cAlias2)->(EOF())",
"\t",
"\tRECLOCK(cAlias1, .T. )",
"\t\t(cAlias1)->COD := (CALIAS2)->B1_COD",
"\t\t(cAlias1)->DESCRI := (CALIAS2)->B1_DESC",
"\t\t(cAlias1)->TIPO := (CALIAS2)->B1_TIPO",
"\tMSUNLOCK()",
"\t(CALIAS2)->(DBSKIP())",
"\tENDDO",
"\t",
"\t//Executa a leitura da tabela",
"/*tcQuery := \"select * from \"+ oTempTable:GetRealName()",
"\tMPSysOpenQuery( cQuery, 'QRYTMP' )",
"\t",
"\tDbSelectArea('QRYTMP')",
"\t",
"\twhile !eof()",
"\t for nI := 1 to fcount()",
"\t varinfo(fieldname(nI),fieldget(ni))",
"\t next",
"\t dbskip()",
"\tEnddo */",
"\t",
"\tDbSelectArea(cAlias1)",
"\tDBGOTOP()",
"\tDbSetOrder(1)",
"\tWhile !eof()",
"\t\tfor nI := 1 to fcount()",
"\t\tvarinfo(fieldname(nI),fieldget(ni))",
"\tnext",
"\tdbskip()",
"\tEnddo",
"\t",
"\t//Exclui a tabela ",
"\toTempTable:Delete()"
],
"description": "Exemplo - FwtemporaryTable"
},
"Query - Insert": {
"prefix": "Query - Insert - Snippet",
"body": [
"\tcQuerySQL := \"\" ",
"\tcQuerySQL += \"INSERT INTO \" + ${1:/*cTabela*/} + \" (${2:/*cCampos*/})",
"\tcQuerySQL += \" VALUES (${3:/*cValues...*/})",
"\t ",
"\t\tIF TCSqlExec(cQuerySQL) < 0 ",
"\t\t\t ConOut(\"Erro:\", TCSqlError()) ",
"\t\tEndif"
]
},
"FWAlertNoYes": {
"prefix": "FWAlertNoYes - Snippet",
"body": [
"FWAlertNoYes(\"${1:/*Mensagem*/}\",\"Atenção - \"+ProcName()+cValToChar(ProcLine()))"
],
"description": "FWAlertNoYes - Exemplo"
},
"FWAlertyesno": {
"prefix": "FWAlertyesno - Snippet",
"body": [
"FWAlertYesNo(\"${1:/*Mensagem*/}\",\"Atenção - \"+ProcName()+cValToChar(ProcLine()))"
],
"description": "FWAlertyesno - Exemplo"
},
"FWalerterror": {
"prefix": "FWalerterror - Snippet",
"body": [
"FWalerterror(\"${1:/*Mensagem*/}\",\"Atenção - \"+ProcName()+cValToChar(ProcLine()))"
],
"description": "FWalerterror - Exemplo"
},
"FWalertinfo": {
"prefix": "FWalertinfo - Snippet",
"body": [
"FWalertinfo(\"${1:/*Mensagem*/}\",\"Atenção - \"+ProcName()+cValToChar(ProcLine()))"
],
"description": "FWalertinfo - Exemplo"
},
"FWAlertWarning": {
"prefix": "FWAlertWarning - Snippet",
"body": [
"FWAlertWarning(\"${1:/*Mensagem*/}\",\"Atenção - \"+ProcName()+cValToChar(ProcLine()))"
],
"description": "FWAlertWarning - Exemplo"
},
"FWAlertSucess": {
"prefix": "FWAlertSucess - Snippet",
"body": [
"FWAlertSucess(\"${1:/*Mensagem*/}\",\"Atenção - \"+ProcName()+cValToChar(ProcLine()))"
],
"description": "FWAlertSucess - Exemplo"
},
"FWAlertHelp": {
"prefix": "FWAlertHelp - Snippet",
"body": [
"FWAlertHelp(\"${1:/*Mensagem*/}\",\"Atenção - \"+ProcName()+cValToChar(ProcLine()))"
],
"description": "FWAlertHelp - Exemplo"
},
"TCSqlExec": {
"prefix": "TCSqlExec - Snippet",
"body": [
"\tcSQLExec := \"\" ",
"\tcSQLExec += \"\" ",
"\tIf TCSqlExec(cSQLExec) < 0 ",
"\tHelp(NIL, NIL,ProcName(), NIL, \"O comando SQL gerou erro\"+ TCSqlError(), 1, 0, NIL, NIL, NIL, NIL, .T., {\"Verifique com o setor de TI!\"})",
"\tEndIf ",
]
},
"funcao": {
"prefix": "#include",
"body": [
"#INCLUDE 'TOTVS.CH' "
]
},
"Case": {
"prefix": "Case - snippet",
"body": [
"Do Case ",
"CASE ${condicao1}",
"\t${instrucoes1}",
"CASE ${condicao2}",
"\t${instrucoes2} ",
"OTHERWISE ",
"\t${instrucoes3} ",
"End Case "
]
},
"Sql_string": {
"prefix": [
"sql"
],
"body": [
"_cSql += \" ${TM_SELECTED_TEXT} \"+CRLF"
],
"description": "Encapsula o texto selecionado no formato de string"
},
"delete_string": {
"prefix": [
"delete"
],
"body": [
"${1|D_E_L_E_T_<>'*',%NOTDEL%|}"
],
"description": "insere a retirada do deleted no sql para protheus"
},
"dbseekcomif": {
"prefix": [
"dbseek com if - snippet"
],
"body": [
"${1:tabela}->(dbSetOrder(1))",
"If ${1:tabela}->(dbSeek(FWxFilial(\"${1:tabela}\")+$0))",
"EndIf"
],
"description": "Insere dbselectarea com if do seek"
},
"dbseek": {
"prefix": [
"dbseek - snippet"
],
"body": [
"${1:tabela}->(dbSetOrder(1))",
"${1:tabela}->(dbSeek(FWxFilial(\"${1:tabela}\")+$0))",
],
"description": "Insere dbselectarea com if do seek"
},
"msseek": {
"prefix": [
"msseek - snippet"
],
"body": [
"${1:tabela}->(dbSetOrder(1))",
"${1:tabela}->(msseek(FWxFilial(\"${1:tabela}\")+$0))",
],
"description": "Insere dbselectarea com if do seek"
},
"FwMsgRun": {
"prefix": [
"FwMsgRun"
],
"body": [
"/* para mudar descricao da tela se usa oSay:cCaption := \"\" dentro da funcao a ser executada ",
"ProcessMessage() -> força a atualização da messgem da tela cCaption */",
"FWMsgRun( /* Obj_tela */ , {|oSay| ${1:Funcao_a_ser_executada} } , ${2:Titulo} , ${3:Mensagem} )"
],
"description": "FwMsgRun"
},
"RecLock": {
"prefix": [
"RecLock - snippet"
],
"body": [
"RecLock(\"${1:Tabela}\" , .F. )",
"${1:Tabela}->$0",
"${1:Tabela}->(MsUnlock())"
],
"description": "cl_ Insere reclock"
},
"MemoWrite": {
"prefix": [
"MemoWrite"
],
"body": [
"MemoWrite(\"D:\\logsql\\\"+FunName()+\"_\"+ProcName()+\".txt\", GetLastQuery()[2])"
],
"description": "Insert memowrite logsql getlastquery"
},
"Aviso_varinfo": {
"prefix": [
"Aviso",
"VarInfo"
],
"body": [
"Aviso( 'VarInfo', VarInfo('${1:variavel}', ${1:variavel} , , .F. ) ,{'ok'} ,4,,,, .T.)$0"
],
"description": "Insert aviso com varinfo"
},
"Posicione": {
"prefix": [
"Posicione snippet"
],
"body": [
"Posicione(\"${1:tabela}\", 1, FWxFilial(\"${1:tabela}\")+${2:chave}, \"${3:retorno}\")$0"
],
"description": "Insert aviso com varinfo"
},
"FwFldGet - Tkz": {
"prefix": [
"FWFldGet"
],
"body": [
"FWFldGet(\"${1:cCampo}\")"
],
"description": "FWFldGet(<cCampo >, [ nLinha ], [ oModel ], [ lShowMsg ])"
},
"FWFldPut - TKZ": {
"prefix": [
"FWFldPut"
],
"body": [
"FWFldPut(\"${1:cCampo}\",\"${2:xConteudo}\")"
],
"description": "FWFldPut(<cCampo >, <xConteudo >, [ nLinha ], [ oModel ], [ lShowMsg ], [ lLoad ])"
},
"Supergetmv": {
"prefix": [
"Supergetmv"
],
"body": [
"SuperGetMV(\"${1:MV_XXXXXX}\",${2:.F.},${3:\" \"})"
],
"description": "SUPERGETMV( <nome do parâmetro>, <lHelp>, <cPadrão>, <Filial do sistema> )"
},
"JsonObject()": {
"prefix": [
"JsonObject()"
],
"body": [
"JsonObject():New()"
],
"description": "Cria uma nova instância do objeto, da classe JsonObject, que representa um objeto JSON."
},
"PADR()": {
"prefix": [
"PADR()"
],
"body": [
"PADR(${1:CAMPO/VAR},GETSX3CACHE(\"${2:CAMPO REFERENCIA}\",\"X3_TAMANHO\"),'' )"
],
"description": "Ajusta campo conforme tamanho."
},
"aArea": {
"prefix": [
"aArea - snippet"
],
"body": [
"Local aAreas := { Getarea(), XXX->(GetArea())}",
"AEval(aAreas,{|x,y| RestArea(x) })"
],
"description": "Guardar varias areas."
},
"MsgYesNo": {
"prefix": [
"MSGYESNO( 'cTexto', 'cTitulo' )"
],
"body": [
"MSGYESNO( 'cTexto', 'cTitulo' )"
],
"description": "Guardar varias areas."
},
"GetSx3Cache": {
"prefix": [
"GetSx3Cache - snippet"
],
"body": [
"GetSx3Cache(\"${1:CAMPO}\" , \"X3_TAMANHO\" )"
],
"description": "GetSx3Cache snippet"
},
"MPSysExecScalar - snippet ": {
"prefix": "MPSysExecScalar - snippet",
"body": [
"Local cQuery as character ",
"Local nCount as numeric ",
"cQuery := \" SELECT COUNT(R_E_C_N_O_) NREC FROM \" + RetSqlName(\"SA1\") + \" WHERE D_E_L_E_T_ = ' ' \" ",
"nCount := MpSysExecScalar(cQuery,\"NREC\") ",
"Conout(\"Tabela possui \" + cValToChar(nCount) + \" registros\") "
]
},
"MPSysExecScalar - snippet - Bindparam ": {
"prefix": "MPSysExecScalar - Bindparam",
"body": [
" Local cQuery as character",
" Local nVal as numeric",
" Local aBindParam as array",
" cQuery := \"SELECT COUNT(*) CNT FROM SE1T10 WHERE E1_FABOV = ? AND D_E_L_E_T_ = ? \" ",
" aBindParam := {'123', ' '} ",
" nVal := MPSysExecScalar(cQuery,'CNT',aBindParam)"
]
},
"count advpl - snippet ": {
"prefix": "count advpl - snippet",
"body": [
"Local nCount as numeric ",
"COUNT TO ncount ",
"DbGoTop()"
]
},
"FWUUIDV1": {
"prefix": "FWUUIDV1",
"body": [
"FWUUIDV1()"
],
"description": "Gera um UUID V1"
},
"FWUUID": {
"prefix": "FWUUID",
"body": [
"FWUUID()",
],
"description": "Gera um UUID V4"
},
"FWUUIDV4" : {
"prefix": "FWUUIDV4",
"body": [
"FWUUIDV4()"
],
"description": "Gera um UUID V4"
},
"FWTimeStamp" : {
"prefix": "FWTimeStamp",
"body": [
"FWTimeStamp()"
],
"description": "Retorna a data e hora atual - https://tdn.totvs.com/display/public/framework/FWTimeStamp"
},
"FwDateTimeToLocal": {
"prefix": "FwDateTimeToLocal",
"body": [
"FwDateTimeToLocal(${1:/*cDateTime*/})"
],
"description": "Converte uma data e hora UTC para a hora local - https://tdn.totvs.com/display/public/framework/FwDateTimeToLocal"
},
"FWIsInCallStack": {
"prefix": "FWIsInCallStack",
"body": [
"FWIsInCallStack(${1:/*cFunction*/})"
],
"description": "Verifica se a função está na pilha de chamadas - https://tdn.totvs.com/display/public/framework/FWIsInCallStack"
},
"aEval": {
"prefix": "AEval",
"body": [
"AEval(${1:/*aArray*/}, {|x| ${2:/*funcao*/} })"
],
"description": "Executa uma função para cada elemento de um array - https://tdn.totvs.com/display/public/framework/AEval"
},
"aSort": {
"prefix": "ASort",
"body": [
"ASort(${1:/*aArray*/}, {|x,y| ${2:/*funcao*/} })"
],
"description": "Ordena um array - https://tdn.totvs.com/display/public/framework/ASort"
},
"aSize": {
"prefix": "aSize",
"body": [
"aSize(${1:/*aArray*/})"
],
"description": "Retorna o tamanho de um array - https://tdn.totvs.com/display/public/framework/aSize"
},
"aScan": {
"prefix": "aScan",
"body": [
"aScan(${1:/*aArray*/}, {|x| ${2:/*funcao*/} })"
],
"description": "Procura um elemento em um array - https://tdn.totvs.com/display/public/framework/aScan"
},
"cToD": {
"prefix": "cToD",
"body": [
"cToD(${1:/*cData*/})"
],
"description": "Converte uma data no formato string para o formato date - https://tdn.totvs.com/display/public/framework/cToD"
},
"dToC": {
"prefix": "dToC",
"body": [
"dToC(${1:/*dData*/})"
],
"description": "Converte uma data no formato date para o formato string - https://tdn.totvs.com/display/public/framework/dToC"
}
}