-
Notifications
You must be signed in to change notification settings - Fork 0
/
DB Manager.sb
1922 lines (1654 loc) · 87 KB
/
DB Manager.sb
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
'Copyrighted Software 2016. Abhishek Sathiabalan . All Rights Reserved. Governed by EULA.
'For a timeline of release information please check Assets\Change_Log Table
'v1119
'Support for TEMP Tables has been added by a Third Party dev to the underlying dll and to hene this program as well.
'New Table Menu added through Plugin Interface . You must copy and paste the SQL Code until a further revision
'Refactored Load Settings so manually editing the settings file looks less messy
'Save Settings : File will not be rewritten unless changes have been made
'LOAD DB and GET Path have been made into functions.
'Revised ADD UI Function to add for the ability to set tooltips and the like.
'Added Support for toggling between multiple database connections
'Fixed Font Size Related bugs
'v1120
'Refactorization
'Moved Define New Table Function into the Main Program due to bugs
'Fixed Generate Query Function
'Statistics Page Function
'Updated All Plugins to become SQL Compliant
'Updated Import CSV to hopefully work better
' WARNING Import CSV does not work in the following situations:
' 1) 1 Line of Data spans 2 Lines seperated by a CLLF
' 2)IMPORT CSV IS Prone to cause the application to stop responding for larger files
'v1121
' Removed CMD Parser for default use
'Fixed bug with Master Table Combo Box
'Made Import CSV roughly 4x faster on all file sizes. Real savings seen in larger files
'Added default Extensions
'Added .plugins to DBM CLI
'Added in Memory databases
'Added time taken to insert data for commands and fetch data for querys
'Added invert Search function
StartTime[0] = Clock.ElapsedMilliseconds
GraphicsWindow.Show()
MainWindowID = LDWindows.CurrentID
LDGraphicsWindow.ExitOnClose = "False"
LDGraphicsWindow.CancelClose = "True"
LDGraphicsWindow.Closing = Closing
'______________________________________________________________________________
' Functions List ( Mini API of sorts )
'______________________________________________________________________________
QueryFunction = "Query"
CommandFunction = "Command"
TransactionFunction = "TransactionRecord"
RunModParserFunction = "MOD_RUN_Parser"
Function_XML_Attributes = "XML_Fetch_All"
Function_Handler_ComboBox = "ComboBoxChanged"
Function_Handler_EULA = "EULA_Handler"
Function_Handler_MainMenu = "MainMenuHandler"
Function_Handler_ExportCB = "Export_CB_Handler"
Function_Handler_DefineTable = "Create_Table_UI_CMDS"
Function_Handler_CreateStatistics = "Create_Statistics_Page"
Function_Handler_Universal = "Universal_Handler"
Function_UI_Add = "Add_UI_Controls"
Function_UI_Query = "Query_UI_Controls"
Function_Load_DB = "Load_DB"
Function_Get_DB = "GetPath"
Function_RunMod_Parser = RunModParserFunction
Function_Command = CommandFunction
Function_Query = QueryFunction
Function_Query_Emulator ="Query_SQLITE_Emulator"
Function_Log = "Log"
Function_FileRead = "FileRead"
Function_Command_Parser = "Command_Parse"
Function_Transaction = TransactionFunction
Function_logCB = "LogCBFunction"
logfunction = Function_Log
'______________________________________________________________________________
' List Names
'______________________________________________________________________________
Export_T2 = "Export T2"
Export_T1 = "Export T1"
TrackDefaultTable = "TrackDefaultTable"
List_Mod_Name = "Mod_Name"
List_Mod_Path = "Mod_Path"
List_Command_Parser = "Command_SQL_Parser"
List_Command_Parser_Status = "Command_SQL_Parser_Status"
List_Command_Parser_OnFail = "Command_SQL_Parser_Fail"
List_Command_Parser_OnFail_Index = "Command_SQL_Parser_Fail_Index"
List_UI_Name = "UI_Name"
List_UI_Handler = "UI_Handler"
List_UI_Action = "UI_Action"
List_Stack_Trace = "Stack_Trace"
List_Stack_Time = "Stack_Time"
List_SCHEMA_Table = "SCHEMA_TABLE"
List_SCHEMA_View = "SCHEMA_VIEW"
List_Schema_Index = " SCHEMA_INDEX"
List_DB_Path = "DB_Path"
List_DB_Name = "DB_Name"
List_DB_ShortName = "DB_SName"
List_DB_Tracker = "DB_Tracking"
List_Query_Time = "Query_Time"
List_CMD_Time = "CMD_Time"
List_Time_Refer = "Time_Ref"
List_File_Read = "File_Read"
'______________________________________________________________________________
' Variables
'______________________________________________________________________________
Register = "Register"
NO_DB = "<None>"
LDUtilities.ShowErrors = "False"
LDUtilities.ShowFileErrors= "False"
LDUtilities.ShowNoShapeErrors = "False"
LDEvents.Error = ErrorHandler
debug_mode = 0 '1=On;0=Off(Default)
debug_Parser = 0 'Debugs the CMD Function Parser . Seperated bc otherwise it creates a lot of noise in the debug output
EULA_Test = 0 'Default 0
Functions_Support_Obselete = 0 'If set to true then the program will run Obselete Functions , otherwise it will return an error .
copyrightDate = 2016
ProductID = "DBM"
PrgmVersionID = 1121
title = "Database Manager (" + ProductID + ") v" + PrgmVersionID + " "
Self = Program.Directory +"\DB Manager.exe"
Booleans ="True=1;False=0;0=False;1=True;"
Toggle_Booleans = "0=1;1=0;True=False;False=True;"
UserName = LDFile.UserName
'______________________________________________________________________________
' Not to be set by Settings
'______________________________________________________________________________
TabKey = Text.GetCharacter(9)
CLLF = Text.GetCharacter(10)
DoubleQuotesCharacter = Text.GetCharacter(34)
DQC = DoubleQuotesCharacter
XML_Version_Number ="1.0"
MOD_Running = 0 'Temp Fake Variable ; Add Functionality Later
SQLFunctionsList = "1=AVG;2=COUNT;3=MAX;4=MIN;5=SUM;6=TOTAL;7=Hex;8=Length;9=Lower;10=round;11=Trim;12=Upper;"
SQLFunctionsList = Text.ConvertToUpperCase( SQLFunctionsList )
DB_Engines_Types = "1=MySQL;2=Odbc;3=Oledb;4=SQLite;5=SqlServer;"
DB_Engine_Username = "1=1;2=1;3=1;4=0;5=0;"
DB_Engine_Password = "1=1;2=1;3=1;4=0;5=0;"
Engine_Mode = 4
LOG_DB_SQL = "CREATE TABLE IF NOT EXISTS Log (ID Integer PRIMARY KEY," +DQC +"UTC DATE" + DQC +" TEXT," + DQC +"UTC TIME" + DQC +" TEXT,Date TEXT,Time TEXT,USER TEXT,ProductID TEXT,ProductVersion INTEGER,Type TEXT,Event TEXT);"
LOG_DB_SQL_View = "CREATE VIEW IF NOT EXISTS " + DQC + "LOCAL TIME" + DQC +" AS SELECT ID,DATE,TIME,USER,PRODUCTID,PRODUCTVERSION,Type,Event From Log;"
LOG_DB_SQL_View = LOG_DB_SQL_View +"CREATE VIEW IF NOT EXISTS " + DQC + "UTC TIME" + DQC +" AS Select ID," + DQC +"UTC DATE" + DQC +"," + DQC +"UTC TIME" + DQC +",USER,ProductID,ProductVersion,Type,Event From Log;"
LOG_DB_SQL_View = LOG_DB_SQL_View +"DROP VIEW IF EXISTS LOCAL_TIME;DROP VIEW IF EXISTS UTC_TIME;"
Transactions_SQL = "CREATE TABLE IF NOT EXISTS Transactions (ID INTEGER PRIMARY KEY," + DQC +"UTC DATE" + DQC +" TEXT," + DQC +"UTC TIME" + DQC +" TEXT,USER TEXT,PATH TEXT,DB TEXT,SNAME TEXT,SQL TEXT,Type TEXT,Reason TEXT);"
'______________________________________________________________________________
' File Operations
'______________________________________________________________________________
AssetPath = Program.Directory +"\Assets\"
logpath = AssetPath +"Log.csv"
LogDBpath = AssetPath +"Log.db"
TransactionDBpath = AssetPath +"Transactions.db"
EULAFile = AssetPath +"EULA.txt"
EULA_HTML_File = AssetPath +"EULA.html"
'EULAFile = EULA_HTML_File 'Allows HTML File to be used in place of TXT File
settingspath = AssetPath+"setting.txt"
ModPath = AssetPath +"Plugin\"
AutoRunMod_Path = AssetPath +"Auto Run Mod.txt"
HelpPath = AssetPath +"HELP Table.html"
External_Menu_Items_Path = AssetPath +"Menu.txt"
LocalizationsFolder = Program.Directory +"\Localization\"
LocalizationsLangFolder = Program.Directory +"\Localization\Lang\"
LocalizationsFilesArray = File.GetFiles ( LocalizationsFolder )
OnlineEULaPath = "https://drive.google.com/uc?export=download&id=0B2v4xbFnpKvRNTFKckFKLVNNUDg" 'EULA Path
OnlineEULAHTMLPath = "https://drive.google.com/uc?export=download&id=0B2v4xbFnpKvRSFVqQVBqelJoS2s"
OnlineDB_Refrence_Location = "https://docs.google.com/uc?id=0B2v4xbFnpKvRVmNVODZ4bnppd3c&export=download" 'Update DB Path
Ping = LDNetwork.Ping("8.8.8.8",500)
If Ping <> "-1" Then 'Pings Google DNS Server ; This server will probably never be down
StartTime[1] = Clock.ElapsedMilliseconds
LDNetwork.DownloadFile(EULAFile,OnlineEULaPath)
LDNetwork.DownloadFile(EULA_HTML_File,OnlineEULAHTMLPath)
EndTime[1] = Clock.ElapsedMilliseconds
EndIf
LoadedFile = 0
SortByMode = 1
RestoreSettings = 0
args = ""
'Gets EULA Version
EULA_Version = LDText.Replace(File.ReadLine(EULAFile,1)," ","")
For I = 1 To Text.GetLength(EULA_Version)
Character = Text.GetSubText(EULA_Version,I,1)
If Character <> TabKey Then
NEULA_Version = Text.Append(NEULA_Version, Character )
EndIf
EndFor
EULA_Version = NEULA_Version
NEULA_Version =""
'______________________________________________________________________________
' End of No Settings Zone
'______________________________________________________________________________
Startup()
Sub Startup 'Akin to Main in C#
LDList.Add(List_Stack_Trace,"Startup") 'Adds subroutine used for better debugging purposes
LoadSettings()
Int_DB() 'Creates The Databases used for logging error and transactions
MOD_Find_All() 'Finds all Mods Placed in the Mod Folder
Localization_XML()
LDCall.Function2( Function_Log , "Program Started",LangList["Application"]) '// Localize
If Program.ArgumentCount = 1 Then
LDCall.Function2(Function_Load_DB,4, LDCall.Function( Function_Get_DB ,"") )
EndIf
If (EULA_Accepted = "True") And (EULA_Accepted_By = LDFile.UserName) And (EULA_Version = EULA_Accepted_Version) And (VersionID = PrgmVersionID) And EULA_Test = 0 Then
Startup_GUI()
Else 'Passes to EULA
If debug_mode = 1 Then
TextWindow.WriteLine( EULA_Accepted )
TextWindow.WriteLine( EULA_Accepted_By )
TextWindow.WriteLine( EULA_Version +":" + EULA_Accepted_Version )
TextWindow.WriteLine( VersionID +":"+ PrgmVersionID )
TextWindow.WriteLine( EULA_Test)
EndIf
SaveSettings()
EULA_UI()
EndIf
EndSub
Sub Int_DB
LDList.Add(List_Stack_Trace,"Int_DB")
IF LDFile.Exists(AssetPath) = "False" Or LDFile.Exists(LocalizationsFolder) = "False" Or LDFile.Exists( ModPath ) = "False" Then
File.CreateDirectory(AssetPath)
File.CreateDirectory(LocalizationsFolder )
File.CreateDirectory(ModPath )
EndIf
If LDFile.Exists( AutoRunMod_Path ) = "False" Then
File.AppendContents( AutoRunMod_Path , "# This file designates the Mod and the subroutine the main program should call on the start of the program. Use this to insert your UI at startup. The character # marks the line as commented. ")
EndIf
If LDFile.Exists(logpath) = "False" Then
File.AppendContents( logpath , "id,local date,local time,Username,Product ID,Version ,Type of Error,Log Event")
EndIf
LOG_DB= LDDataBase.ConnectSQLite(LogDBpath) ' Creates Log DB if it does not exist
TransactionDB = LDDataBase.ConnectSQLite( TransactionDBpath ) 'Creates Transaction DB Path
LDList.Add(List_DB_Path, "<None>" ) '//Localize
LDList.Add(List_DB_Name, "<None>" )
LDList.Add(List_DB_ShortName,"<None>") '//Localize
LDList.Add(List_DB_Path, LogDBpath )
LDList.Add(List_DB_Name, Log_DB )
LDList.Add(List_DB_ShortName,"Master Log")
LDList.Add(List_DB_Path, TransactionDBpath )
LDList.Add(List_DB_Name, TransactionDB )
LDList.Add(List_DB_ShortName,"Master Transaction Log")
LDDataBase.Command( TransactionDB , Transactions_SQL)
LDCall.Function4( CommandFunction , LOG_DB , LOG_DB_SQL,"App","Auto Creation Statements" ) ' Cannot be Localized
LDCall.Function4( CommandFunction , LOG_DB , LOG_DB_SQL_View ,"App","Auto Creation Statements")'Cannot be Localized
LDCall.Function4( CommandFunction , TransactionDB , Transactions_SQL ,"App","Auto Creation Statements") ' Cannot be Localized
LogNumber = LDDataBase.Query( LOG_DB,"SELECT COUNT(ID) From Log;","","True")
LogNumber = LogNumber[1]["COUNT(ID)"]
LDCall.Function5(TransactionFunction , "App" , LOG_DB +"| LOG" ,"SELECT COUNT(ID) From Log;" ,"Query", " Auto Query Log Count") 'Cannot be Localized
TransactionNumber = LDDataBase.Query( TransactionDB,"SELECT COUNT(ID) From Transactions","","True")
TransactionNumber = TransactionNumber[1]["COUNT(ID)"]
EndSub
Sub Startup_GUI
LDList.Add(List_Stack_Trace,"Startup_GUI")
GraphicsWindow.Clear()
GraphicsWindow.Hide()
GraphicsWindow.Show()
LDScrollBars.Add( Listview_Width + 500 ,Listview_Height )
Pre_MainMenuUI()
MOD_READ_AutoRunFile()
MOD_AutoRun()
LDCall.Function2( Function_Log , "Startup Time: " +(Clock.ElapsedMilliseconds - StartTime[0]) +" (ms)" ,LangList["UI"])
MainMenuUI()
EndSub
Sub Localization_XML
LDList.Add(List_Stack_Trace,"Localization_XML")
XML_Localization_Path = LocalizationsFolder + Localization_lang+".xml"
Localization_XML_DOC = LDxml.Open(XML_Localization_Path)
If LDFile.Exists(XML_Localization_Path ) Then
LDxml.FirstNode()
LDxml.FirstChild()
LDxml.LastChild()
XML_Array = LDCall.Function( Function_XML_Attributes , "")
If XML_Array[1]["language"] = Localization_lang Then
LangList[ LDText.Replace( XML_Array[4] ,"_"," ") ] = XML_Array[6]
ElseIf debug_mode = 1 Then
TextWindow.WriteLine ("Rejected: " + XML_Array )
EndIf
While LDxml.PreviousSibling() = "SUCCESS"
XML_Array = LDCall.Function( Function_XML_Attributes , "")
If XML_Array[1]["language"] = Localization_lang Then
LangList[ LDText.Replace( XML_Array[4] ,"_"," ") ] = XML_Array[6]
ElseIf debug_mode = 1 Then
TextWindow.WriteLine ("Rejected: " + XML_Array )
EndIf
EndWhile
Else
LDCall.Function2( Function_Log , "Localization XML Missing","Application") 'DO NOT LOCALIZE EVER! This error indicates the localization file is missing!!
EndIf
Localization_Temp = File.ReadContents( LocalizationsLangFolder +Localization_lang+".txt" )
For I = 1 To Array.GetItemCount( LocalizationsFilesArray )
MLanguages[I] = LDFile.GetFile( LocalizationsFilesArray[I] )
Localization_List[ MLanguages[I] ] = Localization_Temp[MLanguages[I]]
LDList.Add("ISO_Lang", MLanguages[I] )
LDList.Add("ISO_Text" , Localization_List[ MLanguages[I] ] )
EndFor
EndSub
Sub LoadSettings
LDList.Add(List_Stack_Trace,"LoadSettings")
If RestoreSettings = 0 Then
Settings = File.ReadContents(settingspath)
EndIf
Listview_Width = Settings["Listview_Width"]
Listview_Height = Settings["Listview_Height"]
VersionID = Settings["VersionID"]
lastFolder = Settings["LastFolder"]
SupportedExtensions = Settings["Extensions"]
deliminator = Settings["Deliminator"]
Transactions_mode = Settings["Transactions"]
Localization_lang = Settings["Language"]
EULA_Accepted = Settings["EULA"]
EULA_Accepted_By = Settings["EULA_By"]
EULA_Accepted_Version = Settings["EULA_Version"]
OS_Dir = Settings["OS_Dir"]
debug_mode = Settings["debug_mode"]
debug_Parser = Settings["debug_parser"]
AssetPath = Settings["Asset_Dir"]
logpath = Settings["Log_Path"]
LogDBpath = Settings["Log_DB_Path"]
Transaction_DB_Path_Temp = Settings["Transaction_DB"]
Transactions_mode_Query = Settings["Transaction_Query"]
Transactions_mode_Cmd = Settings["Transaction_Commands"]
Null_Settings = "1=Listview_Width;2=Listview_Height;3=VersionID;4=Extensions;5=Language;6=Transactions;7=Transaction_Query;8=Transaction_Commands;9=debug_parser;10=debug_mode;11=Deliminator;12=TimeOut;"
Null_Settings = Null_Settings +"13=LastFolder;14=OS_Dir;15=Asset_Dir;16=Log_Path;17=Log_DB_Path;18=Transaction_DB;"
Setting_Default = "1=" + (Desktop.Width - 400 ) +";2=" + (Desktop.Height - 150) +";3="+PrgmVersionID+";5=en;6=0;7=0;8=0;9=0;10=0;11=,;12=10000;"
Setting_Default[4] = "1=db;2=sqlite;3=sqlite3;4=db3;5=*;"
Setting_Default[13] = LDFile.DocumentsFolder
Setting_Default[14] = "C:\Windows\System32\"
Setting_Default[15] = Program.Directory +"\Assets\"
Setting_Default[16] = Setting_Default[15] + "Log.csv"
Setting_Default[17] = Setting_Default[15] + "Log.db"
Setting_Default[18] = Setting_Default[15] + "Transactions.db"
Setting_Files = "15=1;16=1;17=1;18=1;"
For I = 1 To Array.GetItemCount( Null_Settings )
If Settings[ Null_Settings[I] ] = "" Then
Settings[ Null_Settings[I] ] = Setting_Default[I]
RestoreSettings = 1
EndIf
If ( Setting_Files[I] = 1 AND LDFile.Exists( Setting_Files[I] ) = "False" ) Then 'Run this check only in debug mode
Settings[ Null_Settings[I] ] = Setting_Default[I]
RestoreSettings = 1
EndIf
EndFor
If RestoreSettings = 1 Then
Listview_Width = Settings["Listview_Width"]
Listview_Height = Settings["Listview_Height"]
VersionID = Settings["VersionID"]
SupportedExtensions = Settings["Extensions"]
Localization_lang = Settings["Language"]
Transactions_mode = Settings["Transactions"]
lastFolder = Settings["LastFolder"]
OS_Dir = Settings["OS_Dir"]
debug_mode = Settings["debug_mode"]
debug_Parser = Settings["debug_parser"]
AssetPath = Settings["Asset_Dir"]
logpath = Settings["Log_Path"]
LogDBpath = Settings["Log_DB_Path"]
Transaction_DB_Path_Temp = Settings["Transaction_DB"]
EndIf
SaveSettings()
EndSub
Sub SaveSettings
LDList.Add(List_Stack_Trace,"SaveSettings")
If Settings <> File.ReadContents(settingspath) Then
status = File.WriteContents(settingspath,Settings)
EndIf
If status = "FAILED" Then
LDCall.Function2( Function_Log ,"Failed to save settings",LangList["UI"])
GraphicsWindow.ShowMessage(LangList["Failed Save Settings"] ,LangList["Error"]) 'Failed to Save Settings
EndIf
EndSub
Sub GetPath
LDList.Add(List_Stack_Trace,"GetPath")
If Program.ArgumentCount = 1 AND LoadedFile = 0 Then
return = Program.getArgument(1)
LoadedFile = 1 'Boolean Value indicating that the program has opened the data it recieved arguments for!
Else
If Engine_Mode = 4 Then
return = LDDialogs.OpenFile(SupportedExtensions,lastFolder+"\")
EndIf
EndIf
EndSub
Sub Load_DB
'2 Args
'1 = Engine Mode (Integer)
'2 = All other Arguments { Array | String }
LOAD_DB_Args = args
If LOAD_DB_Args[1] = 1 Then '//To DO
' LDDataBase.ConnectMySQL(Server, Username , Password , MySqlDB)
ElseIf LOAD_DB_Args[1] = 2 Then '//To DO
' LDDataBase.ConnectOdbc( ODBC_Driver , Server , Port , Username , Password , Options , ODBC_DB )
ElseIf LOAD_DB_Args[1] = 3 Then '//To DO
' LDDataBase.ConnectOleDb( OLDB_Provider , Server , OLDB_DB)
ElseIf LOAD_DB_Args[1] = 4 And LDFile.Exists(LOAD_DB_Args[2]) = "True" Then
If LDList.IndexOf(List_DB_Path,LOAD_DB_Args[2]) = 0 Then 'New Database Connection :)
databasepath = LOAD_DB_Args[2]
database = LDDataBase.ConnectSQLite(databasepath)
database_ShortName = LDFile.GetFile(databasepath)
LDCall.Function2(Function_Log, "OPENED : " + databasepath ,LangList["Application"])'//Localize
Settings["LastFolder"] = LDFile.GetFolder(databasepath)
SaveSettings()
LDList.Add(List_DB_Path, databasepath )
LDList.Add(List_DB_Name, database )
LDList.Add(List_DB_ShortName, database_ShortName )
LDList.Add(List_DB_Tracker,database_ShortName)
Else 'Existing Database connection
Load_DB_Index = LDList.IndexOf(List_DB_Path,LOAD_DB_Args[2])
databasepath = LDList.GetAt(List_DB_Path, Load_DB_Index )
database = LDList.GetAt(List_DB_Name, Load_DB_Index )
database_ShortName = LDList.GetAt(List_DB_ShortName, Load_DB_Index )
LDList.Add(List_DB_Tracker,database_ShortName)
LDCall.Function2(Function_Log, "OPENED : " + LOAD_DB_Args[2] ,LangList["Application"])'//Localize
EndIf
ElseIF LOAD_DB_Args[1] = 4 And LOAD_DB_Args[2] = "Memory" Then 'In Memory DB
Load_DB_Index = LDList.IndexOf(List_DB_Path,LOAD_DB_Args[2])
databasepath = LDFile.DocumentsFolder
database = LDList.GetAt(List_DB_Name, Load_DB_Index )
database_ShortName = LDList.GetAt(List_DB_ShortName, Load_DB_Index )
LDList.Add(List_DB_Tracker,database_ShortName)
LDCall.Function2(Function_Log, "OPENED : " + LOAD_DB_Args[2] ,LangList["Application"])'//Localize
ElseIf LOAD_DB_Args[1] = 5 Then '//To DO
' LDDataBase.ConnectSqlServer(Server , SQLServer_DB )
Else
If LOAD_DB_Args[1] = 4 And LOAD_DB_Args[2] <> "<None>" Then '//Localize
LDCall.Function2(Function_Log, "Program Failed to OPEN : " + LOAD_DB_Args[2],"Application" ) '//Localize
GraphicsWindow.ShowMessage("File Could not be found or opened .", "Fatal Error" ) '//Localize
Else
If LOAD_DB_Args[2] <> "<None>" Then
GraphicsWindow.ShowMessage("File Could not be found or opened .", "Fatal Error" ) '//Localize
EndIf
EndIf
Endif
EndSub
'______________________________________________________________________________
' EULA UI
'______________________________________________________________________________
Sub EULA_UI
LDList.Add(List_Stack_Trace,"EULA_UI")
GraphicsWindow.Show()
GraphicsWindow.Left = Desktop.Width / 3
GraphicsWindow.Top = Desktop.Height / 4
GraphicsWindow.Title = title + "EULA"
defaultWidth = GraphicsWindow.Width
defaultHeight= GraphicsWindow.Height
LDControls.RichTextBoxReadOnly = "True"
If LDFile.GetExtension(EULAFile) = "html" Then 'For html files
eulatextbox = LDControls.AddBrowser(600,350,"file:///"+EULAFile)
Else 'RTF Text Box
eulatextbox = LDControls.AddRichTextBox(600,350)
EndIf
Controls.Move(eulatextbox,10,10)
LDControls.RichTextBoxReadOnly = "False"
OnlineEULACnts = LDText.Replace( File.ReadContents( EULAFile) , "<date>",copyrightDate )
If Ping = "-1" Then 'If Ping to Google DNS has failed add the following
LDCall.Function2( Function_Log ,LangList["Failed Load Online EULA"],LangList["Error"])
EULAContents = Text.Append("This is the EULA that came with this program. This may not be the most latest EULA. Subject to Section 5 Subsection C the most latest EULA can be found here:" +Text.GetCharacter(10) + OnlineEULaPath +Text.GetCharacter(10) ,File.ReadContents(EULAFile) )
Else
EULAContents = OnlineEULACnts
File.WriteContents(EULAFile, EULAContents)
EndIf
If EULAContents = "" Then 'NO EULA found.
LDCall.Function2( Function_Log , "NO EULA FOUND. Local or Online","UI")'//Localize
GraphicsWindow.ShowMessage("EULA could not be loaded. This program cannot start without its EULA." "EULA LOAD ERROR")'//Localize
Program.End()
Else
LDControls.RichTextBoxSetText(eulatextbox,EULAContents,"False")
EULAContents = ""
Ihaveread = LDControls.AddCheckBox("I have read and agree to this EULA.")
EULAaccept = Controls.AddButton("Accept",235,390)
EULADecline = Controls.AddButton("Decline",235+80,390)
Controls.Move(Ihaveread,190,365)
Controls.SetSize(EULAaccept,70,30)
Controls.SetSize(EULADecline,70,30)
LDCall.Function3( Function_UI_Add , Register , Ihaveread , Function_Handler_EULA )
LDCall.Function3( Function_UI_Add , Register , EULAaccept, Function_Handler_EULA )
LDCall.Function3( Function_UI_Add , Register , EULADecline, Function_Handler_EULA )
EndIf
Controls.ButtonClicked = Universal_BD
EndSub
Sub EULA_Handler
LDList.Add(List_Stack_Trace,"EULA_Handler")
If args[1] <> "" Then
LastClickedButton = args[1]
EndIf
Settings["EULA_By"] = LDFile.UserName
Settings["EULA_Version"] = EULA_Version
Settings["VersionID"] = PrgmVersionID
If LastClickedButton = EULAaccept AND LDControls.CheckBoxGetState(Ihaveread) = "True" Then
Settings["EULA"] = "True"
SaveSettings()
GraphicsWindow.Clear()
Startup_GUI()
ElseIf LastClickedButton = EULADecline Then
Settings["EULA"] = "False"
SaveSettings()
LDCall.Function2( Function_Log, "EULA Declined","UI")
GraphicsWindow.ShowMessage("If you disagree with this EULA please delete this program","EULA Decline")
Program.End()
EndIf
EndSub
'______________________________________________________________________________
' Maine Menu UI
'______________________________________________________________________________
Sub Pre_MainMenuUI 'Basically a List of Defines for the Main Menu UI
LDList.Add(List_Stack_Trace,"Pre_MainMenuUI")
'Root
ViewDB_Button = LangList["View"]
NewDB_Button = LangList["New"]
EditDB_Button = LangList["Edit"]
OpenDB_Button = LangList["Open"]
ImportCSV_Button = LangList["CSV"]
ImportSQL_Button = LangList["SQL"]
ExportCSV_Button = LangList["CSV"]+" "
ExportSQL_Button = LangList["SQL"]+" "
ExportXML_Button = LangList["PXML"] +" "
ExportHTML_Button = LangList["HTML"]+" "
SaveButton = LangList["Save"]
SettingsButton = LangList["Settings Editor"]
ToggleDebug_Button = LangList["Toggle Debug"]
AboutButton = LangList["About"]
ShowHelp = LangList["Show Help"]
RefreshButton = LangList["Refresh Schema"]
CheckForUpdates = LangList["Check for Updates"]
ToggleTransaction = LangList["Toggle Transaction Log"]
PrintStackTrace = "Stack Trace" '// Localize
CLoseTW_Button = "Close TW" '// Localize
Export_UI_Button = "Export UI" '// Localize
Define_New_Table_Button = "Define New Table"'// Localize
Define_New_Table_Button2 = "Define New Table "'// Localize
Create_Statistics_Button = "Create Statistics Page"'// Localize
InMemDB_Button = "New in Memory Database" '// Localize
DebugButton = "Debug" '// Localize
MOD_External_Menu()
EndSub
Sub MainMenuUI
LDList.Add(List_Stack_Trace,"MainMenuUI ")
GraphicsWindow.CanResize = "True"
LDGraphicsWindow.ExitButtonMode(GraphicsWindow.Title,"Enabled")
If debug_mode = 1 Then
CheckList[ LangList["Toggle Debug"]] = "True"
LDCall.Function2( Function_Log , "Debug Mode is ON","UI")
ElseIf debug_mode = 0 Then
CheckList[LangList["Toggle Debug"]] = "False"
EndIf
If Transactions_mode = 1 Then
CheckList[LangList["Toggle Transaction Log"]] = "True"
ElseIf Transactions_mode = 0 Then
CheckList[LangList["Toggle Transaction Log"]] = "False"
EndIf
LDGraphicsWindow.State = 2
GraphicsWindow.Title = title + " "
Default_FontSize = GraphicsWindow.FontSize
TypesOfSorts = "1=" + LangList["Table"] +";2=" +LangList["View"] +";3=" + LangList["Index"] +";4=" +LangList["Master Table"] +";"
Get_SCHEMA()
SCHEMA_CurrentList = SCHEMA_TableList
GraphicsWindow.FontSize = 20
Menu = LDControls.AddMenu(Desktop.Width * 1.5 ,30,MenuList,"",CheckList)
Shapes.Move( Shapes.AddText(LangList["Sort"] +":") , 990 , 1)
SortOffset = ( ( (Text.GetLength(LangList["Sort"] +":") - 5 ) * GraphicsWindow.FontSize ) / 1.5 ) + 5
GraphicsWindow.FontSize = Default_FontSize
TableCB = LDControls.AddComboBox(SCHEMA_TableList,100,100)
SortsCB = LDControls.AddComboBox(TypesOfSorts,100,100)
DataBaseCB = LDControls.AddComboBox( LDList.ToArray(List_DB_ShortName),100,100 )
Controls.Move(SortsCB,970+185 + SortOffset ,5)
Controls.Move(TableCB,1075 + 185+ SortOffset,5)
Controls.Move(DataBaseCB,1050+ SortOffset,5)
LDCall.Function5( Function_UI_Add , Register , TableCB , Function_Handler_ComboBox ,"","")
LDCall.Function5( Function_UI_Add , Register , SortsCB , Function_Handler_ComboBox ,"","")
LDCall.Function5( Function_UI_Add , Register , DataBaseCB , Function_Handler_ComboBox ,"","")
LastClickedButton = ViewDB_Button 'Acts like a Virtual Function Call
MainMenuHandler()
Set_Title()
Ldcontrols.MenuClicked = Universal_MenuClicked
LDControls.ComboBoxItemChanged = Universal_ComboBoxChanged
Controls.ButtonClicked = Universal_BD
If debug_mode = 0 And debug_Parser = 0 Then
TextWindow.Hide()
EndIf
EndSub
Sub MainMenuButton
LDList.Add(List_Stack_Trace,"MainMenuButton")
LDCall.Function( Function_Handler_MainMenu , Controls.LastClickedButton )
EndSub
Sub ComboBoxChanged
LDList.Add(List_Stack_Trace,"ComboBoxChanged")
If args[1] <> "" Then
LastClickedCB = args[1]
Else
LastClickedCB = LDControls.LastComboBox
EndIf
LastCBIndex = LDControls.LastComboBoxIndex
If LastClickedCB = TableCB Then '
LDList.Add(TrackDefaultTable,LastCBIndex)
Default_Table = SCHEMA_CurrentList[ LastCBIndex ]
Get_SCHEMA_Private()
Hide_Display_Results()
LDControls.ComboBoxContent(SortByCB ,SchemaList )
LDControls.ComboBoxContent(SearchByCB, SchemaList )
LDControls.ComboBoxContent(ColumnListCB, SchemaList )
Set_Title()
LastClickedButton = ViewDB_Button
MainMenuHandler()
ElseIf LastClickedCB = DataBaseCB Then
LDList.Add( List_DB_Tracker , LDList.GetAt(List_DB_ShortName,LastCBIndex))
LDCall.Function2( Function_Load_DB , 4, LDList.GetAt(List_DB_Path,LastCBIndex) )
Get_SCHEMA() 'Fetches Schema of everything in the new DB
Get_SCHEMA_Private() 'Fetches Schema of Current Default Table
LDCall.Function(Function_Handler_ComboBox,TableCB)
LDCall.Function(Function_Handler_ComboBox,SortByCB)
If SortByMode <> 4 Then 'Sets Defalt Table in most instances to the first table that exists
LDControls.ComboBoxContent(TableCB,SCHEMA_TableList)
LDControls.ComboBoxSelect(TableCB,1)
LDControls.ComboBoxSelect(SortsCB,1)
Get_SCHEMA_Private()
Default_Table = SCHEMA_TableList[1]
SortByMode = 1
Else
Default_Table = "sqlite_master"
Get_SCHEMA_Private()
SCHEMA_TableList = "1="+Default_Table+";2=sqlite_temp_master;"
LDControls.ComboBoxContent(TableCB, SCHEMA_TableList)
EndIf
LDCall.Function( Function_Handler_Universal , ViewDB_Button )
ElseIf LastClickedCB = SortsCB Then
SortsCB_IndexList[1] = SCHEMA_TableList
SortsCB_IndexList[2] = SCHEMA_ViewList
SortsCB_IndexList[3] = SCHEMA_IndexList
SortsCB_Defaults = "1=" + SCHEMA_TableList[1] +";2=" +SCHEMA_ViewList[1] +";3=" + SCHEMA_IndexList[1] +";4=" + "sqlite_master" +";"
SortByMode = LastCBIndex
If LastCBIndex = 1 Then
Default_Table = SCHEMA_TableList[1]
SCHEMA_CurrentList = SCHEMA_TableList
LDControls.ComboBoxContent(TableCB, SCHEMA_TableList )
ElseIf LastCBIndex = 2 Then
Default_Table = SCHEMA_ViewList[1]
SCHEMA_CurrentList = SCHEMA_ViewList
LDControls.ComboBoxContent(TableCB, SCHEMA_ViewList )
ElseIf LastCBIndex = 3 Then
Default_Table = SCHEMA_IndexList[1]
SCHEMA_CurrentList = SCHEMA_IndexList
LDControls.ComboBoxContent(TableCB, SCHEMA_IndexList )
ElseIf LastCBIndex = 4 then
Default_Table = "sqlite_master"
Get_SCHEMA_Private()
EndIf
If (LastCBIndex = 1 OR LastCBIndex = 2 OR LastCBIndex = 3 Or LastCBIndex = 4) and Default_Table <> "" Then
LDList.Clear(TrackDefaultTable)
LDList.Add(TrackDefaultTable,1)
Get_SCHEMA_Private()
Hide_Display_Results()
LDControls.ComboBoxContent(SortByCB ,SchemaList)
LDControls.ComboBoxContent(SearchByCB, SchemaList )
LDControls.ComboBoxContent(ColumnListCB, SchemaList )
Set_Title()
LDCall.Function( Function_Handler_Universal , ViewDB_Button )
Set_Title()
Else
LDCall.Function2(Function_Log,"In the current database no "+LangList[ TypesOfSorts[SortByMode] ]+"s can be found.","UI") '//Localize
GraphicsWindow.ShowMessage("In the current database no "+ LangList[ TypesOfSorts[SortByMode] ] +"s can be found." , "Error" ) '//Localize
EndIf
If debug_mode = 1 Then
TextWindow.WriteLine("DEBUG : "+ LastCBIndex +":"+ TypesOfSorts[LastCBIndex] +":" + SortsCB_IndexList[LastCBIndex] +":" + Default_Table )
EndIf
EndIf
EndSub
Sub MainMenuHandler
LDList.Add(List_Stack_Trace,"MainMenuHandler")
Results_Search = 0
Results_Sort = 0
Results_Function = 0
If args[1] <> "" Then
LastClickedButton = args[1]
If debug_mode = 1 Then
Textwindow.writeline("Main Menu Handler " + args[1])
EndIf
EndIf
If debug_mode = 0 Then
TextWindow.Hide()
EndIf
If LastClickedButton = NewDB_Button Then 'New Database
NewFileSavePath = LDDialogs.SaveFile("db",lastFolder)
If NewFileSavePath <> "" Then
lastFolder = LDFile.GetFolder(NewFileSavePath)
SaveSettings()
LDCall.Function2(Function_Log, "Created DB : " + NewFileSavePath,"Application")
listview = ""
Dataview = ""
LoadSettings()
LDDataBase.ConnectSQLite(NewFileSavePath)
LDCall.Function2( Function_Load_DB , 4 , NewFileSavePath )
SaveSettings()
Pre_MainMenuUI()
MainMenuUI()
LDDataBase.Connection = ""
EndIf
ElseIf LastClickedButton = EditDB_Button Then 'Edit Database List View
If database <> "" Then
If SortByMode = 2 Then
LDCall.Function2(Function_Log ,LangList["Views Read Only"] , LangList["UI"])
GraphicsWindow.ShowMessage(LangList[ "Error"] +":" + LangList["Views Read Only"] ,LangList["Access Denied"])
ElseIf SortByMode = 4 Then
LDCall.Function2(Function_Log ,LangList["Master Table Protected"] , LangList["UI"])
GraphicsWindow.ShowMessage(LangList[ "Error"] +":" + LangList["Master Table Protected"] ,LangList["Access Denied"])
Else
Controls.HideControl(listview)
If Dataview = "" Then
Dataview = LDControls.AddDataView(Listview_Width,Listview_Height,"")
Controls.Move(Dataview,10,35)
Else
Controls.ShowControl(Dataview)
EndIf
CurrentControl = Dataview
LDDataBase.EditTable(database,Default_Table,CurrentControl)
Hide_Display_Results()
EndIf
Else
LDCall.Function2(Function_Log ,LangList["Error No DB"] , LangList["UI"])
GraphicsWindow.ShowMessage(LangList["Error No DB"] ,LangList[ "Error" ])
EndIf
ElseIf LastClickedButton = ViewDB_Button Then 'View Database
Controls.HideControl(Dataview)
If listview = "" Then
listview = LDDataBase.AddListView(Listview_Width,Listview_Height)
Controls.Move(listview,10,35)
Display_Results()
Else
Show_Display_Results()
Controls.ShowControl(listview)
EndIf
CurrentControl = listview
If Default_Table <> "" Then
LDCall.Function5(QueryFunction,"SELECT * FROM " + DQC + Default_Table + DQC + ";",CurrentControl,"False",LangList["App"],LangList["View Function"])
EndIf
ElseIf LastClickedButton = OpenDB_Button Then 'Opens a DB
listview = ""
Dataview = ""
LoadSettings() 'Reloads Settings
LDList.Add(List_Stack_Trace,"MainMenuHandler.OPEN")
LDCall.Function2(Function_Load_DB,4, LDCall.Function(Function_Get_DB,"") )
LDList.Add(List_Stack_Trace,"MainMenuHandler.OPEN")
SaveSettings()
LDList.Add(List_Stack_Trace,"MainMenuHandler.OPEN")
Pre_MainMenuUI()
LDList.Add(List_Stack_Trace,"MainMenuHandler.OPEN")
MainMenuUI()
Elseif LastClickedButton = SaveButton Then 'Save Button
If database <> "" and Dataview <> "" Then
Save_Status = LDDataBase.SaveTable(database,Dataview)
LDCall.Function2(Function_Log ,"The save was : " + Save_Status , "UI" ) '//Localize
GraphicsWindow.ShowMessage("The save was : " + Save_Status,"Save Status !") '//Localize
Else
LDCall.Function2(Function_Log,"The Database or Dataview does not exist or have not yet been loaded", LangList["UI"]) '//Localize
GraphicsWindow.ShowMessage(LangList["Error"] +":" + LangList["Dataview Error"],"Save Error")
EndIf
ElseIf LastClickedButton = SortButton Then 'Sort View
Results_Sort = 1
GenerateQuery()
ElseIf LastClickedButton = SearchButton Then 'Search View
Results_Search = 1
GenerateQuery()
ElseIf LastClickedButton = RunFunctionButton Then
Results_Function = 1
GenerateQuery()
ElseIF LastClickedButton = CustomQueryButton Then 'USER Custom Query SQL
LDCall.Function5(QueryFunction,Controls.GetTextBoxText(CustomQuery),CurrentControl,"False",Username,LangList["User Requested"])
ElseIf LastClickedButton = CommandButton Then 'User Custom Run SQL
updated = LDCall.Function4(CommandFunction , database , Controls.GetTextBoxText(CustomQuery) , Username,LangList[ "User Requested" ])
GraphicsWindow.ShowMessage(" " + updated + " number of rows were updated.","") '//Localize
ElseIf LastClickedButton = ImportSQL_Button Then ' Imports SQL
CurrentFolder = LDFile.GetFolder(databasepath)
ImportSQLPath = LDDialogs.OpenFile("sql",CurrentFolder)
ImportSQLCNTs = File.ReadContents( ImportSQLPath )
TextWindow.WriteLine( ImportSQLPath )
TextWindow.WriteLine( Text.GetLength(ImportSQLCNTs ))
GraphicsWindow.Hide()
records = LDCall.Function4( CommandFunction , database, ImportSQLCNTs , Username ,"Import SQL") '//Localize
LDCall.Function2(Function_Log, "Imported data into: " + databasepath +" From sql file","Application") '//Localize
ImportSQLCNTs = ""
GraphicsWindow.Show()
GraphicsWindow.ShowMessage(records + " records updated","IMPORT") '//Localize
ElseIf LastClickedButton = ExportCSV_Button Then
TextWindow.WriteLine("")
TextWindow.WriteLine("SELECT DATA TO WRITE IN " + LastClickedButton)
TextWindow.Write(">")
querycmd = TextWindow.Read()
TextWindow.Clear()
TextWindow.Hide()
LDCall.Function(Function_RunMod_Parser, "Export.CSV" )
ElseIf LastClickedButton = ExportXML_Button Then
TextWindow.WriteLine("")
TextWindow.WriteLine("SELECT DATA TO WRITE IN " + LastClickedButton)
TextWindow.Write(">")
querycmd = TextWindow.Read()
TextWindow.Hide()
LDCall.Function( Function_RunMod_Parser , "Export.XML" )
ElseIf LastClickedButton = ToggleDebug_Button Then
debug_mode = Toggle_Booleans [ debug_mode ]
ElseIf LastClickedButton = AboutButton Then
About_Data = LDCall.Function5( Function_Query , "SELECT SQLITE_VERSION(),sqlite_source_id();","","True",UserName, LangList["User Requested"] +":" + LangList["App"] )
About_Msg = "DBM is a Database Mangement Program developed by Abhishek Sathiabalan. Copyright " + copyrightDate + ". All rights reserved." + CLLF + CLLF +"You are running : " + ProductID +" v" + VersionID + CLLF
About_Msg = About_Msg + CLLF + "SQLITE VERSION : " + About_Data[1]["SQLITE_VERSION()"] + CLLF + "SQLITE Source ID : " +About_Data[1]["sqlite_source_id()"]
GraphicsWindow.ShowMessage(About_Msg ,"About") 'DO NOT LOCALIZE
ElseIf LastClickedButton = ShowHelp Then
LDProcess.Start(HelpPath,"")
ElseIf LastClickedButton = SettingsButton Then
Settings_UI()
ElseIf LastClickedButton = Setting_Save Then
Settings["Listview_Width"] = Controls.GetTextBoxText(Settings_WidthTB )
Settings["Listview_Height"]= Controls.GetTextBoxText(Settings_HeigthTB )
Settings["Extensions"] = Controls.GetTextBoxText(Settings_ExtensionsTB)
Settings["Deliminator"] = Controls.GetTextBoxText( Settings_DeliminatorTB )
Settings["Language" ] = LDList.GetAt("ISO_Lang", LDControls.ComboBoxGetSelected( Language_LB ) )
State[1] = LDControls.CheckBoxGetState( Settings_Debug_Mode )
State[2] = LDControls.CheckBoxGetState( Settings_Debug_Parser)
debug_mode = Booleans[( State[1] )]
debug_Parser = Booleans[( State[2] )]
Settings["debug_mode"] = debug_mode
Settings["debug_parser"] = debug_Parser
Localization_lang = Settings["Language" ]
SaveSettings()
LoadSettings()
'Sets it up so the Language Info can be reset
LDList.Clear("ISO_Lang")
LDList.Clear("ISO_Text")
MenuList = ""
CheckList= ""
Localization_XML()
LastClickedButton = Settings_Close
MainMenuHandler()
ElseIf LastClickedButton = Settings_Close Then
listview = ""
Dataview = ""
For I = 1 To Array.GetItemCount( Controls_Settings )
Controls.HideControl( Controls_Settings[I] )
EndFor
Pre_MainMenuUI()
MainMenuUI()
ElseIf LastClickedButton = RefreshButton Then
Get_SCHEMA()
ElseIf LastClickedButton = ToggleTransaction Then
If Transactions_mode = 1 Then
Transactions_mode = 0
ElseIf Transactions_mode = 0 Then
Transactions_mode = 1
EndIf
Settings["Transactions"] = Transactions_mode
SaveSettings()
ElseIf LastClickedButton = CLoseTW_Button Then
TextWindow.Clear()
TextWindow.Hide()
ElseIf LastClickedButton = Settings_Buttons_LogCSVPath Then
Temp_Path = LDDialogs.SaveFile("1=csv;", LDFile.GetFolder( logpath ) )
If Temp_Path <> "" Then
Settings["Log_Path"] = Temp_Path
EndIf
Temp_Path = ""
ElseIf LastClickedButton = Settings_Buttons_LogDBPath Then
Temp_Path = LDDialogs.SaveFile("1=db;2=sqlite;3=*;", LDFile.GetFolder( logDBpath ) )
If Temp_Path <> "" Then
Settings["Log_DB_Path"] = Temp_Path
EndIf
Temp_Path = ""
ElseIf LastClickedButton = Settings_Buttons_TransactionDBPath Then
Temp_Path = LDDialogs.SaveFile("1=db;2=sqlite;3=*;", LDFile.GetFolder( TransactionDBpath ) )
IF Temp_Path <> "" Then
Settings["Transaction_DB"] = Temp_Path
EndIf
Temp_Path = ""
ElseIf LastClickedButton = PrintStackTrace Then
debug_mode = 1
TextWindow.WriteLine("Debug Mode turned on due to current action")
LDList.Print( List_Stack_Trace )
ElseIf LastClickedButton = Define_New_Table_Button OR LastClickedButton = Define_New_Table_Button2 Then
Create_Table_UI()
ElseIf LastClickedButton = Create_Statistics_Button Then
Get_SCHEMA_Private()
return = LDCall.Function2( Function_Handler_CreateStatistics, Default_Table ,SchemaList)
LDCall.Function4(Function_Query ,"Select * FROM " + return +";",CurrentControl,UserName,LangList[ "User Requested" ] )
ElseIf LastClickedButton = DebugButton Then
Controls.ShowControl( LogCB )
ElseIf LastClickedButton = InMemDB_Button Then
LDDataBase.Connection = "Data Source=:memory:;Version=3;New=True;"
listview = ""
Dataview = ""
LoadSettings()