@ts-soft:
mbuettner hat geschrieben:
Ich benutze Scintillahelper (SCI_LoadFile)
Sagt das nicht schon fast alles aus? Nachdem das ganze Lesen von Scintillahelper übernommen wird, habe ich damit nichts am Hut. Hier vielleicht noch die Prozedur, wo SCI_LoadFile aufgerufen wird:
Code:
Procedure OFile(file.s, fileid.l)
ReDim paths(fileid)
paths(fileid) = GetPathPart(file)
ReDim files(fileid)
files(fileid) = GetFilePart(file)
AddGadgetItem(0,CountGadgetItems(0),GetFilePart(file),ImageID(100))
ScintillaGadget(100 + fileid,0,0,WindowWidth(0)-5,WindowHeight(0)-95,#Null)
If SCI_LoadFile(100 + fileid,file) = #True
ScintillaSendMessage(100+fileid,#SCI_SETSAVEPOINT)
ScintillaSendMessages(100+fileid,LineWrapping)
ProcedureReturn #True
Else
ProcedureReturn #False
EndIf
EndProcedure
Und für alle, die Scintillahelper nicht benutzen:
Code:
Procedure SCI_LoadFile(ID, FileName.s)
Protected FF, Format, length, *mem, Text.s
FF = ReadFile(#PB_Any, FileName)
If FF
Select ReadStringFormat(FF)
; hier wird das StringFormat ermittelt und entsprechend gleich die Codepage eingestellt
Case #PB_Unicode
Format = #PB_Unicode
ScintillaSendMessage(ID, #SCI_SETCODEPAGE, 65001)
Case #PB_UTF8
Format = #PB_UTF8
ScintillaSendMessage(ID, #SCI_SETCODEPAGE, #SC_CP_UTF8)
Default
Format = #PB_Ascii
ScintillaSendMessage(ID, #SCI_SETCODEPAGE, 0)
EndSelect
length = Lof(FF)
If length
*mem = AllocateMemory(length)
If *mem
If ReadData(FF, *mem, length)
Text = PeekS(*mem, length, Format)
If SCI_SetGadgetText(ID, Text.s)
FreeMemory(*mem)
CloseFile(FF)
ProcedureReturn #True
EndIf
Else
MessageRequester(#Name,"Can't read data!")
EndIf
EndIf
EndIf
CloseFile(FF)
EndIf
EndProcedure
MfG
Markus