/
Main.bas
8492 lines (8110 loc) · 352 KB
/
Main.bas
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
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
'#########################################################
'# Main.bas #
'# This file is part of VisualFBEditor #
'# Authors: Xusinboy Bekchanov (bxusinboy@mail.ru) #
'# Liu XiaLin (LiuZiQi.HK@hotmail.com) #
'#########################################################
'#define __USE_GTK__
#include once "Main.bi"
#include once "mff/Dialogs.bi"
#include once "mff/Form.bi"
#include once "mff/TextBox.bi"
#include once "mff/RichTextBox.bi"
#include once "mff/TabControl.bi"
#include once "mff/StatusBar.bi"
#include once "mff/Splitter.bi"
#include once "mff/ToolBar.bi"
#include once "mff/ListControl.bi"
#include once "mff/CheckBox.bi"
#include once "mff/ComboBoxEdit.bi"
#include once "mff/ComboBoxEx.bi"
#include once "mff/RadioButton.bi"
#include once "mff/ProgressBar.bi"
#include once "mff/ScrollBarControl.bi"
#include once "mff/Label.bi"
#include once "mff/Panel.bi"
#include once "mff/TrackBar.bi"
#include once "mff/Clipboard.bi"
#include once "mff/TreeView.bi"
#include once "mff/TreeListView.bi"
#include once "mff/IniFile.bi"
#include once "mff/PointerList.bi"
#include once "mff/ReBar.bi"
#include once "vbcompat.bi"
Using My.Sys.Forms
Using My.Sys.Drawing
#ifdef __USE_WINAPI__
InitDarkMode
'setDarkMode(True, True)
#endif
#include once "frmSplash.bi"
pfSplash->MainForm = False
pfSplash->Show
#ifdef __FB_64BIT__
pfSplash->lblSplash1.Text = "(" & ML("Version") & " " & pApp->Version & " " & ML("64-bit") & ")"
#else
pfSplash->lblSplash1.Text = "(" & ML("Version") & " " & pApp->Version & " " & ML("32-bit") & ")"
#endif
pApp->DoEvents
Dim Shared As VisualFBEditor.Application VisualFBEditorApp
Dim Shared As IniFile iniSettings, iniTheme
Dim Shared As ToolBar tbStandard, tbEdit, tbBuild, tbRun, tbProject, tbExplorer, tbForm, tbProperties, tbEvents, tbBottom, tbLeft, tbRight
Dim Shared As StatusBar stBar
Dim Shared As Splitter splLeft, splRight, splBottom, splProperties, splEvents
Dim Shared As ListControl lstLeft
Dim Shared As CheckBox chkLeft
Dim Shared As RadioButton radButton
Dim Shared As ScrollBarControl scrLeft
Dim Shared As Label lblLeft
Dim Shared As Panel pnlLeft, pnlRight, pnlBottom, pnlBottomTab, pnlLeftPin, pnlRightPin, pnlBottomPin, pnlPropertyValue, pnlColor
Dim Shared As TrackBar trLeft
Dim Shared As MainMenu mnuMain
Dim Shared As MenuItem Ptr mnuStartWithCompile, mnuStart, mnuBreak, mnuEnd, mnuRestart, mnuStandardToolBar, mnuEditToolBar, mnuProjectToolBar, mnuBuildToolBar, mnuRunToolBar, mnuSplit, mnuSplitHorizontally, mnuSplitVertically, mnuWindowSeparator, miRecentProjects, miRecentFiles, miRecentFolders, miRecentSessions, miSetAsMain, miTabSetAsMain, miTabReloadHistoryCode, miRemoveFiles, miToolBars
Dim Shared As MenuItem Ptr miSaveProject, miSaveProjectAs, miCloseProject, miCloseFolder, miSave, miSaveAs, miSaveAll, miClose, miCloseAll, miPrint, miPrintPreview, miPageSetup, miOpenProjectFolder, miProjectProperties, miExplorerOpenProjectFolder, miExplorerProjectProperties, miExplorerCloseProject, miRemoveFileFromProject
Dim Shared As MenuItem Ptr miUndo, miRedo, miCutCurrentLine, miCut, miCopy, miPaste, miSingleComment, miBlockComment, miUncommentBlock, miDuplicate, miSelectAll, miIndent, miOutdent, miFormat, miUnformat, miFormatProject, miUnformatProject, miAddSpaces, miCompleteWord, miParameterInfo, miStepInto, miStepOver, miStepOut, miRunToCursor, miGDBCommand, miAddWatch, miToggleBreakpoint, miClearAllBreakpoints, miSetNextStatement, miShowNextStatement
Dim Shared As MenuItem Ptr miNumbering, miMacroNumbering, miRemoveNumbering, miProcedureNumbering, miProcedureMacroNumbering, miRemoveProcedureNumbering, miProjectMacroNumbering, miProjectMacroNumberingStartsOfProcedures, miRemoveProjectNumbering, miPreprocessorNumbering, miRemovePreprocessorNumbering, miProjectPreprocessorNumbering, miRemoveProjectPreprocessorNumbering, miOnErrorResumeNext, miOnErrorGoto, miOnErrorGotoResumeNext, miRemoveErrorHandling
Dim Shared As MenuItem Ptr dmiNumbering, dmiMacroNumbering, dmiRemoveNumbering, dmiProcedureNumbering, dmiProcedureMacroNumbering, dmiRemoveProcedureNumbering, dmiProjectMacroNumbering, dmiProjectMacroNumberingStartsOfProcedures, dmiRemoveProjectNumbering, dmiPreprocessorNumbering, dmiRemovePreprocessorNumbering, dmiProjectPreprocessorNumbering, dmiRemoveProjectPreprocessorNumbering, dmiOnErrorResumeNext, dmiOnErrorGoto, dmiOnErrorGotoResumeNext, dmiRemoveErrorHandling, dmiMake, dmiMakeClean
Dim Shared As MenuItem Ptr miCode, miForm, miCodeAndForm, miCollapseCurrent, miCollapseAllProcedures, miCollapseAll, miUnCollapseCurrent, miUnCollapseAllProcedures, miUnCollapseAll, miImageManager, miAddProcedure, miFind, miReplace, miFindNext, miFindPrevious, miGoto, miDefine, miToggleBookmark, miNextBookmark, miPreviousBookmark, miClearAllBookmarks, miSyntaxCheck, miCompile, miCompileAll, miBuildBundle, miBuildAPK, miGenerateSignedBundle, miGenerateSignedAPK, miMake, miMakeClean
Dim Shared As ToolButton Ptr tbtSave, tbtSaveAll, tbtSyntaxCheck, tbtCompile, tbtUndo, tbtRedo, tbtCut, tbtCopy, tbtPaste, tbtSingleComment, tbtUncommentBlock, tbtFormat, tbtUnformat, tbtCompleteWord, tbtParameterInfo, tbtFind, tbtRemoveFileFromProject, tbtStartWithCompile, tbtStart, tbtBreak, tbtEnd, tbt32Bit, tbt64Bit, tbtUseDebugger, tbtNotSetted, tbtConsole, tbtGUI
Dim Shared As SaveFileDialog SaveD
Dim Shared As ReBar MainReBar
#ifndef __USE_GTK__
Dim Shared As ScrollBarControl scrTool
Dim Shared As PageSetupDialog PageSetupD
Dim Shared As PrintDialog PrintD
Dim Shared As PrintPreviewDialog PrintPreviewD
Dim Shared As My.Sys.ComponentModel.Printer pPrinter
#endif
Dim Shared As List Tools, TabPanels, ControlLibraries
Dim Shared As WStringList GlobalNamespaces, Comps, GlobalTypes, GlobalEnums, GlobalFunctions, GlobalFunctionsHelp, GlobalArgs, AddIns, IncludeFiles, LoadPaths, IncludePaths, LibraryPaths, MRUFiles, MRUFolders, MRUProjects, MRUSessions ' add Sessions
Dim Shared As WString Ptr RecentFiles, RecentFile, RecentProject, RecentFolder, RecentSession '
Dim Shared As Dictionary Helps, HotKeys, Compilers, MakeTools, Debuggers, Terminals, OtherEditors, mlKeys, mlCompiler, mlTemplates, mpKeys, mcKeys
Dim Shared As ListView lvErrors, lvSearch, lvToDo
Dim Shared As ProgressBar prProgress
Dim Shared As CommandButton btnPropertyValue
Dim Shared As TextBox txtPropertyValue, txtLabelProperty, txtLabelEvent
Dim Shared As ComboBoxEdit cboPropertyValue
Dim Shared As PopupMenu mnuForm, mnuVars, mnuExplorer, mnuTabs
Dim Shared As ImageList imgList, imgListD, imgListTools, imgListStates
Dim Shared As TreeListView lvProperties, lvEvents, lvLocals, lvGlobals, lvThreads, lvWatches
Dim Shared As ToolPalette tbToolBox
Dim Shared As Panel pnlToolBox
Dim Shared As TabControl tabLeft, tabRight, tabBottom ', tabDebug
Dim Shared As TreeView tvExplorer, tvVar, tvThd, tvWch ', tvPrc
Dim Shared As TextBox txtOutput, txtImmediate, txtChangeLog ' Add Change Log
Dim Shared As Form frmMain
Dim Shared As Integer tabItemHeight
Dim Shared As Integer miRecentMax =20 'David Changed
Dim Shared As Boolean mLoadLog, mLoadToDo, mChangeLogEdited, mStartLoadSession = True, ManifestIcoCopy ' Add Change Log
Dim Shared As WString * MAX_PATH mChangelogName 'David Changed
pApp = @VisualFBEditorApp
pfrmMain = @frmMain
pSaveD = @SaveD
piniSettings = @iniSettings
piniTheme = @iniTheme
pComps = @Comps
pGlobalNamespaces = @GlobalNamespaces
pGlobalTypes = @GlobalTypes
pGlobalEnums = @GlobalEnums
pGlobalFunctions = @GlobalFunctions
pGlobalArgs = @GlobalArgs
pAddIns = @AddIns
pTools = @Tools
pControlLibraries = @ControlLibraries
pCompilers = @Compilers
pMakeTools = @MakeTools
pDebuggers = @Debuggers
pTerminals = @Terminals
pOtherEditors = @OtherEditors
pHelps = @Helps
plvSearch = @lvSearch
plvToDo = @lvToDo '
ptbStandard = @tbStandard
plvProperties = @lvProperties
plvEvents = @lvEvents
pprProgress = @prProgress
pstBar = @stBar 'David Change
ptxtPropertyValue = @txtPropertyValue
pbtnPropertyValue = @btnPropertyValue
ptvExplorer = @tvExplorer
ptabLeft = @tabLeft
ptabBottom = @tabBottom
ptabRight = @tabRight
pimgList = @imgList
pimgListTools = @imgListTools
pIncludeFiles = @IncludeFiles
pLoadPaths = @LoadPaths
pIncludePaths = @IncludePaths
pLibraryPaths = @LibraryPaths
pfSplash->lblProcess.Text = ML("Load On Startup") & ": LoadKeyWords"
GlobalNamespaces.Sorted = True
Comps.Sorted = True
GlobalTypes.Sorted = True
GlobalEnums.Sorted = True
GlobalFunctions.Sorted = True
GlobalFunctionsHelp.Sorted = True
GlobalArgs.Sorted = True
'LoadLanguageTexts
LoadSettings
#include once "file.bi"
#include once "Designer.bi"
#include once "TabWindow.bi"
#include once "Debug.bi"
#include once "frmFind.bi"
#include once "frmGoto.bi"
#include once "frmFindInFiles.bi"
#include once "frmAddIns.bi"
#include once "frmTools.bi"
#include once "frmAbout.bi"
#include once "frmImageManager.bi"
#include once "frmOptions.bi"
#include once "frmTemplates.bi"
#include once "frmParameters.bi"
#include once "frmProjectProperties.bi"
#include once "frmSave.bi"
#include once "frmTipOfDay.frm"
#include once "frmComponents.frm"
#include once "Debug.bi"
Namespace VisualFBEditor
Function Application.ReadProperty(ByRef PropertyName As String) As Any Ptr
Select Case LCase(PropertyName)
Case "mainprojectfile", "mainfile", "exefile"
Dim As ProjectElement Ptr Project
Dim As ExplorerElement Ptr ee
Dim As TreeNode Ptr ProjectNode
Dim As UString ProjectFile = ""
Dim As UString CompileLine, MainFile = GetMainFile(, Project, ProjectNode)
Dim As UString FirstLine = GetFirstCompileLine(MainFile, Project, CompileLine)
Dim As UString ExeFile = GetExeFileName(MainFile, FirstLine & CompileLine)
If ProjectNode <> 0 Then ee = ProjectNode->Tag
If ee <> 0 Then ProjectFile = *ee->FileName
Select Case LCase(PropertyName)
Case "mainprojectfile": Return ProjectFile.vptr
Case "mainfile": Return MainFile.vptr
Case "exefile": Return ExeFile.vptr
End Select
Case "currentword"
Dim As UString CurrentWord = ""
Dim As TabWindow Ptr tb = Cast(TabWindow Ptr, ptabCode->SelectedTab)
If tb <> 0 Then CurrentWord = tb->txtCode.GetWordAtCursor
Return CurrentWord.vptr
Case Else: Return Base.ReadProperty(PropertyName)
End Select
Return 0
End Function
Function Application.WriteProperty(ByRef PropertyName As String, Value As Any Ptr) As Boolean
If Value = 0 Then
Select Case LCase(PropertyName)
Case Else: Return Base.WriteProperty(PropertyName, Value)
End Select
Else
Select Case LCase(PropertyName)
Case Else: Return Base.WriteProperty(PropertyName, Value)
End Select
End If
Return True
End Function
End Namespace
Function ML(ByRef V As WString) ByRef As WString
If LCase(CurLanguage) = "english" Then Return V
Dim As Integer tIndex = mlKeys.IndexOfKey(V) ' For improve the speed
If tIndex >= 0 Then
Return mlKeys.Item(tIndex)->Text
Else
tIndex = mlKeys.IndexOfKey(Replace(V, "&", "")) '
If tIndex >= 0 Then Return mlKeys.Item(tIndex)->Text Else Return V
End If
End Function
Function MLCompilerFun(ByRef V As WString) ByRef As WString
If LCase(CurLanguage) = "english" Then Return V
Dim As Integer tIndex = mlCompiler.IndexOfKey(V) ' For improve the speed
If tIndex >= 0 Then Return mlCompiler.Item(tIndex)->Text Else Return V
End Function
'David Change For the comment of control's Properties
Function MC(ByRef V As WString) ByRef As WString
If (Not gLocalProperties) Then Return V
Dim As WString * 100 TempV = ""
Dim As Integer Posi = InStrRev(V, ".")
TempV = IIf(Posi > 0, Mid(V, Posi + 1), V)
Dim As Integer tIndex = mcKeys.IndexOfKey(TempV) 'David Changed
If tIndex >= 0 Then Return mcKeys.Item(tIndex)->Text
Return V
End Function
Function MP(ByRef V As WString) ByRef As WString
If (Not gLocalProperties) OrElse LCase(CurLanguage) = "english" Then Return V
Dim As Integer tIndex = -1, tIndex2 = -1
If InStr(V,".") Then
Static As WString*50 TempWstr =""
Dim As UString LineParts(Any)
Split(V, ".", LineParts())
For k As Integer = 0 To UBound(LineParts)
tIndex = mpKeys.IndexOfKey(LineParts(k))
If tIndex >=0 Then
If k=0 Then
TempWstr = mpKeys.Item(tIndex)->Text
Else
TempWstr &= "." & mpKeys.Item(tIndex)->Text
End If
Else
If k=0 Then
TempWstr = LineParts(k)
Else
TempWstr &= "." & LineParts(k)
End If
End If
Next
Return TempWstr
Else
tIndex = mpKeys.IndexOfKey(V)
If tIndex >=0 Then
Return mpKeys.Item(tIndex)->Text
Else
Return V
End If
End If
Return V
End Function
Sub ToolGroupsToCursor()
tbToolBox.Groups.Item(0)->Buttons.Item(0)->Checked = True
tbToolBox.Groups.Item(1)->Buttons.Item(0)->Checked = True
tbToolBox.Groups.Item(2)->Buttons.Item(0)->Checked = True
tbToolBox.Groups.Item(3)->Buttons.Item(0)->Checked = True
End Sub
Sub ClearMessages()
txtOutput.Text = ""
txtOutput.Update
End Sub
Sub SetCodeVisible(tb As TabWindow Ptr)
If tb->tbrTop.Buttons.Item("Form")->Checked = True Then tb->tbrTop.Buttons.Item("Code")->Checked = True: tbrTop_ButtonClick tb->tbrTop, *tb->tbrTop.Buttons.Item("Code")
End Sub
Sub SelectError(ByRef FileName As WString, iLine As Integer, tabw As TabWindow Ptr = 0)
Dim tb As TabWindow Ptr
If tabw <> 0 AndAlso ptabCode->IndexOfTab(tabw) <> -1 Then
tb = tabw
tb->SelectTab
Else
If FileName = "" OrElse EndsWith(LCase(FileName), ".exe") OrElse Dir(FileName) = "" Then Exit Sub
tb = AddTab(FileName)
End If
tb->txtCode.SetSelection iLine - 1, iLine - 1, 0, tb->txtCode.LineLength(iLine - 1)
SetCodeVisible tb
End Sub
Sub lvProperties_CellEditing(ByRef Sender As TreeListView, ByRef Item As TreeListViewItem Ptr, ByVal SubItemIndex As Integer, CellEditor As Control Ptr, ByRef Cancel As Boolean)
'CellEditor = @cboPropertyValue
End Sub
Sub lvProperties_CellEdited(ByRef Sender As TreeListView, ByRef Item As TreeListViewItem Ptr, ByVal SubItemIndex As Integer, ByRef NewText As WString, ByRef Cancel As Boolean)
PropertyChanged Sender, NewText, False
End Sub
Sub txtPropertyValue_LostFocus(ByRef Sender As Control)
PropertyChanged Sender, txtPropertyValue.Text, False
End Sub
Dim Shared bNotChange As Boolean
Sub cboPropertyValue_Change(ByRef Sender As Control)
If Trim(cboPropertyValue.Text) = "" Then
Exit Sub
End If
If bNotChange Then
bNotChange = False
Exit Sub
End If
PropertyChanged Sender, cboPropertyValue.Text, True
End Sub
Function GetShortFileName(ByRef FileName As WString, ByRef FilePath As WString) As UString
If StartsWith(FileName, GetFolderName(FilePath)) Then
Return Mid(FileName, Len(GetFolderName(FilePath)) + 1)
Else
Return FileName
End If
End Function
Function GetFullPathInSystem(ByRef Path As WString) As UString
If InStr(Path, ":") > 0 OrElse Path = "" Then
Return Path
Else
Dim As WString * MAX_PATH fullPath
#ifdef __USE_GTK__
fullPath = WStr(*g_find_program_in_path(Path))
#else
Dim As WString Ptr lpFilePart
If SearchPath(NULL, Path, ".exe", MAX_PATH - 1, @fullPath, 0) = 0 Then
Print GetErrorString(GetLastError)
End If
#endif
Return fullPath
End If
End Function
Function GetFullPath(ByRef Path As WString, ByRef FromFile As WString = "") As UString
If CInt(InStr(Path, ":") > 0) OrElse CInt(StartsWith(Path, "/")) OrElse CInt(StartsWith(Path, "\")) Then
If EndsWith(Path, "\..") OrElse EndsWith(Path, "/..") Then
Return GetFolderName(GetFolderName(Path))
Else
Return Path
End If
ElseIf StartsWith(Path, "./") OrElse StartsWith(Path, ".\") Then
If FromFile = "" Then
If EndsWith(ExePath, "\..") OrElse EndsWith(ExePath, "/..") Then
Return GetFolderName(GetFolderName(ExePath)) & Mid(Path, 3)
Else
Return ExePath & Slash & Mid(Path, 3)
End If
Else
Return GetFolderName(FromFile) & Mid(Path, 3)
End If
ElseIf StartsWith(Path, "../") OrElse StartsWith(Path, "..\") Then
If FromFile = "" Then
Return GetFolderName(ExePath) & Mid(Path, 4)
Else
Return GetFolderName(GetFolderName(FromFile)) & Mid(Path, 4)
End If
Else
If FromFile = "" Then
Dim As UString Path_ = GetFullPathInSystem(Path)
If Path_ <> "" Then
Return Path_
Else
Return ExePath & Slash & Path
End If
Else
Return GetFolderName(FromFile) & Path
End If
End If
End Function
Function GetFolderName(ByRef FileName As WString, WithSlash As Boolean = True) As UString
Dim Pos1 As Long = InStrRev(FileName, "\", Len(FileName) - 1)
Dim Pos2 As Long = InStrRev(FileName, "/", Len(FileName) - 1)
If Pos1 = 0 OrElse Pos2 > Pos1 Then Pos1 = Pos2
If Pos1 > 0 Then
If Not WithSlash Then Pos1 -= 1
Return Left(FileName, Pos1)
End If
Return ""
End Function
Function GetFileName(ByRef FileName As WString) As UString
Dim Pos1 As Long = InStrRev(FileName, "\")
Dim Pos2 As Long = InStrRev(FileName, "/")
If Pos1 = 0 OrElse Pos2 > Pos1 Then Pos1 = Pos2
If Pos1 > 0 Then
Return Mid(FileName, Pos1 + 1)
End If
Return FileName
End Function
Function GetBakFileName(ByRef FileName As WString) As UString
If FileName = "" Then Return ""
Dim As String BakDate = Format(Now, "yyyymmdd_hhmm") 'David Change ReplaceAny(__DATE_ISO__ & "_" & Time,":/\-","")
Dim As WString * MAX_PATH iFileName
Dim Pos1 As Long = InStrRev(FileName, ".")
If Pos1 = 0 Then Pos1 = Len(FileName)
If Pos1 > 0 Then
Return ExePath + "/Temp/" + GetFileName(FileName) + "_" & BakDate & ".bak"
Else
Return ExePath + "/Temp/" + BakDate & ".bak"
End If
End Function
Function GetExeFileName(ByRef FileName As WString, ByRef sLine As WString) As UString
Dim As UString CompileWith = " " & LTrim(sLine)
Dim As UString pFileName = FileName
Dim As UString ExeFileName
Dim As String SearchChar
Dim As Long Pos1, Pos2
Pos1 = InStr(CompileWith, " -x ")
If Pos1 > 0 Then
If Mid(CompileWith, Pos1 + 4, 1) = """" Then
SearchChar = """"
Else
SearchChar = " "
End If
Pos2 = InStr(Pos1 + 5, CompileWith, SearchChar)
If Pos2 > 0 Then
ExeFileName = Mid(CompileWith, Pos1 + 5, Pos2 - Pos1 - 5)
If CInt(InStr(ExeFileName, ":") = 0) AndAlso CInt(Not StartsWith(ExeFileName, "/")) Then
Return GetFolderName(pFileName) + ExeFileName
Else
Return ExeFileName
End If
End If
End If
Pos1 = InStrRev(pFileName, ".")
If Pos1 = 0 Then Pos1 = Len(pFileName) + 1
If Pos1 > 0 Then
#ifdef __USE_GTK__
Pos2 = InStrRev(pFileName, "/")
If Pos2 > 0 AndAlso InStr(CompileWith, "-dll") > 0 Then
Return Left(pFileName, Pos2) & "lib" & Mid(pFileName, Pos2 + 1, Pos1 - Pos2 - 1) & ".so"
Else
Return IIf(InStr(CompileWith, "-dll"), "lib", "") & Left(pFileName, Pos1 - 1) & IIf(InStr(CompileWith, "-dll"), ".so", "")
End If
#else
If InStr(CompileWith, "-target ") Then
Pos2 = InStrRev(pFileName, "\")
If Pos2 > 0 AndAlso InStr(CompileWith, "-dll") > 0 Then
Return Left(pFileName, Pos2) & "lib" & Mid(pFileName, Pos2 + 1, Pos1 - Pos2 - 1) & ".so"
Else
Return IIf(InStr(CompileWith, "-dll"), "lib", "") & Left(pFileName, Pos1 - 1) & IIf(InStr(CompileWith, "-dll"), ".so", "")
End If
Else
Return Left(pFileName, Pos1 - 1) & IIf(InStr(CompileWith, "-dll"), ".dll", ".exe")
End If
#endif
End If
End Function
Function Compile(Parameter As String = "", bAll As Boolean = False) As Integer
On Error Goto ErrorHandler
Dim As WString Ptr MainFile, LogFileName, LogFileName2, LogText, BatFileName, fbcCommand, PipeCommand
Dim As WString Ptr CompileWith, MFFPathC, ErrFileName, ErrTitle, ExeName, FirstLine, ProjectPath
Dim As Integer NumberErr, NumberWarning, NumberInfo, NodesCount, CompileResult = 1
Dim As UString CompileLine
Dim As ProjectElement Ptr Project
Dim As TreeNode Ptr ProjectNode
Dim As Boolean Bit32 = tbt32Bit->Checked
Dim As WString Ptr FbcExe, CurrentCompiler = IIf(Bit32, CurrentCompiler32, CurrentCompiler64)
ThreadsEnter()
ClearMessages
NodesCount = IIf(bAll, tvExplorer.Nodes.Count, 1)
StartProgress
lvErrors.ListItems.Clear
ptabBottom->Tabs[1]->Caption = ML("Errors") ' 'Inits
ThreadsLeave()
For k As Integer = 0 To NodesCount - 1
ThreadsEnter()
If bAll Then ProjectNode = tvExplorer.Nodes.Item(k) Else ProjectNode = 0
WLet(MainFile, GetMainFile(AutoSaveBeforeCompiling, Project, ProjectNode))
If Project Then
If EndsWith(*Project->FileName, ".vfp") Then
WLet(ProjectPath, GetFolderName(*Project->FileName))
Else
WLet(ProjectPath, *Project->FileName)
End If
Else
WLet(ProjectPath, GetFolderName(*MainFile))
End If
ThreadsLeave()
If Len(*MainFile) <= 0 Then
ThreadsEnter()
ShowMessages ML("No Main file specified for the project.") & "!"
ThreadsLeave()
CompileResult = 0
Continue For
End If
WLet(FirstLine, GetFirstCompileLine(*MainFile, Project, CompileLine))
Versioning *MainFile, *FirstLine & CompileLine, Project, ProjectNode
Dim FileOut As Integer
ThreadsEnter()
ThreadsLeave()
WLet(ExeName, GetExeFileName(*MainFile, *FirstLine))
If Project AndAlso Trim(*Project->CompilerPath) <> "" Then
WLet(FbcExe, GetFullPath(*Project->CompilerPath))
Else
WLet(FbcExe, GetFullPath(IIf(Bit32, *Compiler32Path, *Compiler64Path)))
End If
If *FbcExe = "" Then
ThreadsEnter()
ShowMessages ML("Invalid defined compiler path.")
ThreadsLeave()
CompileResult = 0
Continue For
Else
ChDir(ExePath)
#ifdef __USE_GTK__
If g_find_program_in_path(ToUtf8(*FbcExe)) = NULL Then
#else
If Not FileExists(*FbcExe) Then
#endif
ThreadsEnter()
ShowMessages ML("File") & " """ & *FbcExe & """ " & ML("not found") & "!"
ThreadsLeave()
CompileResult = 0
Continue For
End If
End If
Dim As UserToolType Ptr Tool
For i As Integer = 0 To Tools.Count - 1
Tool = Tools.Item(i)
If Tool->LoadType = LoadTypes.BeforeCompile Then Tool->Execute
Next
Dim As Integer iLine
WLet(MFFPathC, *MFFPath)
If CInt(InStr(*MFFPathC, ":") = 0) AndAlso CInt(Not StartsWith(*MFFPathC, "/")) Then WLet(MFFPathC, ExePath & "/" & *MFFPath)
WLet(BatFileName, ExePath + "/debug.bat")
Dim As Boolean Band, Yaratilmadi
ChDir(GetFolderName(*MainFile))
If Parameter = "Check" Then
WLet(ExeName, "chk.dll")
End If
If Dir(*ExeName) <> "" Then 'delete exe if exist
If *ExeName = ExePath OrElse Kill(*ExeName) <> 0 Then
ThreadsEnter()
ShowMessages(Str(Time) & ": " & ML("Cannot compile - the program is now running") & " " & *ExeName) '
ThreadsLeave()
Band = True
CompileResult = 0
Continue For
End If
End If
Dim As Integer Idx
Dim As ToolType Ptr CompilerTool
If Parameter = "Make" Then
Idx = pMakeTools->IndexOfKey(*CurrentMakeTool1)
If Idx <> -1 Then CompilerTool = pMakeTools->Item(Idx)->Object
ElseIf Parameter = "MakeClean" Then
Idx = pMakeTools->IndexOfKey(*CurrentMakeTool2)
If Idx <> -1 Then CompilerTool = pMakeTools->Item(Idx)->Object
Else
Idx = pCompilers->IndexOfKey(*CurrentCompiler)
If Idx <> -1 Then CompilerTool = pCompilers->Item(Idx)->Object
End If
If CompilerTool <> 0 Then
WLet(CompileWith, CompilerTool->GetCommand(, True))
End If
WAdd(CompileWith, " " & *FirstLine)
'If IncludeMFFPath Then WAdd CompileWith, " -i """ & *MFFPathC & """"
Dim CtlLibrary As Library Ptr
For i As Integer = 0 To ControlLibraries.Count - 1
CtlLibrary = ControlLibraries.Item(i)
If CtlLibrary <> 0 AndAlso CtlLibrary->Enabled Then
If EndsWith(CtlLibrary->IncludeFolder, Slash) Then
WAdd CompileWith, " -i """ & Left(CtlLibrary->IncludeFolder, Len(CtlLibrary->IncludeFolder) - 1) & """"
Else
WAdd CompileWith, " -i """ & CtlLibrary->IncludeFolder & """"
End If
End If
Next
For i As Integer = 0 To pIncludePaths->Count - 1
WAdd CompileWith, " -i """ & pIncludePaths->Item(i) & """"
Next
For i As Integer = 0 To pLibraryPaths->Count - 1
WAdd CompileWith, " -p """ & pLibraryPaths->Item(i) & """"
Next
WAdd CompileWith, " -d _DebugWindow_=" & Str(txtImmediate.Handle)
'WLet LogFileName, ExePath & "/Temp/debug_compil.log"
WLet(LogFileName2, ExePath & "/Temp/Compile.log")
Dim As UString OtherModuleFiles
If CInt(ProjectNode <> 0) AndAlso CInt(Project <> 0) AndAlso CInt(Project->PassAllModuleFilesToCompiler) Then
For i As Integer = 0 To ProjectNode->Nodes.Count - 1
If EndsWith(LCase(ProjectNode->Nodes.Item(i)->Text), ".bas") Then
If LCase(GetFileName(*MainFile)) <> LCase(ProjectNode->Nodes.Item(i)->Text) Then
OtherModuleFiles &= " """ & ProjectNode->Nodes.Item(i)->Text & """"
End If
Else
For j As Integer = 0 To ProjectNode->Nodes.Item(i)->Nodes.Count - 1
If EndsWith(LCase(ProjectNode->Nodes.Item(i)->Nodes.Item(j)->Text), ".bas") Then
If LCase(GetFileName(*MainFile)) <> LCase(ProjectNode->Nodes.Item(i)->Nodes.Item(j)->Text) Then
OtherModuleFiles &= " """ & ProjectNode->Nodes.Item(i)->Nodes.Item(j)->Text & """"
End If
End If
Next
End If
Next
End If
If InStr(*CompileWith, "{S}") > 0 Then
WLet(fbcCommand, Replace(*CompileWith, "{S}", """" & GetFileName(*MainFile) & """" & OtherModuleFiles))
Else
WLet(fbcCommand, """" & GetFileName(*MainFile) & """" & OtherModuleFiles & " " & *CompileWith)
End If
If Parameter <> "" AndAlso Parameter <> "Make" AndAlso Parameter <> "MakeClean" Then
If Parameter = "Check" Then WAdd fbcCommand, " -x """ & *ExeName & """"
End If
If CInt(Parameter = "Make") OrElse CInt(CInt(Parameter = "Run") AndAlso CInt(UseMakeOnStartWithCompile) AndAlso CInt(FileExists(GetFolderName(*MainFile) & "/makefile") OrElse FileExists(*ProjectPath & "/makefile"))) Then
Dim As String Colon = ""
#ifdef __USE_GTK__
Colon = ":"
#endif
WLet(PipeCommand, """" & *MakeToolPath1 & """ FBC" & Colon & "=""""""" & *FbcExe & """"""" XFLAG" & Colon & "=""-x """"" & *ExeName & """""""" & IIf(UseDebugger, " GFLAG" & Colon & "=-g", "") & " " & *Make1Arguments)
ElseIf Parameter = "MakeClean" Then
WLet(PipeCommand, """" & *MakeToolPath2 & """ " & *Make2Arguments)
Else
WLet(PipeCommand, """" & *FbcExe & """ " & *fbcCommand)
End If
' ' for better showing
' #ifdef __USE_GTK__
' *PipeCommand=Replace(Replace(*PipeCommand,"\","/"),"/./","/")
' #else
' *PipeCommand=Replace(Replace(*PipeCommand,"/","\"),"\.\","\")
' #endif
'OPEN *BatFileName For Output As #FileOut
'Print #FileOut, *fbcCommand + " > """ + *LogFileName + """" + " 2>""" + *LogFileName2 + """"
'Close #FileOut
'Shell("""" + BatFileName + """")
If CBool(Project <> 0) AndAlso (Not EndsWith(*Project->FileName, ".vfp")) AndAlso FileExists(*Project->FileName & "/gradlew") Then
Dim As String gradlewFile, gradlewCommand
If Parameter = "Bundle" Then
gradlewCommand = "bundleRelease"
ElseIf Parameter = "APK" Then
gradlewCommand = "assembleRelease"
Else
gradlewCommand = "assembleDebug"
End If
ChDir(*Project->FileName)
#ifdef __FB_WIN32__
gradlewFile = "gradlew.bat"
#else
gradlewFile = "./gradlew"
#endif
WLet(PipeCommand, gradlewFile & " " & gradlewCommand)
Dim As Integer Fn1 = FreeFile_
Open gradlewFile For Input As #Fn1
Dim pBuff As WString Ptr
Dim As Integer FileSize
Dim As WStringList Lines
FileSize = LOF(Fn1)
WReAllocate(pBuff, FileSize)
Do Until EOF(Fn1)
LineInputWstr Fn1, pBuff, FileSize
Lines.Add *pBuff
Loop
CloseFile_(Fn1)
WDeAllocate pBuff
Dim As Integer Fn2 = FreeFile_
Open gradlewFile For Output As #Fn2
For i As Integer = 0 To Lines.Count - 1
If StartsWith(Lines.Item(i), "set FBC=") Then
Print #Fn2, "set FBC=" & *FbcExe
ElseIf StartsWith(Lines.Item(i), "set MFF=") Then
Print #Fn2, "set MFF=" & *MFFPathC
ElseIf StartsWith(Lines.Item(i), "set NDK=") Then
Print #Fn2, "set NDK=" & *Project->AndroidNDKLocation
Else
Print #Fn2, Lines.Item(i)
End If
Next i
CloseFile_(Fn2)
Else
If CInt(Parameter = "Make") OrElse CInt(Parameter = "MakeClean") OrElse CInt(CInt(Parameter = "Run") AndAlso CInt(UseMakeOnStartWithCompile) AndAlso CInt(FileExists(GetFolderName(*MainFile) & "/makefile") OrElse FileExists(*ProjectPath & "/makefile"))) Then
If FileExists(GetFolderName(*MainFile) & "/makefile") Then
ChDir(GetFolderName(*MainFile))
Else
ChDir(*ProjectPath)
End If
Else
ChDir(GetFolderName(*MainFile))
End If
End If
'Shell(*fbcCommand + "> """ + *LogFileName + """" + " 2> """ + *LogFileName2 + """")
'Open Pipe *fbcCommand + "> """ + *LogFileName + """" + " 2> """ + *LogFileName2 + """" For Input As #Fn
'Close #Fn
'PipeCmd "", *PipeCommand & " > """ + *LogFileName + """" + " 2> """ + *LogFileName2 + """"
Dim As Long nLen, nLen2
Dim As Boolean Log2_, ERRGoRc
Dim As Integer Result = -1
Dim Buff As WString * 2048 ' for V1.07 Line Input not working fine
#ifdef __USE_GTK__
WLetEx(PipeCommand, *PipeCommand & " 2> """ + *LogFileName2 + """", True)
#else
'WLetEx PipeCommand, """" & *PipeCommand & " 2> """ + *LogFileName2 + """" & """", True
#endif
If Parameter <> "Check" Then
ThreadsEnter()
ShowMessages(Str(Time) + ": " + IIf(Parameter = "MakeClean", ML("Clean"), ML("Compilation")) & ": " & *PipeCommand + WChr(13) + WChr(10))
ThreadsLeave()
End If
Dim As UShort bFlagErr
Dim As Double CompileElapsedTime = Timer
'Dim As String TmpStr, TmpStrKey = "@freebasic compiler @copyright @standalone @creating import library @target @backend @compiling @compiling rc @compiling c @assembling @linking @line "
#ifdef __USE_GTK__
Dim As Integer Fn = FreeFile_
If Open Pipe(*PipeCommand For Input As #Fn) = 0 Then
While Not EOF(Fn)
Line Input #Fn, Buff
If Len(Trim(Buff)) <= 1 OrElse StartsWith(Trim(Buff), "|") Then Continue While
ThreadsEnter()
ShowMessages(Buff, False)
ThreadsLeave()
'nPos1 = -1
'nPos = InStr(Buff, ":")
'If nPos < 1 Then nPos = InStr(Buff, " ")
'If nPos < 1 Then
' nPos = Len(Buff) + 1
' TmpStr = Buff
'Else
' TmpStr = Left(Buff, nPos - 1)
'End If
'If InStr(Buff, "Error!") Then ERRGoRc = True
'nPos1 = InStr(LCase(tmpStrKey), "@" & LCase(TmpStr))
'If CBool(nPos1 > 0) OrElse ERRGoRc Then
' ThreadsEnter()
' ShowMessages Str(Time) & ": " & ML(TmpStr) & " " & Trim(Mid(Buff, nPos))
' ThreadsLeave()
' NumberWarning = 0 : NumberErr = 0 : NumberInfo = 0
'Else
If Not (StartsWith(Buff, "FreeBASIC Compiler") OrElse StartsWith(Buff, "Copyright ") OrElse StartsWith(Buff, "standalone") OrElse StartsWith(Buff, "target:") _
OrElse StartsWith(Buff, "compiling:") OrElse StartsWith(Buff, "compiling C:") OrElse StartsWith(Buff, "assembling:") OrElse StartsWith(Buff, "compiling rc:") _
OrElse StartsWith(Buff, "linking:") OrElse StartsWith(Buff, "OBJ file not made") OrElse StartsWith(Buff, "compiling rc failed:") _
OrElse StartsWith(Buff, "creating import library:") OrElse StartsWith(Buff, "backend:") OrElse StartsWith(Buff, "Restarting fbc") OrElse StartsWith(Buff, "archiving:") OrElse StartsWith(Buff, "creating:")) Then
bFlagErr = SplitError(Buff, ErrFileName, ErrTitle, iLine)
If bFlagErr = 2 Then
NumberErr += 1
ElseIf bFlagErr = 1 Then
NumberWarning += 1
Else
NumberInfo += 1
End If
If bFlagErr >= 0 Then
ThreadsEnter()
If *ErrFileName <> "" AndAlso InStr(*ErrFileName, "/") = 0 AndAlso InStr(*ErrFileName, "\") = 0 Then WLet(ErrFileName, GetFolderName(*MainFile) & *ErrFileName)
lvErrors.ListItems.Add *ErrTitle, IIf(bFlagErr = 1, "Warning", IIf(bFlagErr = 2, "Error", "Info"))
lvErrors.ListItems.Item(lvErrors.ListItems.Count - 1)->Text(1) = WStr(iLine)
lvErrors.ListItems.Item(lvErrors.ListItems.Count - 1)->Text(2) = *ErrFileName
'ShowMessages(Buff, False)
ThreadsLeave()
End If
End If
Wend
End If
CloseFile_(Fn)
#else
#define BufferSize 2048
Dim si As STARTUPINFO
Dim pi As PROCESS_INFORMATION
Dim sa As SECURITY_ATTRIBUTES
Dim hReadPipe As HANDLE
Dim hWritePipe As HANDLE
Dim sBuffer As ZString * BufferSize
Dim sOutput As UString
Dim bytesRead As DWORD
Dim result_ As Integer
sa.nLength = SizeOf(SECURITY_ATTRIBUTES)
sa.lpSecurityDescriptor = NULL
sa.bInheritHandle = True
If CreatePipe(@hReadPipe, @hWritePipe, @sa, 0) = 0 Then
ShowMessages(ML("Error: Couldn't Create Pipe"), False)
CompileResult = 0
Continue For
End If
si.cb = Len(STARTUPINFO)
si.dwFlags = STARTF_USESTDHANDLES Or STARTF_USESHOWWINDOW
si.hStdOutput = hWritePipe
si.hStdError = hWritePipe
si.wShowWindow = 0
If CreateProcess(0, PipeCommand, @sa, @sa, 1, NORMAL_PRIORITY_CLASS, 0, 0, @si, @pi) = 0 Then
ShowMessages(ML("Error: Couldn't Create Process"), False)
CompileResult = 0
Continue For
End If
CloseHandle hWritePipe
Dim As Integer Pos1, FirstErrFlag
Do
result_ = ReadFile(hReadPipe, @sBuffer, BufferSize, @bytesRead, ByVal 0)
sBuffer = Left(sBuffer, bytesRead)
Pos1 = InStrRev(sBuffer, Chr(10))
If Pos1 > 0 Then
Dim res() As WString Ptr
sOutput += Left(sBuffer, Pos1 - 1)
If InStr(sOutput, "GoRC.exe' terminated with exit code") > 0 Then
sOutput = Replace(sOutput, Chr(13, 10), " ")
ERRGoRc = True
ElseIf InStr(sOutput, "of Resource Script ") > 0 Then
sOutput = Replace(sOutput, Chr(13, 10), " ")
End If
Split sOutput, Chr(10), res()
For i As Integer = 0 To UBound(res) 'Copyright
ShowMessages(*res(i), False)
If Len(Trim(*res(i))) <= 1 OrElse StartsWith(Trim(*res(i)), "|") Then Continue For
If InStr(*res(i), Chr(13)) > 0 Then *res(i) = Left(*res(i), Len(*res(i)) - 1)
'nPos = InStr(*res(i), ":")
'If nPos < 1 Then nPos = InStr(*res(i), " ")
'If nPos < 1 Then
' nPos = Len(*res(i)) + 1
' TmpStr = *res(i) '"standalone" ' Hanving ASCii CR
'Else
' TmpStr = Left(*res(i), nPos - 1)
'End If
'nPos1 = InStr(LCase(tmpStrKey), "@" & LCase(TmpStr)) ' so can't with " " for standalone + Chr(13)
'If nPos1 > 0 OrElse ERRGoRc Then
'ShowMessages Str(Time) & ": " & ML(TmpStr) & " " & Trim(Mid(*res(i), nPos))
If Not (StartsWith(*res(i), "FreeBASIC Compiler") OrElse StartsWith(*res(i), "Copyright ") OrElse StartsWith(*res(i), "standalone") OrElse StartsWith(*res(i), "target:") _
OrElse StartsWith(*res(i), "backend:") OrElse StartsWith(*res(i), "compiling:") OrElse StartsWith(*res(i), "compiling C:") OrElse StartsWith(*res(i), "assembling:") _
OrElse StartsWith(*res(i), "compiling rc:") OrElse StartsWith(*res(i), "linking:") OrElse StartsWith(*res(i), "OBJ file not made") OrElse StartsWith(*res(i), Space(14)) _
OrElse StartsWith(*res(i), "creating import library:") OrElse StartsWith(*res(i), "compiling rc failed:") OrElse StartsWith(*res(i), "Restarting fbc") OrElse StartsWith(*res(i), "creating:") OrElse StartsWith(*res(i), "archiving:") OrElse InStr(*res(i), "ld.exe") > 0) Then
bFlagErr = SplitError(*res(i), ErrFileName, ErrTitle, iLine)
If bFlagErr = 2 Then
NumberErr += 1
ElseIf bFlagErr = 1 Then
NumberWarning += 1
Else
NumberInfo += 1
End If
If bFlagErr >= 0 Then
If *ErrFileName <> "" AndAlso InStr(*ErrFileName, "/") = 0 AndAlso InStr(*ErrFileName, "\") = 0 Then WLet(ErrFileName, GetFolderName(*MainFile) & *ErrFileName)
lvErrors.ListItems.Add *ErrTitle, IIf(bFlagErr = 1, "Warning", IIf(bFlagErr = 2, "Error", "Info"))
lvErrors.ListItems.Item(lvErrors.ListItems.Count - 1)->Text(1) = WStr(iLine)
lvErrors.ListItems.Item(lvErrors.ListItems.Count - 1)->Text(2) = *ErrFileName
End If
End If
Deallocate res(i): res(i) = 0
sOutput = ""
Next i
Erase res
sOutput = Mid(sBuffer, Pos1 + 1)
Else
If FirstErrFlag < 1 AndAlso (InStr(LCase(sOutput), "compiling") OrElse result_ = False) Then
sOutput += Chr(10) + sBuffer
FirstErrFlag +=1
Else
sOutput += sBuffer
End If
End If
Loop While result_
CloseHandle pi.hProcess
CloseHandle pi.hThread
CloseHandle hReadPipe
#endif
#ifdef __USE_GTK__
Yaratilmadi = g_find_program_in_path(ToUtf8(*ExeName)) = NULL
#else
Yaratilmadi = Dir(*ExeName) = ""
#endif
'Delete the default ManifestFile And IcoFile
'If ManifestIcoCopy Then Kill GetFolderName(*MainFile) & "Manifest.xml": Kill GetFolderName(*MainFile) & "Form1.rc": Kill GetFolderName(*MainFile) & "Form1.ico"
#ifdef __USE_GTK__
Fn = FreeFile_
Result = -1
Result = Open(*LogFileName2 For Input Encoding "utf-8" As #Fn)
If Result <> 0 Then Result = Open(*LogFileName2 For Input Encoding "utf-16" As #Fn)
If Result <> 0 Then Result = Open(*LogFileName2 For Input Encoding "utf-32" As #Fn)
If Result <> 0 Then Result = Open(*LogFileName2 For Input As #Fn)
If Result = 0 Then
While Not EOF(Fn)
Line Input #Fn, Buff
'If Trim(*Buff) <> "" Then lvErrors.ListItems.Add *Buff
bFlagErr = SplitError(Buff, ErrFileName, ErrTitle, iLine)
If bFlagErr = 2 Then
NumberErr += 1
ElseIf bFlagErr = 1 Then
NumberWarning += 1
Else
NumberInfo += 1
End If
ThreadsEnter()
If *ErrFileName <> "" AndAlso InStr(*ErrFileName, "/") = 0 AndAlso InStr(*ErrFileName, "\") = 0 Then WLet(ErrFileName, GetFolderName(*MainFile) & *ErrFileName)
lvErrors.ListItems.Add *ErrTitle, IIf(InStr(*ErrTitle, "warning"), "Warning", IIf(InStr(LCase(*ErrTitle), "error"), "Error", "Info"))
lvErrors.ListItems.Item(lvErrors.ListItems.Count - 1)->Text(1) = WStr(iLine)
lvErrors.ListItems.Item(lvErrors.ListItems.Count - 1)->Text(2) = *ErrFileName
ShowMessages(Buff, False)
ThreadsLeave()
'*LogText = *LogText & *Buff & WChr(13) & WChr(10)
Log2_ = True
Wend
End If
CloseFile_(Fn)
#endif
ThreadsEnter()
ShowMessages("")
If lvErrors.ListItems.Count <> 0 Then
ptabBottom->Tabs[1]->Caption = IIf(NumberErr > 0, ML("Errors") & " (" & WStr(NumberErr) & " " & ML("Pos") & ")", "")
ptabBottom->Tabs[1]->Caption = IIf(NumberWarning > 0, ptabBottom->Tabs[1]->Caption & ML("Warnings") & " (" & WStr(NumberWarning) & " " & ML("Pos") & ")", ptabBottom->Tabs[1]->Caption)
ptabBottom->Tabs[1]->Caption = IIf(NumberInfo > 0, ptabBottom->Tabs[1]->Caption & ML("Messages") & " (" & WStr(NumberInfo) & " " & ML("Pos") & ")", ptabBottom->Tabs[1]->Caption)
ShowMessages(Str(Time) & ": " & ML("found") & " " & ptabBottom->Tabs[1]->Caption, False)
Else
ptabBottom->Tabs[1]->Caption = ML("Errors")
End If
ThreadsLeave()
For i As Integer = 0 To Tools.Count - 1
Tool = Tools.Item(i)
If Tool->LoadType = LoadTypes.AfterCompile Then Tool->Execute
Next
If Yaratilmadi Or Band Then
ThreadsEnter()
If Parameter <> "Check" Then
ShowMessages(Str(Time) & ": " & ML("Do not build file.")) & " " & ML("Elapsed Time") & ": " & Format(Timer - CompileElapsedTime, "#0.00") & " " & ML("Seconds")
If (Not Log2_) AndAlso lvErrors.ListItems.Count <> 0 Then ptabBottom->Tabs[1]->SelectTab
ElseIf lvErrors.ListItems.Count <> 0 Then
ShowMessages(Str(Time) & ": " & ML("Checking ended.")) & " " & ML("Elapsed Time") & ": " & Format(Timer - CompileElapsedTime, "#0.00") & " " & ML("Seconds")
ptabBottom->Tabs[1]->SelectTab
Else
ShowMessages(Str(Time) & ": " & ML("No errors or warnings were found.")) & " " & ML("Elapsed Time") & ": " & Format(Timer - CompileElapsedTime, "#0.00") & " " & ML("Seconds")
End If
ThreadsLeave()
CompileResult = 0
Else
ThreadsEnter()
If InStr(*LogText, "warning") > 0 Then
If Parameter <> "Check" Then
ShowMessages(Str(Time) & ": " & ML("Layout has been successfully completed, but there are warnings.")) & " " & ML("Elapsed Time") & ": " & Format(Timer - CompileElapsedTime, "#0.00") & " " & ML("Seconds")
End If
Else
If Parameter <> "Check" Then
ShowMessages(Str(Time) & ": " & ML("Layout succeeded!")) & " " & ML("Elapsed Time") & ": " & Format(Timer - CompileElapsedTime, "#0.00") & " " & ML("Seconds")
Else
ShowMessages(Str(Time) & ": " & ML("Syntax errors not found!")) & " " & ML("Elapsed Time") & ": " & Format(Timer - CompileElapsedTime, "#0.00") & " " & ML("Seconds")
End If
End If
ThreadsLeave()
End If
Next k
ThreadsEnter()
StopProgress
ThreadsLeave()
WDeAllocate FbcExe
WDeAllocate PipeCommand
WDeAllocate ExeName
WDeAllocate LogText
WDeAllocate fbcCommand
WDeAllocate CompileWith
WDeAllocate MFFPathC
WDeAllocate FirstLine
WDeAllocate ErrTitle
WDeAllocate ErrFileName
WDeAllocate LogFileName
WDeAllocate LogFileName2
WDeAllocate BatFileName
WDeAllocate MainFile
WDeAllocate ProjectPath
Return CompileResult
Exit Function
ErrorHandler:
ThreadsEnter()
MsgBox ErrDescription(Err) & " (" & Err & ") " & _
"in line " & Erl() & " " & _
"in function " & ZGet(Erfn()) & " " & _
"in module " & ZGet(Ermn())
ThreadsLeave()
End Function
Sub CreateKeyStore
#ifndef __USE_GTK__