Ich habe 2 Subroutinen (AddNewItem und ReplaceItem), die einen Datensatz in eine SQLite-DB schreiben:
Code: Alles auswählen
SQLiteExecute(DBref, "BEGIN TRANSACTION" )
If SQliteExecute( DBref, "Insert Into mainTable (" + cols2write + ") Values (" + str4sql + ")" ) = #False
MessageRequester("Error", SQliteErrorMsg(DBref))
Debug SQliteErrorMsg(DBref)
EndIf
SQLiteExecute(DBref, "COMMIT" )
Code: Alles auswählen
SQLiteExecute(DBref, "BEGIN TRANSACTION" )
If SQliteExecute( DBref, "Replace Into mainTable (" + cols2write + ") Values (" + str4sql + ")" ) = #False
MessageRequester("Replace Into mainTable: Error", SQliteErrorMsg(DBref))
Debug SQliteErrorMsg(DBref)
EndIf
SQLiteExecute(DBref, "COMMIT" )
Code: Alles auswählen
make_str4sql:
;#############################################
;{
cols2write = ""
str4sql = "°"
If (GetGadgetText(#i_win_strg_titel) <> "")
cols2write = cols2write + "Titel"
str4sql = str4sql + GetGadgetText(#i_win_strg_titel) + "°"
EndIf
If GetGadgetText(#i_win_strg_genre) <> ""
cols2write = cols2write + ", Genre"
str4sql = str4sql + ", °" + GetGadgetText(#i_win_strg_genre) + "°"
EndIf
If GetGadgetText(#i_win_spig_jahr) <> ""
cols2write = cols2write + ", Jahr"
str4sql = str4sql + ", °" + GetGadgetText(#i_win_spig_jahr) + "°"
EndIf
If GetGadgetText(#i_win_CBxg_MeTYp) <> ""
cols2write = cols2write + ", MediumTyp"
str4sql = str4sql + ", °" + GetGadgetText(#i_win_CBxg_MeTYp) + "°"
EndIf
If GetGadgetText(#i_win_strg_MeNam) <> ""
cols2write = cols2write + ", Mediumname"
str4sql = str4sql + ", °" + GetGadgetText(#i_win_strg_MeNam) + "°"
EndIf
If GetGadgetText(#i_win_CBxg_lager) <> ""
cols2write = cols2write + ", Owner"
str4sql = str4sql + ", °" + GetGadgetText(#i_win_CBxg_lager) + "°"
EndIf
If GetGadgetText(#i_win_CBxg_quell) <> ""
cols2write = cols2write + ", Quelle"
str4sql = str4sql + ", °" + GetGadgetText(#i_win_CBxg_quell) + "°"
EndIf
If GetGadgetText(#i_win_strg_dauer) <> ""
cols2write = cols2write + ", Dauer"
str4sql = str4sql + ", °" + GetGadgetText(#i_win_strg_dauer) + "°"
EndIf
If GetGadgetText(#i_win_CBxg_quali) <> ""
cols2write = cols2write + ", Qualität"
str4sql = str4sql + ", °" + GetGadgetText(#i_win_CBxg_quali) + "°"
EndIf
If GetGadgetText(#i_win_strg_infos) <> ""
cols2write = cols2write + ", Infos"
str4sql = str4sql + ", °" + GetGadgetText(#i_win_strg_infos) + "°"
EndIf
If GetGadgetText(#i_win_strg_artis) <> ""
cols2write = cols2write + ", Artist"
str4sql = str4sql + ", °" + GetGadgetText(#i_win_strg_artis) + "°"
EndIf
If GetGadgetText(#i_win_strg_path) <> ""
cols2write = cols2write + ", Path"
str4sql = str4sql + ", °" + GetGadgetText(#i_win_strg_path) + "°"
EndIf
If GetGadgetText(#i_win_strg_fname) <> ""
cols2write = cols2write + ", FileName"
str4sql = str4sql + ", °" + GetGadgetText(#i_win_strg_fname) + "°"
EndIf
If GetGadgetText(#i_win_strg_fsize) <> ""
cols2write = cols2write + ", FileSize"
str4sql = str4sql + ", °" + GetGadgetText(#i_win_strg_fsize) + "°"
EndIf
If GetGadgetText(#i_win_strg_vicod) <> ""
cols2write = cols2write + ", VideoCodec"
str4sql = str4sql + ", °" + GetGadgetText(#i_win_strg_vicod) + "°"
EndIf
If GetGadgetText(#i_win_strg_vibit) <> ""
cols2write = cols2write + ", VideoBitrate"
str4sql = str4sql + ", °" + GetGadgetText(#i_win_strg_vibit) + "°"
EndIf
If GetGadgetText(#i_win_strg_auflo) <> ""
cols2write = cols2write + ", Auflösung"
str4sql = str4sql + ", °" + GetGadgetText(#i_win_strg_auflo) + "°"
EndIf
If GetGadgetText(#i_win_strg_fps) <> ""
cols2write = cols2write + ", fps"
str4sql = str4sql + ", °" + GetGadgetText(#i_win_strg_fps) + "°"
EndIf
If GetGadgetText(#i_win_strg_aucod) <> ""
cols2write = cols2write + ", AudioCodec"
str4sql = str4sql + ", °" + GetGadgetText(#i_win_strg_aucod) + "°"
EndIf
If GetGadgetText(#i_win_strg_aubit) <> ""
cols2write = cols2write + ", AudioBitrate"
str4sql = str4sql + ", °" + GetGadgetText(#i_win_strg_aubit) + "°"
EndIf
If GetGadgetText(#i_win_strg_kanal) <> ""
cols2write = cols2write + ", AudioKanäle"
str4sql = str4sql + ", °" + GetGadgetText(#i_win_strg_kanal) + "°"
EndIf
If GetGadgetText(#i_win_strg_srate) <> ""
cols2write = cols2write + ", SamplingRate"
str4sql = str4sql + ", °" + GetGadgetText(#i_win_strg_srate) + "°"
EndIf
Debug cols2write
str4sql = ReplaceString(str4sql, "'", "''")
str4sql = ReplaceString(str4sql, "°", "'")
Debug str4sql
;}
Return; make_str4sql
Nun bin ich grade beim "Aufräumen" und verfrachte soviel Subroutinene wie möglich/nötig/sinnvoll in Prozeduren, um das ganze Proggie etwas übersichtlicher zu bekommen.
Dummerweise bekomme ich aus einer Procedure ja nur einen Wert heraus, sodaß ich in diesem Fall besser bei der Subroutine bleibe.
Oder hab ich was übersehen, das es mir ermöglicht, irgendwie an beide Werte zu kommen.
etwas
