samurize plugin skeleton

Share your advanced PureBasic knowledge/code with the community.
hm
User
User
Posts: 30
Joined: Mon Oct 27, 2003 12:15 pm
Location: Germany
Contact:

samurize plugin skeleton

Post by hm »

Code updated For 5.20+

hi,
this is some quick conversion of the powerbasic examples found in the samurize forum (link).
please use the samurize website for asking questions related to samurize like "how to use samurize plugins".

tested on pb3.91 and ss1.55

Code: Select all

    ; this code is released to the public domain

    ProcedureDLL.l init ( )
      ; return address to string containing function names separated by pipe symbol
      ; no ending pipe symbol
      ProcedureReturn @"helloworld1|helloworld2|sum"
    EndProcedure

    ProcedureDLL.l getparam ( l_funcname.l )
      ; return address to string containing function parameters separated by pipe symbol
      ; end string with pipe symbol if there are any function parameters
      s_funcname.s = PeekS(l_funcname)
      If s_funcname = "helloworld1"
        ProcedureReturn @""
      ElseIf s_funcname = "helloworld2"
        ProcedureReturn @""
      ElseIf s_funcname = "sum"
        ProcedureReturn @"value1|value2|"
      EndIf
    EndProcedure

    ; every function must only accept long parameters (addresses of strings)
    ; every function must only return long values (address of string)

    ProcedureDLL.l helloworld1 ()
      ProcedureReturn @"Hello pure basic world (1)!"
    EndProcedure

    ProcedureDLL.l helloworld2 ()
      ProcedureReturn @"Hello pure basic world (2)!"
    EndProcedure

    ProcedureDLL.l sum ( value1.l, value2.l )
      Global txt.s = Str( Val(PeekS(value1)) + Val(PeekS(value2)) )
      ProcedureReturn @txt
    EndProcedure

cu
-hm