Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen gezeigt.

Link zu dieser Vergleichsansicht

nettalk:scripting:readfiles [2006/03/08 12:11]
mirici
nettalk:scripting:readfiles [2006/03/08 12:13] (aktuell)
mirici
Zeile 1: Zeile 1:
 +====== Textdatei auslesen ======
  
 +<code vb>
 +#​NewScriptBegin ReadFromFile
 +
 +Sub Load()
 +  MakeShortcut "",​ "​readfile",​ "/call ReadFromFile.StartRead",​ 2
 +End Sub
 +
 +Sub StartRead()
 +  Send "Text: " & GetLastLine("​Update.ini"​),​ FrontFrameID
 +End Sub
 +
 +Function GetLastLine(FileName)
 +  Data = ReadFile(FileName) ​
 +  i=-1
 +  i2=-1
 +  Do
 +    i3=i2
 +    i2=i
 +    i=instr(i+2,​ Data, Chr(13)+Chr(10))
 +  Loop until i=0
 +  'Falls die letzte Zeile keine Zeichen enthällt
 +  'soll die Vorletzte verwendet werden:
 +  If i2+1 = Len(Data) Then i2=i3
 +  GetLastLine = Mid(Data, i2+2)
 +End Function
 +
 +Function GetRandomLine(FileName)
 +  LineCount=20
 +  Data = ReadFile(FileName) ​
 +  i=-1
 +  i2=-1
 +  RLine=int(LineCount*Rnd)
 +  Do
 +    i3=i2
 +    i2=i
 +    LineCount=LineCount-1
 +    i=instr(i+2,​ Data, Chr(13)+Chr(10))
 +  Loop until i=0 or LineCount = RLine
 +  If i2+1 = Len(Data) Then i2=i3
 +  GetRandomLine = Mid(Data, i3+2, i2-i3-2)
 +End Function
 +</​code>​

Eigene Werkzeuge