fb:porticula NoPaste
test.bas
Uploader: | ThePuppetMaster |
Datum/Zeit: | 21.10.2009 10:26:46 |
#include once "netdb.bi"
'------------------------------------------------------------------------------------------------------------------------------------------------------
'=Commands=
'Clearall = Clear the complete database: Data and Header fields (Blank Database)
'HeaderAdd = Add a Headerfield. '<Headername>'='<Type (numeric/string/date)>'
'GetHeaderCount = Return the number of Headerfields
'DataClear = Delete all Dataelements
'DataAdd = Add a Dataelement to the database! Note: The Datafiels must have the same count how the header has! <Datafield>[,<Datafield>[,<Datafield>[...]]]
'GetDataCount = Return the number of Dataelements
'GetDataByIndex = Return a Dataelement selected by a Indexnumber. To select the Elements use "index='<Indexnumber>'" or "index='<From Indexnumber>-<To Indexnumber>'"
'DelDataByIndex = Delete a Dataelement selected by a Indexnumber. To select the Elements use "index='<Indexnumber>'" or "index='<From Indexnumber>-<To Indexnumber>'"
'------------------------------------------------------------------------------------------------------------------------------------------------------
Dim DName as String = "MyDB"
Dim DAcc as String = "Username:Password"
Dim T as String
Dim RDD() as String
Dim RDC as UInteger
Dim RV as Integer
Print
Print "Create New User-Database"
'If a Database create whisout Username and password, then then Database can access from any other
'If the Public Flag is set then the database can view and modify from any other
RV = NETDB_Add(DName)
If RV <> NETDB_GURU_NoError Then Print " ErrorID:"; RV
'NOTE! To profe the commandstring use NETDB_EncodeData() in all User-Data!!!
'This function replace "CR" / "LF" / "'" and "/" by a special Char
'Full stream commandset
T = ""
T += "DB='" & DName & "',Acc='" & DAcc & "',Cmd=clearall" & Chr(13, 10)
T += "DB='" & DName & "',Acc='" & DAcc & "',Cmd=HeaderAdd,'Head1_Num'='numeric'" & Chr(13, 10)
T += "DB='" & DName & "',Acc='" & DAcc & "',Cmd=HeaderAdd,'Head2_String'='string'" & Chr(13, 10)
T += "DB='" & DName & "',Acc='" & DAcc & "',Cmd=HeaderAdd,'Head3_Date'='date'" & Chr(13, 10)
T += "Cmd=DataAdd" & Chr(13, 10)
T += "'1','" & NETDB_EncodeData("Teststring1") & "','2001.01.01-11:21:31'" & Chr(13, 10)
T += "'2','" & NETDB_EncodeData("Teststring2") & "','2002.02.02-12:22:32'" & Chr(13, 10)
T += "'3','" & NETDB_EncodeData("Teststring3") & "','2003.03.03-13:23:33'" & Chr(13, 10)
T += "'4','" & NETDB_EncodeData("Teststring4") & "','2004.04.04-14:24:34'" & Chr(13, 10)
Print ""
Print "CommandStream Len (Full): "; Len(T)
Print "Execute Commandset"
RV = NETDB_DoCommandStream(T, RDD(), RDC)
If RV <> NETDB_GURU_NoError Then Print " ErrorID:"; RV
'Preset stream commandset
'multiple add lines must seperate by CRLF
T = ""
T += "DB='" & DName & "',Acc='" & DAcc & "',Cmd=clearall" & Chr(13, 10)
T += "Cmd=HeaderAdd" & Chr(13, 10)
T += "'Head1_Num'='numeric','Head2_String'='string','Head3_Date'='date'" & Chr(13, 10)
T += "Cmd=DataAdd" & Chr(13, 10)
T += "'1','" & NETDB_EncodeData("Teststring1") & "','2001.01.01-11:21:31'" & Chr(13, 10)
T += "'2','" & NETDB_EncodeData("Teststring2") & "','2002.02.02-12:22:32'" & Chr(13, 10)
T += "'3','" & NETDB_EncodeData("Teststring3") & "','2003.03.03-13:23:33'" & Chr(13, 10)
T += "'4','" & NETDB_EncodeData("Teststring4") & "','2004.04.04-14:24:34'" & Chr(13, 10)
Print ""
Print "CommandStream Len (Preset):"; Len(T)
Print "Execute Commandset"
RV = NETDB_DoCommandStream(T, RDD(), RDC)
If RV <> NETDB_GURU_NoError Then Print " ErrorID:"; RV
'Shorter stream commandset
'multiple add lines must seperate by CRLF
T = ""
T += "DB='" & DName & "',Acc='" & DAcc & "',Cmd=clearall,Cmd=HeaderAdd,'Head1_Num'='num','Head2_String'='str','Head3_Date'='date',Cmd=DataAdd" & Chr(13, 10)
T += "'1','" & NETDB_EncodeData("Teststring1") & "','2001.01.01-11:21:31'" & Chr(13, 10)
T += "'2','" & NETDB_EncodeData("Teststring2") & "','2002.02.02-12:22:32'" & Chr(13, 10)
T += "'3','" & NETDB_EncodeData("Teststring3") & "','2003.03.03-13:23:33'" & Chr(13, 10)
T += "'4','" & NETDB_EncodeData("Teststring4") & "','2004.04.04-14:24:34'" & Chr(13, 10)
Print ""
Print "CommandStream Len (Short): "; Len(T)
Print "Execute Commandset"
RV = NETDB_DoCommandStream(T, RDD(), RDC)
If RV <> NETDB_GURU_NoError Then Print " ErrorID:"; RV
Print
Print "Request counts"
RV = NETDB_DoCommandStream("DB='" & DName & "',Acc='" & DAcc & "',cmd=GetHeaderCount,", RDD(), RDC)
If RV <> NETDB_GURU_NoError Then
Print " ErrorID:"; RV
Else: If RDC > 0 Then Print " Header Count:"; RDD(1)
End If
RV = NETDB_DoCommandStream("DB='" & DName & "',Acc='" & DAcc & "',cmd=GetDataCount,", RDD(), RDC)
If RV <> NETDB_GURU_NoError Then
Print " ErrorID:"; RV
Else: If RDC > 0 Then Print " Data Count:"; RDD(1)
End If
Print ""
Print "Request data. Index:2"
RV = NETDB_DoCommandStream("DB='" & DName & "',Acc='" & DAcc & "',index='2',cmd=GetDataByIndex,", RDD(), RDC)
If RV = NETDB_GURU_NoError Then
Print " Elements: >";
For X as UInteger = 1 to RDC
Print NETDB_DecodeData(RDD(X)) & "<___>";
Next
Print "!"
Else: Print " ErrorID:"; RV
End If
Print ""
Print "Request data. Index:2 to 4"
RV = NETDB_DoCommandStream("DB='" & DName & "',Acc='" & DAcc & "',index='2-4',cmd=GetDataByIndex,", RDD(), RDC)
If RV = NETDB_GURU_NoError Then
Print " Elements: >";
For X as UInteger = 1 to RDC
Print NETDB_DecodeData(RDD(X)) & "<___>";
Next
Print "!"
Else: Print " ErrorID:"; RV
End If
Print ""
Print "Remove Data. Index:3"
RV = NETDB_DoCommandStream("DB='" & DName & "',Acc='" & DAcc & "',index='3',cmd=DelDataByIndex,", RDD(), RDC)
If RV <> NETDB_GURU_NoError Then Print " ErrorID:"; RV
Print
Print "Request counts"
RV = NETDB_DoCommandStream("DB='" & DName & "',Acc='" & DAcc & "',cmd=GetHeaderCount,", RDD(), RDC)
If RV <> NETDB_GURU_NoError Then
Print " ErrorID:"; RV
Else: If RDC > 0 Then Print " Header Count:"; RDD(1)
End If
RV = NETDB_DoCommandStream("DB='" & DName & "',Acc='" & DAcc & "',cmd=GetDataCount,", RDD(), RDC)
If RV <> NETDB_GURU_NoError Then
Print " ErrorID:"; RV
Else: If RDC > 0 Then Print " Data Count:"; RDD(1)
End If
Print ""
Print "Request data. Index:1 to 3"
RV = NETDB_DoCommandStream("DB='" & DName & "',Acc='" & DAcc & "',index='1-3',cmd=GetDataByIndex,", RDD(), RDC)
If RV = NETDB_GURU_NoError Then
Print " Elements: >";
For X as UInteger = 1 to RDC
Print NETDB_DecodeData(RDD(X)) & "<___>";
Next
Print "!"
Else: Print " ErrorID:"; RV
End If
'To profe the system-memory clear the complete database
Print ""
Print "Clear compleate Database"
NETDB_Clear_All()
Print ""
'End app
End 0