Re: Goto sinnvoll nutzen
Verfasst: 27.04.2014 20:28
Da sagst du was. Da konnte man noch mit PageDown in einer Minute durch den ganze 64k Speicher durchscrollen und mit Assemblerprogrammierung jedes Byte gezählt...
Nein, ich glaube bezüglich Goto gar nichts, hab's noch nie verwendet (außer a long time ago) und weiß nur, dass es schwere Kritik und Warnungen dagegen gibt.NicTheQuick hat geschrieben:Wenn du glaubst mit Goto deinen Code einfacher oder übersichtlicher machen zu können, dann nutze es einfach. Es macht nichts langsamer oder schlechter.
walbus hat geschrieben:Ansonsten ist Goto weitestgehend unproblematisch, wenn´s knallt, knallt´s gleich...
Code: Alles auswählen
Procedure MultiFillFields()
Protected Date = GetGadgetState(#Date_AutoFillFrom)
Protected DateTo = GetGadgetState(#Date_AutoFillTo)
CreateDirectory(WorkTablesPath)
Repeat
If GetDayOfWeekAsString(Date, Day(Date)) = "Mo" And Not GetGadgetState(#CheckBox_IncludeMonday): Goto JumpToEnd: EndIf
If GetDayOfWeekAsString(Date, Day(Date)) = "Di" And Not GetGadgetState(#CheckBox_IncludeTuesday): Goto JumpToEnd: EndIf
If GetDayOfWeekAsString(Date, Day(Date)) = "Mi" And Not GetGadgetState(#CheckBox_IncludeWednesday): Goto JumpToEnd: EndIf
If GetDayOfWeekAsString(Date, Day(Date)) = "Do" And Not GetGadgetState(#CheckBox_IncludeThursday): Goto JumpToEnd: EndIf
If GetDayOfWeekAsString(Date, Day(Date)) = "Fr" And Not GetGadgetState(#CheckBox_IncludeFriday): Goto JumpToEnd: EndIf
If GetDayOfWeekAsString(Date, Day(Date)) = "Sa" And Not GetGadgetState(#CheckBox_IncludeSaturday): Goto JumpToEnd: EndIf
If GetDayOfWeekAsString(Date, Day(Date)) = "So" And Not GetGadgetState(#CheckBox_IncludeSunday): Goto JumpToEnd: EndIf
If Not OpenPreferences(WorkTablesPath + "WorkTable_" + RSet(Str(Month(Date)), 2, "0") + Str(Year(Date)) + ".ini")
If Not CreatePreferences(WorkTablesPath + "WorkTable_" + RSet(Str(Month(Date)), 2, "0") + Str(Year(Date)) + ".ini")
MessageRequester("WorkTimeBook", "Daten konnten nicht eingetragen werden!")
Break
EndIf
EndIf
If GetGadgetText(#String_AutoFillWorkBegin)
WritePreferenceString("WorkBegin_" + Str(Day(Date)), GetGadgetText(#String_AutoFillWorkBegin))
EndIf
If GetGadgetText(#String_AutoFillWorkEnd)
WritePreferenceString("WorkEnd_" + Str(Day(Date)), GetGadgetText(#String_AutoFillWorkEnd))
EndIf
If GetGadgetText(#String_AutoFillWorkBreak)
WritePreferenceString("WorkBreak_" + Str(Day(Date)), GetGadgetText(#String_AutoFillWorkBreak))
EndIf
If GetGadgetText(#String_AutoFillWorkNotice)
WritePreferenceString("WorkNotice_" + Str(Day(Date)), GetGadgetText(#String_AutoFillWorkNotice))
EndIf
ClosePreferences()
JumpToEnd:
Date = AddDate(Date, #PB_Date_Day, 1)
Until Date > DateTo
EndProcedure
Code: Alles auswählen
Procedure MultiFillFields()
Protected Date = AddDate(GetGadgetState(#Date_AutoFillFrom), #PB_Date_Day, -1)
Protected DateTo = AddDate(GetGadgetState(#Date_AutoFillTo, #PB_Date_Day, -1)
CreateDirectory(WorkTablesPath)
Repeat
Date = AddDate(Date, #PB_Date_Day, 1)
If GetDayOfWeekAsString(Date, Day(Date)) = "Mo" And Not GetGadgetState(#CheckBox_IncludeMonday): Continue : EndIf
If GetDayOfWeekAsString(Date, Day(Date)) = "Di" And Not GetGadgetState(#CheckBox_IncludeTuesday): Continue : EndIf
If GetDayOfWeekAsString(Date, Day(Date)) = "Mi" And Not GetGadgetState(#CheckBox_IncludeWednesday): Continue : EndIf
If GetDayOfWeekAsString(Date, Day(Date)) = "Do" And Not GetGadgetState(#CheckBox_IncludeThursday): Continue : EndIf
If GetDayOfWeekAsString(Date, Day(Date)) = "Fr" And Not GetGadgetState(#CheckBox_IncludeFriday): Continue : EndIf
If GetDayOfWeekAsString(Date, Day(Date)) = "Sa" And Not GetGadgetState(#CheckBox_IncludeSaturday): Continue : EndIf
If GetDayOfWeekAsString(Date, Day(Date)) = "So" And Not GetGadgetState(#CheckBox_IncludeSunday): Continue : EndIf
If Not OpenPreferences(WorkTablesPath + "WorkTable_" + RSet(Str(Month(Date)), 2, "0") + Str(Year(Date)) + ".ini")
If Not CreatePreferences(WorkTablesPath + "WorkTable_" + RSet(Str(Month(Date)), 2, "0") + Str(Year(Date)) + ".ini")
MessageRequester("WorkTimeBook", "Daten konnten nicht eingetragen werden!")
Break
EndIf
EndIf
If GetGadgetText(#String_AutoFillWorkBegin)
WritePreferenceString("WorkBegin_" + Str(Day(Date)), GetGadgetText(#String_AutoFillWorkBegin))
EndIf
If GetGadgetText(#String_AutoFillWorkEnd)
WritePreferenceString("WorkEnd_" + Str(Day(Date)), GetGadgetText(#String_AutoFillWorkEnd))
EndIf
If GetGadgetText(#String_AutoFillWorkBreak)
WritePreferenceString("WorkBreak_" + Str(Day(Date)), GetGadgetText(#String_AutoFillWorkBreak))
EndIf
If GetGadgetText(#String_AutoFillWorkNotice)
WritePreferenceString("WorkNotice_" + Str(Day(Date)), GetGadgetText(#String_AutoFillWorkNotice))
EndIf
ClosePreferences()
Until Date > DateTo
EndProcedure