How to create a custom library?
Posted: Fri Sep 22, 2017 8:29 pm
Is it possible to create my own PB library with compiler functions?
http://www.purebasic.com
https://www.purebasic.fr/english/
Code: Select all
;{==================================================================================
;: Name : PB Resident Maker
;: Author : George Bisonte
;: Date : July 02, 2014
;: Compiler : PureBasic 5.22 LTS (Windows - x86) - (c) 2014 Fantaisie Software
;: CompilerFlags : Debugger, XPSkin, Unicode, ThreadSafe, Usermode
;: Subsystem : none
;: TargetOS : Windows
;: License : Free
;: ---------------------------------------------------------------------------------
;}==================================================================================
;{==================================================================================
;: Configure as
;:
;: Commandline: "%FILE"
;:
;: [x] Wait until tool quits
;:
;}==================================================================================
EnableExplicit
Define.s Source, DestinationFile, PBCompiler, PBCompilerHome, Params, Output, Result
Define pc, i
Source.s = ProgramParameter()
If FileSize(Source) > 0
DestinationFile.s = GetFilePart(Source, #PB_FileSystem_NoExtension) + ".res"
PBCompiler.s = GetEnvironmentVariable("PB_TOOL_COMPILER")
PBCompilerHome.s = GetPathPart(GetEnvironmentVariable("PB_TOOL_IDE"))
Params.s = Chr(34) + Source + Chr(34) +" /RESIDENT " + Chr(34) + PBCompilerHome + "Residents\"+DestinationFile + Chr(34)
pc = RunProgram(PBCompiler, Params, "", #PB_Program_Open|#PB_Program_Read|#PB_Program_Hide)
Output.s = ""
If pc
While ProgramRunning(pc)
If AvailableProgramOutput(pc)
Result = ReadProgramString(pc) + Chr(13)
If #PB_Unicode
Result = PeekS(@Result, -1, #PB_UTF8)
EndIf
Output + Result + Chr(13)
EndIf
Wend
Output + "Exitcode: " + Str(ProgramExitCode(pc)) + Chr(13)
CloseProgram(pc)
EndIf
Else
Output = "File : '" + Source + "' not found." + Chr(13)
EndIf
MessageRequester("ResidentMaker", Output)
EndWhy don't you store the bytes of the ASCII strings in a DataSection with a label. You can then use CompareMemory() with the string in the buffer data you read from the file.Wolfram wrote:I hoped to find a comfortable way to work with asci data in a unicode program.
All the files I work with are in Asci so I can not use structures anymore to to read it or I must stop at PB 5.45.
I hoped to find a way to define a constant as asci string in a unicode project.
If you have ASCII files which contain pure ASCII strings, why not loading the files as ASCII and store them as UNICODE string in PB string variables. Then you can use standard string functions to work on the string data. When you are ready you can save the string data back as ASCII to the ASCII file.Wolfram wrote:Thanks, but this does not help.
I hoped to find a comfortable way to work with asci data in a unicode program.
All the files I work with are in Asci so I can not use structures anymore to to read it or I must stop at PB 5.45.
I hoped to find a way to define a constant as asci string in a unicode project.
Why? What do you want to do with such a constant?Wolfram wrote:I hoped to find a way to define a constant as asci string in a unicode project.