Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

64-bit Plugin development using PureBasic

Aug
1,904
68
I am attempting to generate a 64-bit TCC plugin template using PureBasic.

Back in 2011, @gwgaston provided a 32-bit PowerBasic solution for me, which allowed me to develop several plugins for 32-bit TCC.

(Bob Zale, owner and developer of PowerBasic, passed away in 2012, thus no 64-bit version of PowerBasic is available.)

What I have tried with PureBasic, so far, is not working properly.

I have posted the source code and issues I am having on the PureBasic Forum.

Is there any TCC user who uses PureBasic, and would be interested in the development of a TCC plugin template?

Joe
 
Thanks to the guidance of Mijikai at the PureBasic forum, I now have a working TCC Plugin Template, compile-able with PureBasic.
Code:
EnableExplicit

Import ""
  wprintf.i(format.s)
EndImport

Structure PLUGININFO_STRUCT
    *pszDll
    *pszAuthor
    *pszEmail
    *pszWWW
    *pszDescription
    *pszFunctions    
    nMajor.l
    nMinor.l
    nBuild.l
    hModule.i
    *pszModule
EndStructure

ProcedureDLL.i InitializePlugin()
  ProcedureReturn #Null  
EndProcedure

ProcedureDLL.i ShutdownPlugin(bEndProcess.b)
  ProcedureReturn #Null  
EndProcedure

ProcedureDLL.i GetPluginInfo()
  Static pi.PLUGININFO_STRUCT
  Static DLLname.s
  Static DLLauth.s
  Static DLLmail.s
  Static DLLwww.s
  Static DLLdesc.s
  Static DLLfuns.s
  
  DLLname = "PBPlugin"
  DLLauth = "Joe Caverly"
  DLLmail = "[email protected]"
  DLLwww  = "https://www.twitter.com/JoeC4281"
  DLLdesc = "TCC Plugin Template written using Purebasic"
  DLLfuns = "Dummy,@Reverse,@PlusOne,_hello"
  
  pi\pszDll         = @DLLname
  pi\pszAuthor      = @DLLauth
  pi\pszEmail       = @DLLmail
  pi\pszWWW         = @DLLwww
  pi\pszDescription = @DLLdesc
  pi\pszFunctions    = @DLLfuns
  pi\nMajor.l       = 2021
  pi\nMinor.l       = 08
  pi\nBuild.l       = 27

  ProcedureReturn @pi
EndProcedure

; Command
ProcedureDLL.i Dummy(*lpszString)
  Static theString.s
  Static theValue.i
  
  theString = PeekS(*lpszString)
  
  If Len(theString) < 1
    wprintf("USAGE: Dummy <text>")
  Else
    theString = LTrim(RTrim(theString))
    wprintf(theString)
  EndIf
  
  ProcedureReturn #Null
EndProcedure

; Function
ProcedureDLL.i f_Reverse(*lpszString)
  Static theString.s
  Static theValue.i
  
  theString = PeekS(*lpszString)
  theString = ReverseString(theString)
  
  PokeS(*lpszString,theString)
  
  ProcedureReturn #Null
EndProcedure

; Function
ProcedureDLL.i f_PlusOne(*lpszString)
  Static theString.s
  Static theValue.i
  
  theString = PeekS(*lpszString)
  
  theValue = Val(theString)
  theValue = theValue + 1
  
  theString = Str(theValue)
  
  PokeS(*lpszString,theString)
  
  ProcedureReturn #Null
EndProcedure

; Internal Variable
ProcedureDLL.i _hello(*lpszString)
  PokeS(*lpszString,"Hello!")
  
  ProcedureReturn #Null
EndProcedure

I've attached the PBPlugin (plugin.dll) to this message.

Here's a .BTM that I used to test the plugin;
Code:
@setlocal
@echo off
if plugin pbplugin plugin /u pbplugin
plugin /l plugin.dll
plugin /i PBPlugin
echo @Reverse: %@PBPlugin$Reverse[Today]
echo @PlusOne: %@PlusOne[27]
echo _hello  : %_hello
Dummy Test
endlocal

Execution of said .BTM produced these results;
Code:
Module:      E:\Documents\PureBasic\tcc\2021-08-27\plugin.dll
Name:        PBPlugin
Author:      Joe Caverly
Email:       [email protected]
Web:         https://www.twitter.com/JoeC4281
Description: TCC Plugin Template written using Purebasic
Implements:  Dummy,@Reverse,@PlusOne,_hello
Version:     2021.8  Build 27
@Reverse: yadoT
@PlusOne: 28
_hello  : Hello!
Test

Lord willing, I can now make a 64-bit version of my dbase plugin!

Joe
 

Attachments

  • pbplugin.zip
    3.8 KB · Views: 210
Heehee! I used "True Basic" 30+ years ago and I remember absolutely nothing about it.
 
Commodore BASIC here. According to Edsger Dijkstra, I am now mentally mutilated beyond hope of regeneration.
Heehee! (again) I had to print out the Commodore's BASIC code for "African Safari" (or whatever it was called) to find out what the prize was and how to get it!
 
P.S., I wasn't a gamer then and I'm not one now (except for the more than occasional Solitaire, Freecell, and Winmine (all imported from Windows 7).
 
The Basic Programming languages of today are closer to C than the Basic of 30 years ago.

Joe
 
The Basic Programming languages of today are closer to C than the Basic of 30 years ago.
It's just somebody effortlessly renamed language constructs to appear as another language.
rofl.gif
 
Joe, the new DBF64 plugin is working well. I'd prefer comma as separator rather than space, but I could live with it the way it is.
 
Dave, I will make the change to accomodate the comma as separator.

Thankyou for the feedback.

Joe
 
Hey @dcantor,
I have made the requested change, and have available dbf64.zip, which contains;
Code:
e:\documents\purebasic\dbf>zip /v dbf64.zip
2021-09-14  15:15        391,089   99%  CASH.DBF
2021-09-21  17:26         26,112   56%  dbf64.dll
2021-09-21  17:34          3,025   67%  testdbf.btm

Let me know how it goes.

Joe
 
Joe,

The @recsize function appears to be returning a wrong value. It looks like it's reading a single byte for the length and ignoring the higher order byte.
I have a .dbf where the record size is 637, but @recsize tells me 125: a difference of 512. So, as a result, %@record[dbfname,recno] does not return correct data.
 
Hey @dcantor,
Thanks for the bug report.

I've found the problem, made changes, and have uploaded an update.

Please test, and let me know how it goes.

Joe
 
I'll be testing it more fully tomorrow, but a quick check against the file I reported in my bug report now shows the correct record length 637.
Thanks for the quick action.
 
Last edited:
I've done quite a bit of testing and I've found no problem. Thanks for supplying this plugin.
 

Similar threads

Back
Top