Just a small frame for your BOM procedure.
Code: Select all
;{- Program header
;==Code Header Comment==============================
; Name/title: BOMBOMDetector.pb
; Executable name: BOMBOMDetector.exe
; Version: 1.0
; Author: Demivec
; Collaborators: Amílcar Matos Pérez
; Translation by:
; Create date: 03/Dec/2015
; Previous releases:
;Most recent update:
; Release date/hour:
; Operating system: Windows [X]GUI
; Compiler version: PureBasic 5.31 (x86)
; Copyright: (C)2015 AMP All rights reserved.
; License:
; Libraries:
; Forum: http://www.purebasic.fr/english/viewtopic.php?f=13&t=64180&sid=ec0e244cfabf06876bfd82d3f709cc1c
; Tested platforms: Windows
; Explanation: To detect the file encoding by examining the file content.
; ==================================================
;.......10........20........30........40........50........60........70........80
;}
;{ Declare procedures
Declare.s BrowseProcedure()
Declare.l ClearWindowDataEntryFields (Window_BOMBOM)
Declare OpenWindow_BOMBOM (x = 0, y = 0, width = 600, height = 400)
Declare.l Window_Events (Event_BOMBOM)
;}
;{ Variable exposure stmts
Global Window_BOMBOM
Global BrowseButton_BOMBOM
Global ClipBoardButton_BOMBOM
Global ClearButton_BOMBOM
Global DetectButton_BOMBOM
Global ExitButton_BOMBOM
Global FileNameStr
Global ResultsEditor
Global Text_0
Global Text_1
;}
Enumeration FormFont
#Font_Window_BOMBOM_0
EndEnumeration
LoadFont(#Font_Window_BOMBOM_0,"Consolas", 14)
OpenWindow_BOMBOM()
ClearWindowDataEntryFields(Window_BOMBOM)
Repeat
Event_BOMBOM = WaitWindowEvent()
Quit_BOMBOM = Window_Events(Event_BOMBOM)
Until Quit_BOMBOM = 0
End
Procedure.l Window_Events(Event_BOMBOM)
Select Event_BOMBOM
Case #PB_Event_CloseWindow
ProcedureReturn #False
Case #PB_Event_Gadget
Select EventGadget()
Case ExitButton_BOMBOM ;{- Exit"
ProcedureReturn #False ;}
Case ClearButton_BOMBOM ;{- Clear Data Entry Fields
ClearWindowDataEntryFields(Window_BOMBOM)
ProcedureReturn #True ;}
Case BrowseButton_BOMBOM ;{- Browse for file to test.
SetGadgetText(FileNameStr, BrowseProcedure())
ProcedureReturn #True ;}
Case ClipBoardButton_BOMBOM ;{- Copy the results to the clipboard.
SetClipboardText(GetGadgetText(ResultsEditor))
ProcedureReturn #True ;}
Case DetectButton_BOMBOM ;{- Detect BOM
; TODO Insert here the BOM detector procedure.
ProcedureReturn #True ;}
EndSelect
EndSelect
ProcedureReturn #True
EndProcedure
Procedure.l ClearWindowDataEntryFields(Window_BOMBOM)
;{- Procedure explanation
; To blank the screen data entry fields.
;}
SetGadgetText(FileNameStr , #NULL$)
SetGadgetText(ResultsEditor, #NULL$)
SetActiveGadget(FileNameStr)
ProcedureReturn #True
EndProcedure ; ClearWindowDataEntryFields(Window_BOMBOM)
Procedure.s BrowseProcedure()
;{- Procedure explanation
; To ease the file selection task.
;}
;{- Protected variables
Protected StandardFile$
Protected File$
Protected Pattern$
;}
StandardFile$ = "C:\" ; set initial file+path to display
; With next string we will set the search patterns ("|" as separator) for file displaying:
; 1st: "Text (*.txt)" as name, ".txt" and ".bat" as allowed extension
; 2nd: "PureBasic (*.pb)" as name, ".pb" as allowed extension
; 3rd: "All files (*.*) as name, "*.*" as allowed extension, valid for all files
Pattern$ = "Text (*.txt)|*.txt;*.bat|PureBasic (*.pb)|*.pb|All files (*.*)|*.*"
Pattern = 0 ; use the first of the three possible patterns as standard
File$ = OpenFileRequester("Please choose file to test", StandardFile$, Pattern$, Pattern)
ProcedureReturn File$
EndProcedure ; BrowseProcedure
; PB Forms Code
; This code is automatically generated by the FormDesigner.
; Manual modification is possible to adjust existing commands, but anything else will be dropped when the code is compiled.
; Event procedures needs to be put in another source file.
;
Procedure OpenWindow_BOMBOM(x = 0, y = 0, width = 600, height = 400)
Window_BOMBOM = OpenWindow(#PB_Any, x, y, width, height, "BOM-BOM Detector", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered)
CreateStatusBar(0, WindowID(Window_BOMBOM))
AddStatusBarField(150)
StatusBarText(0, 0, "(c) 2015 Demivec")
ExitButton_BOMBOM = ButtonGadget(#PB_Any, 510, 330, 60 , 30, "Exit" )
ClearButton_BOMBOM = ButtonGadget(#PB_Any, 280, 330, 100, 30, "Clear" )
DetectButton_BOMBOM = ButtonGadget(#PB_Any, 400, 330, 100, 30, "Detect")
BrowseButton_BOMBOM = ButtonGadget(#PB_Any, 510, 40, 60, 30, "Browse")
ClipBoardButton_BOMBOM = ButtonGadget(#PB_Any, 510, 280, 60, 30, "Copy To Clipboard", #PB_Button_MultiLine)
Text_0 = TextGadget(#PB_Any, 10, 40, 60, 15, "Filename")
Text_1 = TextGadget(#PB_Any, 10, 90, 50, 15, "Results" )
FileNameStr = StringGadget(#PB_Any, 70, 40 , 430, 30 , #NULL$)
ResultsEditor = EditorGadget(#PB_Any, 20, 110, 480, 200)
SetGadgetFont(FileNameStr , FontID(#Font_Window_BOMBOM_0))
SetGadgetFont(ResultsEditor, FontID(#Font_Window_BOMBOM_0))
EndProcedure