[Source] eLeC BASE - DB Engine Sample, pure AutoIT

    • [Source] eLeC BASE - DB Engine Sample, pure AutoIT

      hey
      hab hier was für euch
      ich habs eben in ner stunne gemacht.
      Es ist ein Data Base Engine in purem AutoIT gecoded
      es ist nicht 100 prozentig fertig, damit ihr auch was dran ändern könnt.

      Am besten leßt ihr alles und dann startet ihr mal das sample.
      Das ganze funktioniert über Arrays, zum speichern hab ich FileWriteFromArray verwended, was ich aber modifizieren musste, da es nur eine Dimension unterstützt wobei ich 2mal 2 Dimensionen und einmal 3 Dimensionen verwende
      Die FileReadToArray Func muss noch gemodded werden.
      Dann geht das speichern und auslesen komplett.

      Was man noch machen könnte wären ein paar kleine funcs um bestimmte informationen herauszufinden.
      Und wer es anpacken möchte : ein DB Editor like NaviCat oder so ^^
      das wäre mit der enigine ziemlich einfach x)
      ich hab nur grad kopfschmerzen xD

      also ich hab das komplette grundgerüst fertig
      es is eigentlich sehr schnell.
      wenn es komplett seien sollte ( durch eure hilfe ), werd ich dazu nen serverprogramieren und ne udf um auf den server zu connecten und daten zu empfangen.
      vllt. noch ne Dll für C++/C# und vB oder so ^^

      "eLeC BASE"

      C-Quellcode

      1. #cs ----------------------------------------------------------------------------
      2. AutoIt Version: 3.3.1.1 (beta)
      3. Author: Jiyan Akgül
      4. Type: UDF
      5. UDF Name: " eLeC BASE "
      6. About UDF: A DATABASE for every usage and without sepctial types like "int,string,float,double,etc.."
      7. Functions:
      8. '->
      9. #ce ----------------------------------------------------------------------------
      10. #include <File.au3>
      11. #include <Array.au3>
      12. Dim $DATABASE[1001][5002] ; 10.000 Data Bases with 10.000 Tables
      13. Dim $TABLE[5001][1002][2] ; 10.000 Tables for 10.000 Rows
      14. Dim $LINES[5001][1002] ; 10.000 Tabels for 50.000 Lines
      15. Global $DB_ID, $T_ID, $L_ID
      16. Global $DATABASE, $TABLE, $LINES
      17. ;;; START SAMPLE >>>>>
      18. ;load normaly
      19. _elec_Load()
      20. ;add Things
      21. $Test_DB = _elec_CreateDB("Test DB")
      22. $Test_Table = _elec_CreateTable("Test Table")
      23. _elec_CreateRow("Test Row1", $Test_Table, "My Comment")
      24. _elec_CreateRow("Test Row2", $Test_Table, "Only a Test")
      25. _elec_CreateRow("Test Row3", $Test_Table, "Nur ein Test")
      26. $Test_Line = _elec_AddLine($Test_Table, "hi;hey;helo")
      27. ;show:
      28. $Read = _elec_ReadLine($Test_Table, $Test_Line)
      29. _ArrayDisplay($Read)
      30. ;;; END SAMPLE <<<<<
      31. Func _elec_Load()
      32. $DATABASE[0][0] = 0 ; 0 Databases registred
      33. $TABLE[0][0][0] = 0 ; 0 Tables registret
      34. $LINES[0][0] = 0 ; 0 Lines registred
      35. EndFunc ;==>_elec_Load
      36. Func _elec_Load_FromFile($DB_Link = "elec.db", $T_Link = "elec.t", $L_Link = "elec.l")
      37. _FileReadToArray($DB_Link, $DATABASE)
      38. _FileReadToArray($T_Link, $TABLE)
      39. _FileReadToArray($L_Link, $LINES)
      40. EndFunc ;==>_elec_Load_FromFile
      41. Func _elec_CreateTable($Table_Name, $DB_ID = -1)
      42. If $DB_ID = -1 Then $DB_ID = $DATABASE[0][0]
      43. $DATABASE[$DB_ID][0] = $DATABASE[$DB_ID][0] + 1
      44. $i = $DATABASE[$DB_ID][0]
      45. ConsoleWrite("$i=" & $i & @CRLF)
      46. $TABLE[$i][0][0] = 1
      47. $TABLE[$i][0][1] = $Table_Name
      48. $LINES[$i][0] = 0
      49. Return $i
      50. EndFunc ;==>_elec_CreateTable
      51. Func _elec_CreateRow($Row_Name, $T_ID = -1, $Comment = "")
      52. If $T_ID = -1 Then $T_ID = $TABLE[0][0]
      53. $TABLE[$T_ID][0][0] = $TABLE[$T_ID][0][0] + 1
      54. $LINES[0][0] = $LINES[0][0] + 1
      55. $i = $TABLE[$T_ID][0][0]
      56. $TABLE[$T_ID][$i][0] = $Row_Name
      57. $TABLE[$T_ID][$i][1] = $Comment
      58. Return $i
      59. EndFunc ;==>_elec_CreateRow
      60. Func _elec_AddLine($T_ID, $LINE)
      61. $LINES[0][0] = $LINES[0][0] + 1
      62. $LINES[$T_ID][0] = $LINES[$T_ID][0] + 1
      63. $i = $LINES[$T_ID][0]
      64. $LINES[$T_ID][$i] = $LINE
      65. Return $i
      66. EndFunc ;==>_elec_AddLine
      67. Func _elec_ReadLine($T_ID, $L_ID, $R_ID = 0)
      68. $LINE = StringSplit($LINES[$T_ID][$L_ID], ";")
      69. Local $LINE_[$LINE[0]+1]
      70. If $R_ID = 0 Then
      71. For $i = 1 To $LINE[0]
      72. $LINE_[$i] = $LINE[$i]
      73. Next
      74. Else
      75. $LINE_[0] = $LINE[$R_ID]
      76. EndIf
      77. Return $LINE_
      78. EndFunc ;==>_elec_ReadLine
      79. Func _elec_ReplaceLine($L_ID, $LINE)
      80. $LINES[$T_ID][$L_ID] = $LINE
      81. EndFunc ;==>_elec_ReplaceLine
      82. Func _elec_CreateDB($DB_Title)
      83. $DATABASE[0][0] = $DATABASE[0][0] + 1
      84. $i = $DATABASE[0][0]
      85. $DATABASE[$i][0] = 1
      86. $DATABASE[$i][1] = $DB_Title
      87. Return $i
      88. EndFunc ;==>_elec_CreateDB
      89. Func _elec_ListDB()
      90. $j = $DATABASE[0][0]
      91. Local $ListArr_DB[$j + 1][2]
      92. $ListArr_DB[0] = $j
      93. For $i = 1 To $j
      94. $ListArr_DB[$i][0] = $DATABASE[$i][0]
      95. $ListArr_DB[$i][1] = $DATABASE[$i][1]
      96. Next
      97. Return $ListArr_DB
      98. EndFunc ;==>_elec_ListDB
      99. Func _elec_Save($DB_Link = "elec.db", $T_Link = "elec.t", $L_Link = "elec.l")
      100. _FileWriteFromArray_1($DB_Link, $DATABASE)
      101. _FileWriteFromArray_2($T_Link, $TABLE)
      102. _FileWriteFromArray_1($L_Link, $LINES)
      103. EndFunc ;==>_elec_Save
      104. ;;;; NEEEDED AND MODDED FUNCS
      105. ; #FUNCTION# ====================================================================================================================
      106. ; Name...........: _FileWriteFromArray <<<modded for 2 DIMENSIONS>>>
      107. ; Author ........: Jos van der Zande <jdeb at autoitscript dot com>
      108. ; Modified.......: Updated for file handles by PsaltyDS at the AutoIt forums.
      109. ; ===============================================================================================================================
      110. Func _FileWriteFromArray_1($File, $a_Array)
      111. ; Check if we have a valid array as input
      112. If Not IsArray($a_Array) Then Return SetError(2, 0, 0)
      113. ; Open output file for overwrite by default, or use input file handle if passed
      114. Local $hFile
      115. If IsString($File) Then
      116. $hFile = FileOpen($File, 2)
      117. Else
      118. $hFile = $File
      119. EndIf
      120. If $hFile = -1 Then Return SetError(1, 0, 0)
      121. ; Write array data to file
      122. Local $ErrorSav = 0
      123. For $x = 0 To UBound($a_Array)-1
      124. For $y = 0 To UBound($a_Array, 2)-1
      125. If FileWrite($hFile, $a_Array[$x][$y] & @CRLF) = 0 Then
      126. $ErrorSav = 3
      127. ExitLoop
      128. EndIf
      129. Next
      130. Next
      131. ; Close file only if specified by a string path
      132. If IsString($File) Then FileClose($hFile)
      133. ; Return results
      134. If $ErrorSav Then
      135. Return SetError($ErrorSav, 0, 0)
      136. Else
      137. Return 1
      138. EndIf
      139. EndFunc ;==>_FileWriteFromArray_1
      140. ; #FUNCTION# ====================================================================================================================
      141. ; Name...........: _FileWriteFromArray <<<modded for 3 DIMENSIONS>>>
      142. ; Author ........: Jos van der Zande <jdeb at autoitscript dot com>
      143. ; Modified.......: Updated for file handles by PsaltyDS at the AutoIt forums.
      144. ; ===============================================================================================================================
      145. Func _FileWriteFromArray_2($File, $a_Array)
      146. ; Check if we have a valid array as input
      147. If Not IsArray($a_Array) Then Return SetError(2, 0, 0)
      148. ; Open output file for overwrite by default, or use input file handle if passed
      149. Local $hFile
      150. If IsString($File) Then
      151. $hFile = FileOpen($File, 2)
      152. Else
      153. $hFile = $File
      154. EndIf
      155. If $hFile = -1 Then Return SetError(1, 0, 0)
      156. ; Write array data to file
      157. Local $ErrorSav = 0
      158. For $x = 0 To UBound($a_Array)-1
      159. For $y = 0 To UBound($a_Array, 2)-1
      160. For $z = 0 to UBound($a_Array,3)-1
      161. If FileWrite($hFile, $a_Array[$x][$y][$z] & @CRLF) = 0 Then
      162. $ErrorSav = 3
      163. ExitLoop
      164. EndIf
      165. Next
      166. Next
      167. Next
      168. ; Close file only if specified by a string path
      169. If IsString($File) Then FileClose($hFile)
      170. ; Return results
      171. If $ErrorSav Then
      172. Return SetError($ErrorSav, 0, 0)
      173. Else
      174. Return 1
      175. EndIf
      176. EndFunc ;==>_FileWriteFromArray_1
      Alles anzeigen


      have fun ;)

      gez :: *electriZer*
    • Werbung zur Unterstützung des Forums ( Bitte AddBlocker deaktivieren )