How to create a custom library?

Just starting out? Need help? Post your questions and find answers here.
Wolfram
Enthusiast
Enthusiast
Posts: 567
Joined: Thu May 30, 2013 4:39 pm

How to create a custom library?

Post by Wolfram »

Is it possible to create my own PB library with compiler functions?
macOS Catalina 10.15.7
User avatar
falsam
Enthusiast
Enthusiast
Posts: 630
Joined: Wed Sep 21, 2011 9:11 am
Location: France
Contact:

Re: How to create a custom library?

Post by falsam »

MLF : Make Lib Factory. This is an Alpha Version https://github.com/MLF4PB/MLF-Alpha

Image

➽ Windows 11 64-bit - PB 6.0 x64 - AMD Ryzen 7 - NVIDIA GeForce GTX 1650 Ti

Sorry for my bad english and the Dunning–Kruger effect.
User avatar
falsam
Enthusiast
Enthusiast
Posts: 630
Joined: Wed Sep 21, 2011 9:11 am
Location: France
Contact:

Re: How to create a custom library?

Post by falsam »

An error in the main code. GitHub updated. :oops:

➽ Windows 11 64-bit - PB 6.0 x64 - AMD Ryzen 7 - NVIDIA GeForce GTX 1650 Ti

Sorry for my bad english and the Dunning–Kruger effect.
User avatar
Zebuddi123
Enthusiast
Enthusiast
Posts: 794
Joined: Wed Feb 01, 2012 3:30 pm
Location: Nottinghamshire UK
Contact:

Re: How to create a custom library?

Post by Zebuddi123 »

Thank you falsam. :) You have just made my weekend interesting.

Dont forget new user`s ProcedureDLL is required

Zebuddi. :)
malleo, caput, bang. Ego, comprehendunt in tempore
Wolfram
Enthusiast
Enthusiast
Posts: 567
Joined: Thu May 30, 2013 4:39 pm

Re: How to create a custom library?

Post 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.
macOS Catalina 10.15.7
User avatar
Bisonte
Addict
Addict
Posts: 1226
Joined: Tue Oct 09, 2007 2:15 am

Re: How to create a custom library?

Post 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
PureBasic 6.04 LTS (Windows x86/x64) | Windows10 Pro x64 | Asus TUF X570 Gaming Plus | R9 5900X | 64GB RAM | GeForce RTX 3080 TI iChill X4 | HAF XF Evo | build by vannicom​​
English is not my native language... (I often use DeepL to translate my texts.)
Wolfram
Enthusiast
Enthusiast
Posts: 567
Joined: Thu May 30, 2013 4:39 pm

Re: How to create a custom library?

Post 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.
macOS Catalina 10.15.7
User avatar
Bisonte
Addict
Addict
Posts: 1226
Joined: Tue Oct 09, 2007 2:15 am

Re: How to create a custom library?

Post 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....
PureBasic 6.04 LTS (Windows x86/x64) | Windows10 Pro x64 | Asus TUF X570 Gaming Plus | R9 5900X | 64GB RAM | GeForce RTX 3080 TI iChill X4 | HAF XF Evo | build by vannicom​​
English is not my native language... (I often use DeepL to translate my texts.)
User avatar
Demivec
Addict
Addict
Posts: 4086
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: How to create a custom library?

Post 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.
User avatar
helpy
Enthusiast
Enthusiast
Posts: 552
Joined: Sat Jun 28, 2003 12:01 am

Re: How to create a custom library?

Post 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?
Windows 10 / Windows 7
PB Last Final / Last Beta Testing
User avatar
falsam
Enthusiast
Enthusiast
Posts: 630
Joined: Wed Sep 21, 2011 9:11 am
Location: France
Contact:

Re: How to create a custom library?

Post 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

➽ Windows 11 64-bit - PB 6.0 x64 - AMD Ryzen 7 - NVIDIA GeForce GTX 1650 Ti

Sorry for my bad english and the Dunning–Kruger effect.
User avatar
dobro
Enthusiast
Enthusiast
Posts: 766
Joined: Sun Oct 31, 2004 10:54 am
Location: France
Contact:

Re: How to create a custom library?

Post 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. )
Image
Windows 98/7/10 - PB 5.42
■ sites : http://michel.dobro.free.fr/
Post Reply