My Workaround Collection
My Workaround Collection
Purebasic is my favorite development environment and I also create professional applications and tools.
Even if Purebasic has few bugs, they do occur. For these, however, there is usually a simple solution to fix until the next release via a workaround.
I cleaned up and summarized my workaround, because I can't find most of them myself.
Furthermore, the workaround are rewritten as modules, so that they can be used more easily in the module
This workaround should always be cross-platform and easy to extend.
Even if Purebasic has few bugs, they do occur. For these, however, there is usually a simple solution to fix until the next release via a workaround.
I cleaned up and summarized my workaround, because I can't find most of them myself.
Furthermore, the workaround are rewritten as modules, so that they can be used more easily in the module
This workaround should always be cross-platform and easy to extend.
Last edited by mk-soft on Fri Aug 24, 2018 12:34 pm, edited 2 times in total.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: My Workaround Collection
Workaround-560.pb
[/size]
Code: Select all
;-TOP
; Workaround PB v5.60
; Version : v1.0
; Create : 24.08.2018
; Update :
; -----------------------------------------------------------------------------
;- Global
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_MacOS
;TODO
CompilerCase #PB_OS_Windows
;TODO
CompilerCase #PB_OS_Linux
; Ubuntu Compiler bug
ImportC "-no-pie" : EndImport
CompilerEndSelect
; -----------------------------------------------------------------------------
;- Module
DeclareModule __Workaround
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_MacOS
Declare FixResizeGadget(Gadget, x, y, width, height)
Declare FixSetGadgetFont(Gadget, FontID)
Declare FixAddGadgetItem(Gadget, Position, Text.s, Image=0, Flags=0)
CompilerCase #PB_OS_Windows
;TODO
CompilerCase #PB_OS_Linux
Declare FixWriteData(file, *adress, length)
CompilerEndSelect
EndDeclareModule
Module __Workaround
EnableExplicit
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_MacOS
; Link https://www.purebasic.fr/english/viewtopic.php?f=24&t=71269
; Canvas Gadget Container Bugfix
Procedure FixResizeGadget(Gadget, x, y, width, height)
ResizeGadget(Gadget, x, y, width, height)
Protected rect.NSRect, sv, container
If GadgetType(Gadget) <> #PB_GadgetType_Canvas
ProcedureReturn 1
EndIf
sv = CocoaMessage(0, GadgetID(Gadget), "subviews")
If CocoaMessage(0, sv, "count")
container = CocoaMessage(0, sv, "objectAtIndex:", 0)
If container
CocoaMessage(@rect, GadgetID(Gadget), "frame")
rect\origin\x = 0
rect\origin\y = 0
CocoaMessage(0, container, "setFrame:@", @rect)
EndIf
EndIf
EndProcedure
; Link http://www.purebasic.fr/english/viewtopic.php?f=24&t=68571
Procedure FixSetGadgetFont(Gadget, FontID)
SetGadgetFont(Gadget, #PB_Default)
SetGadgetFont(Gadget, FontID)
EndProcedure
; Link http://www.purebasic.fr/english/viewtopic.php?f=24&t=68494
Procedure FixAddGadgetItem(Gadget, Position, Text.s, Image=0, Flags=0)
Protected font
AddGadgetItem(Gadget, Position, Text, Image, Flags)
If GadgetType(Gadget) = #PB_GadgetType_Editor
font = GetGadgetFont(Gadget)
If font
SetGadgetFont(Gadget, font)
EndIf
EndIf
EndProcedure
CompilerCase #PB_OS_Windows
;TODO
CompilerCase #PB_OS_Linux
; Link http://www.purebasic.fr/english/viewtopic.php?f=23&t=68630
Procedure FixWriteData(file, *adress, length) ; Workaround for Linux PB560
Protected write_data_pointer=Loc(file)
Protected writen_data=WriteData(file, *adress, length)
FileSeek(file, write_data_pointer+writen_data)
ProcedureReturn writen_data
EndProcedure
CompilerEndSelect
EndModule
; -----------------------------------------------------------------------------
;- Macro
DeclareModule Workaround
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_MacOS
Macro ResizeGadget(Gadget, x, y, width, height)
__Workaround::FixResizeGadget(Gadget, x, y, width, height)
EndMacro
Macro SetGadgetFont(Gadget, FontID)
__Workaround::FixSetGadgetFont(Gadget, FontID)
EndMacro
Macro AddGadgetItem(Gadget, Position, Text, Image=0, Flags=0)
__Workaround::FixAddGadgetItem(Gadget, Position, Text, Image, Flags)
EndMacro
CompilerCase #PB_OS_Windows
;TODO
CompilerCase #PB_OS_Linux
Macro WriteData(File, Buffer, Size)
__Workaround::FixWriteData(File, Buffer, Size)
EndMacro
CompilerEndSelect
EndDeclareModule
Module Workaround
EndModule
; -----------------------------------------------------------------------------
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: My Workaround Collection
Workaround-562.pb
[/size]
Code: Select all
;-TOP
; Workaround PB v5.62
; Version : v1.0
; Create : 24.08.2018
; Update :
; -----------------------------------------------------------------------------
;- Global
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_MacOS
;TODO
CompilerCase #PB_OS_Windows
;TODO
CompilerCase #PB_OS_Linux
; Ubuntu compiler bug
ImportC "-no-pie" : EndImport
CompilerEndSelect
; -----------------------------------------------------------------------------
;- Module
DeclareModule __Workaround
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_MacOS
Declare FixResizeGadget(Gadget, x, y, width, height)
CompilerCase #PB_OS_Windows
;TODO
CompilerCase #PB_OS_Linux
;TODO
CompilerEndSelect
EndDeclareModule
Module __Workaround
EnableExplicit
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_MacOS
; Link https://www.purebasic.fr/english/viewtopic.php?f=24&t=71269
; Canvas Gadget Container Bugfix
Procedure FixResizeGadget(Gadget, x, y, width, height)
ResizeGadget(Gadget, x, y, width, height)
Protected rect.NSRect, sv, container
If GadgetType(Gadget) <> #PB_GadgetType_Canvas
ProcedureReturn 1
EndIf
sv = CocoaMessage(0, GadgetID(Gadget), "subviews")
If CocoaMessage(0, sv, "count")
container = CocoaMessage(0, sv, "objectAtIndex:", 0)
If container
CocoaMessage(@rect, GadgetID(Gadget), "frame")
rect\origin\x = 0
rect\origin\y = 0
CocoaMessage(0, container, "setFrame:@", @rect)
EndIf
EndIf
EndProcedure
CompilerCase #PB_OS_Windows
;TODO
CompilerCase #PB_OS_Linux
;TODO
CompilerEndSelect
EndModule
; -----------------------------------------------------------------------------
;- Macro
DeclareModule Workaround
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_MacOS
Macro ResizeGadget(Gadget, x, y, width, height)
__Workaround::FixResizeGadget(Gadget, x, y, width, height)
EndMacro
CompilerCase #PB_OS_Windows
;TODO
CompilerCase #PB_OS_Linux
;TODO
CompilerEndSelect
EndDeclareModule
Module Workaround
EndModule
; -----------------------------------------------------------------------------
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: My Workaround Collection
Base for extended workaround
Workaround-Empty.pb
[/size]
Workaround-Empty.pb
Code: Select all
;-TOP
; Workaround PB Empty
; Version : v1.0
; Create : 24.08.2018
; Update :
; -----------------------------------------------------------------------------
;- Global
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_MacOS
;TODO
CompilerCase #PB_OS_Windows
;TODO
CompilerCase #PB_OS_Linux
;TODO
CompilerEndSelect
; -----------------------------------------------------------------------------
;- Module
DeclareModule __Workaround
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_MacOS
;TODO
CompilerCase #PB_OS_Windows
;TODO
CompilerCase #PB_OS_Linux
;TODO
CompilerEndSelect
EndDeclareModule
Module __Workaround
EnableExplicit
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_MacOS
;TODO
CompilerCase #PB_OS_Windows
;TODO
CompilerCase #PB_OS_Linux
;TODO
CompilerEndSelect
EndModule
; -----------------------------------------------------------------------------
;- Macro
DeclareModule Workaround
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_MacOS
;TODO
CompilerCase #PB_OS_Windows
;TODO
CompilerCase #PB_OS_Linux
;TODO
CompilerEndSelect
EndDeclareModule
Module Workaround
EndModule
; -----------------------------------------------------------------------------
Last edited by mk-soft on Fri Aug 24, 2018 12:55 pm, edited 3 times in total.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
- RSBasic
- Moderator
- Posts: 1218
- Joined: Thu Dec 31, 2009 11:05 pm
- Location: Gernsbach (Germany)
- Contact:
Re: My Workaround Collection
Good idea
At home I also have a few workarounds.
1 workaround for FTP text conversion:
Or with my library: viewtopic.php?f=27&t=70380
At home I also have a few workarounds.
1 workaround for FTP text conversion:
Code: Select all
Procedure.s AsciiToUTF8(String$)
Protected Buffer$
Buffer$ = Space(Len(String$))
PokeS(@Buffer$, String$, -1, #PB_Ascii)
String$ = PeekS(@Buffer$, -1, #PB_UTF8)
ProcedureReturn String$
EndProcedure
Re: My Workaround Collection
Thanks this is useful
Re: My Workaround Collection
Thanks,
My goal is to have a workaround that can always be changed with the next release of purebasic without changing the other code.
I've dropped an empty workaround so that I can add tested code more easily,
or use a separate workaround for certain libraries if needed. For example WorkaroundFTP.pb
My goal is to have a workaround that can always be changed with the next release of purebasic without changing the other code.
I've dropped an empty workaround so that I can add tested code more easily,
or use a separate workaround for certain libraries if needed. For example WorkaroundFTP.pb
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: My Workaround Collection
You could additionally check the constant #PB_Compiler_Version, so that the correct workarounds are used for each PB version:
Code: Select all
CompilerSelect #PB_Compiler_Version
CompilerCase 560 : XIncludeFile "Workarounds-560.pbi"
CompilerCase 562 : XIncludeFile "Workarounds-562.pbi"
Default : XIncludeFile "Workarounds-All.pbi"
CompilerEndSelect
Why OpenSource should have a license :: PB-CodeArchiv-Rebirth :: Pleasant-Dark (syntax color scheme) :: RegEx-Engine (compiles RegExes to NFA/DFA)
Manjaro Xfce x64 (Main system) :: Windows 10 Home (VirtualBox) :: Newest PureBasic version
- RSBasic
- Moderator
- Posts: 1218
- Joined: Thu Dec 31, 2009 11:05 pm
- Location: Gernsbach (Germany)
- Contact:
Re: My Workaround Collection
Workaround for FileSize():
FileSize() (FindFirstFile_()) in Windows supports wildcards.
But I don't want that, because I want to know exactly with the given file name whether the file with the exact file name exists.
Solution code:
FileSize() (FindFirstFile_()) in Windows supports wildcards.
But I don't want that, because I want to know exactly with the given file name whether the file with the exact file name exists.
Solution code:
Code: Select all
Procedure FileSizeEx(FileName$)
Protected p
FileName$ = ReplaceString(FileName$, "*", "_")
FileName$ = ReplaceString(FileName$, "?", "_")
FileName$ = ReplaceString(FileName$, "<", "_")
FileName$ = ReplaceString(FileName$, ">", "_")
FileName$ = ReplaceString(FileName$, Chr(34), "_")
If FileSize(FileName$) <> -2
p = Len(FileName$)
While p >= 1 And FindString("/\", Mid(FileName$, p, 1)) <> 0
p-1
Wend
If Len(FileName$) <> Len(Left(FileName$, p))
FileName$ + "_"
EndIf
EndIf
ProcedureReturn FileSize(FileName$)
EndProcedure
Macro FileSize(FileName)
FileSizeEx(FileName)
EndMacro