Ich hab mal ein Programm gemacht was aus einer zitatdatenbank 10-20 Zitate anzeigt.
Jede Variante eines Zitat!-Readers ist gerne willkommen. Jeder kann seine hier posten, und wir fusionieren das dann zu einem großen perfektem Zitat!-Reader, wo jeder einzeln in den Credits erwähnt wird. Übrigens das wichtigste ist, ein knapper Code!
Variante von mir:
Spoiler anzeigen
#Include <File.au3>
;by campweb
$file = FileOpen("zitate.zit", 0)
MsgBox(0, "Zitat! by campweb", "Willkommen bei Zitat!"&@crlf&@crlf&"Klicken Sie einfach auf OK, um das nächste Zitat zu lesen. Wenn das Programm meint es reicht für heute, wird es beendet."&@crlf&"Viel Spaß!")
If $file = -1 Then
MsgBox(0, "Error", "Zitatdatei ist gelöscht!")
Exit
EndIf
While 1
$rnd = Random(1, 1575, 1)
$line = FileReadLine($file, $rnd)
If @error = -1 Then ExitLoop
MsgBox(0, "Zitat! by campweb", $line)
Wend
FileClose($file)
[/autoit]Variante von Nitrama:
Spoiler anzeigen
#Include <File.au3>
#include <Misc.au3>
$dll = DllOpen("user32.dll")
$file = FileOpen("zitate.zit", 0)
$zeilen =_FileCountLines("zitate.zit")
$rnd = Random(1, $zeilen, 1)
$line = FileReadLine($file, $rnd)
HotKeySet("{ESC}", "_Quit")
While 1
Sleep (10)
If _IsPressed("01", $dll) Then
_neu ()
EndIf
$pos = MouseGetPos()
$pos[0] += 10
$pos[1] += 10
ToolTip($line, $pos[0] , $pos[1])
WEnd
Func _Quit()
FileClose ($file)
DllClose($dll)
Exit
EndFunc
[/autoit] [autoit][/autoit] [autoit]Func _neu ()
$rnd = Random(1, $zeilen, 1)
$line = FileReadLine($file, $rnd)
EndFunc
Variante von mireko:
Spoiler anzeigen
#include <File.au3>
;by campweb(edited by mireko)
$file = FileOpen("zitate.zit", 0)
MsgBox(0, "Zitat! by campweb(edited by mireko)", "Willkommen bei Zitat!" & @CRLF & @CRLF & "Klicken Sie einfach auf OK, um das nächste Zitat zu lesen. Wenn das Programm meint es reicht für heute, wird es beendet." & @CRLF & "Viel Spaß!")
Do
$zitatanzahl = InputBox("Zitate pro Seite", "Wie viele Zitate möchtest du auf einmal sehen? max.10")
Until $zitatanzahl < 11
If $file = -1 Then
MsgBox(0, "Error", "Zitatdatei ist gelöscht!")
Exit
EndIf
While 1
$line = ""
For $i = 1 To $zitatanzahl Step +1
$rnd = Random(1, 1575, 1)
$line &= FileReadLine($file, $rnd)
$line &= @LF
$line &= @LF
If @error = -1 Then ExitLoop (2)
Next
$ant = MsgBox(1, "Zitat! by campweb(edited by mireko)", $line)
If $ant = 2 Then
MsgBox(0, "Ende", "ende")
Exit
EndIf
WEnd
FileClose($file)
Die Zitatdatenbank ist im Anhang mit 1575 Zitaten, also bitte nicht misbrauchen, es war eine reine Fleißarbeit.