OpenFile
OpenFile
with ButtonGadget, how do you open a file from anywhere on a pc and put to TextGadget or StringGadget? thanks to who ever replies. been stuck on this and can't seem to figure it out or for it to function.
Code: Select all
Procedure OFile(file.s)
d=readFile(1, file)
If d
While Eof(1)=0
Text$ = text$+ReadString()+Chr(13)+ Chr(10)
Wend
CloseFile(1)
SetGadgetText(2, Text$)
Else
MessageRequester("Error","No valid file was selected.",#MB_ICONERROR)
EndIf
EndProcedure
If OpenWindow(0, 100, 200, 495, 260, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget, "Open Small Files Example")
CreateGadgetList(WindowID())
ButtonGadget(1,210,20,80,25,"Open File")
StringGadget(2,10,60,480,185,"",#PB_String_Multiline|#ES_AUTOVSCROLL|#WS_VSCROLL|#WS_HSCROLL)
;TextGadget(2,10,60,480,185,"",#PB_Text_Border )
Repeat
EventID.l = WaitWindowEvent()
If EventID = #PB_Event_CloseWindow
Quit = 1
EndIf
If EventID = #PB_EventGadget
Select EventGadgetID()
Case 1
file$ = OpenFileRequester("Open File","","All Files|*.*",1)
OFile(file$)
EndSelect
EndIf
Until Quit = 1
EndIf
End

