Page 1 of 1

How to create a custom library?

Posted: Fri Sep 22, 2017 8:29 pm
by Wolfram
Is it possible to create my own PB library with compiler functions?

Re: How to create a custom library?

Posted: Sat Sep 23, 2017 12:23 am
by falsam
MLF : Make Lib Factory. This is an Alpha Version https://github.com/MLF4PB/MLF-Alpha

Image

Re: How to create a custom library?

Posted: Sat Sep 23, 2017 1:36 am
by falsam
An error in the main code. GitHub updated. :oops:

Re: How to create a custom library?

Posted: Sat Sep 23, 2017 8:14 am
by Zebuddi123
Thank you falsam. :) You have just made my weekend interesting.

Dont forget new user`s ProcedureDLL is required

Zebuddi. :)

Re: How to create a custom library?

Posted: Sat Sep 23, 2017 9:56 am
by Wolfram
Thanks for this tip.

But on OSX LibraryMaker does not exist. Can I make a library on Windows and use this on OSX?

I made a test, building a simple library on windows for OSX is not possible. :-/
Also this function can not be used to define a constant.

Re: How to create a custom library?

Posted: Sat Sep 23, 2017 1:20 pm
by Bisonte
To define constants, structures and macros you have to create "resident" - files with the /RESIDENT switch.

Here is my little "Resident Maker" as an IDE Tool... I think it's crossplatform, if you change the switch / to -- .

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)

End

Re: How to create a custom library?

Posted: Sat Sep 23, 2017 6:45 pm
by Wolfram
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.

Re: How to create a custom library?

Posted: Sat Sep 23, 2017 7:41 pm
by Bisonte
Why it must be a constant and cannot be a simple variable (Or list, Map etc) ?
edit : moment... cannot read anymore ? Where is there the problem ? The structures won't fit anymore ?

I work with lots of ASCII, UTF8 and Unicode files, and I don't have problems with it....

Re: How to create a custom library?

Posted: Sat Sep 23, 2017 7:48 pm
by Demivec
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.
Why 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.

Re: How to create a custom library?

Posted: Sat Sep 23, 2017 8:20 pm
by helpy
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.
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: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?

Re: How to create a custom library?

Posted: Sun Sep 24, 2017 12:18 am
by falsam
I apologize for that. I probably published this version prematurely. There were a lot of bugs in the previous version.

■ New version of MLF
Fixed many bugs.
Added German language. (Thanks to Bisonte)

Download https://github.com/MLF4PB/MLF-Alpha/archive/master.zip

Re: How to create a custom library?

Posted: Sun Sep 24, 2017 9:45 am
by dobro
@Falsam : ouvre toi un nouveau Topic pour MLF <--- USER Library Creator
si tu veux pouvoir etre visible ;)

(open a new Topic for MLF
if you want to be visible. )