Announcement

Collapse
No announcement yet.

PB DLL wants dynamic string BYVAL

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #21
    > Gee if it is so well known what was this all about

    What that was about was offering Mr. Squires an alternative to rewriting the function, simultaneously making his function easily usable by MS VB users AND avoiding the backward incompatibilities it would have created for his existing PowerBASIC users.


    MCM
    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment


      #22
      Just got done testing a DLL which accepts the BYVAL strings from VB as ASCIIZ and passes them
      to the SQLitening.DLL. No more crashes in the VB6 environment or GPF's compiled.
      Probably some byte array passed as STRPTR or the like might allow directly calling within VB6.
      The VB'ers should stop using it passing incorrect values. How they got around lock-ups and
      GPF's is beyond me.
      Last edited by Mike Doty; 21 Oct 2008, 03:03 PM.

      Comment


        #23
        Michael
        Thats got to be the biggest BS reply I have seen you give yet.
        Your suggestion required a re-write of the DLL to add the extra functions, currently the DLL is very difficult to use with MS VB unless they release a new Service Pack just for you with PEEK and POKE functions
        As for the existing PB users IF and they use an upgraded version of the DLL (they don't need to) or just change a few declares WOW.
        Of course if they have multiple applications using the DLL then I hope they know how to have the different versions of the DLL in the correct places. I know never upgrade, still on windows 2 or are you now on 3.1.
        You actually got it right on your first post in this thread
        I'm not a VB guy
        So as the question was about VB why did you bother posting apart from getting your post count up.
        John
        PS when I post bad info I admit it, go back and look at your posts about why columns of numbers could not be done with proportional spaced fonts, then proudly announced weeks later you had discovered a way to do it

        Comment


          #24
          At least I made an effort to help the man.
          Michael Mattias
          Tal Systems (retired)
          Port Washington WI USA
          [email protected]
          http://www.talsystems.com

          Comment


            #25
            Note he stated "the man". You 2, quit it.

            Comment


              #26
              Matter of fact, you wouldn't have to TOUCH the existing DLL.

              Write a SECOND DLL, containing only the "Z" functions... all they do is call the functions in the FIRST DLL.

              Then for the icing on the cake.... you make the second DLL an additional-price addon: The "Visual Basic Compatibility Kit."

              MCM
              Michael Mattias
              Tal Systems (retired)
              Port Washington WI USA
              [email protected]
              http://www.talsystems.com

              Comment


                #27
                That is what I did. SQLitening is open source.
                Some of them look like this.

                Code:
                DECLARE SUB mSetProcessMods LIB "connect.dll" ALIAS "MSETPROCESSMODS" (BYREF RsModChars AS STRING) 'no change
                DECLARE FUNCTION mConnect   LIB "connect.dll" ALIAS "MCONNECT"(OPT sServer AS ASCIIZ, _
                                                   OPT BYVAL PortNumber AS LONG, OPT rsModChars AS ASCIIZ) AS LONG
                DECLARE FUNCTION mOpen LIB "connect.dll" ALIAS "MOPEN" (OPT rsFileName AS ASCIIZ, OPT rsModChars AS ASCIIZ) AS LONG
                DECLARE SUB      mDisconnect LIB "connect.dll" ALIAS "MDISCONNECT"
                Code:
                FUNCTION mConnect(OPT rsServer AS ASCIIZ, OPT BYVAL PortNumber AS LONG, OPT rsModChars AS ASCIIZ) EXPORT AS LONG
                  IF gConnect THEN BEEP: EXIT FUNCTION
                  IF gBusy    THEN BEEP:EXIT FUNCTION
                  gBusy = 1
                  LOCAL result AS LONG
                  result = slConnect(BYVAL rsServer, BYVAL PortNumber, BYVAL rsModChars)
                  IF result = 0 THEN gConnect = 1
                  gBusy = 0
                END FUNCTION
                SUB mDisconnect EXPORT
                  IF gConnect = 0 THEN BEEP:EXIT SUB
                  IF gBusy THEN EXIT SUB
                  gBusy = 1
                  slDisconnect
                  gBusy = 0
                  gOpen = 0
                  gConnect = 0
                END SUB
                SUB mSetProcessMods(BYREF rsModChars AS STRING) EXPORT
                    IF gBusy THEN EXIT SUB
                    gBusy = 1
                    slSetProcessMods rsModChars
                    gBusy = 0
                END SUB
                FUNCTION mOpen(OPT rsFileName AS ASCIIZ, OPT rsModChars AS ASCIIZ) EXPORT AS LONG
                  LOCAL result AS LONG
                  IF gConnect = 0 THEN
                    FUNCTION = 99
                    EXIT FUNCTION
                  END IF
                  IF gBusy THEN FUNCTION = 99:EXIT FUNCTION
                  IF gOpen THEN FUNCTION = 99:EXIT FUNCTION
                  gBusy = 1
                  result = slOpen(rsFileName, rsModChars)
                  IF result = 0 THEN gOpen = 1
                  FUNCTION = result
                  gBusy = 0
                END FUNCTION
                Last edited by Mike Doty; 21 Oct 2008, 05:28 PM.

                Comment


                  #28
                  Mike,

                  Rather than create a new DLL to call the original DLL, maybe you could simply create the "z" wrappers in an #INCLUDE file and include that file in the original "sqlitening.bas" source file. You could even have an equate in the sqlitening.bas file that will allow conditionally compiling the wrappers into a "VB" version of the DLL. Seems like a simple solution that would prevent you/us from having to deal with a separate DLL just for VB'ers only.
                  Paul Squires
                  FireFly Visual Designer (for PowerBASIC Windows 10+)
                  Version 3 now available.
                  http://www.planetsquires.com

                  Comment


                    #29
                    VB stores strings in Unicode and if you pass a string BYVAL it carries out a "fudge",
                    Actually its "Kludge" but thats a matter of semantics (UniCode vs Ascii)

                    Typically from VB I have wrappers to pass "ByVal", and my PB to take "ByVal" because I always forget that default for most languages are "ByRef" whether stated or otherwise.

                    Actually that gives me an idea (kinda like VB "Option Explicit") that maybe PB "#DEFINE ALL" could be expanded to force me to declare if "BYREF" or "BYVAL" in my functions if I am not thinking of it myself (although that is also putting me a little bit into "Your Momma does not live here", but could not hurt in situations such as this)

                    Being from a VB converted to PB and having to support most every language I can think of, I hide the confusion of the passing from the user (that has NO CLUE by they way) and call 1 function in my DLL and pass accordingly.)

                    In the words of MCM "First make it work.....THEN make it BETTER"
                    ComTria
                    Engineer's Motto: If it aint broke take it apart and fix it

                    "If at 1st you don't succeed... call it version 1.0"

                    "Half of Programming is coding"....."The other 90% is DEBUGGING"

                    "Document my code????" .... "WHYYY??? do you think they call it CODE? "

                    Comment


                      #30
                      Seems like a simple solution that would prevent you/us from having to deal with a separate DLL just for VB'ers only.
                      I liked the separate DLL because it offers an additional revenue opportunity with minimal investment.

                      But if that won't fly - and it may well not... "You mean it costs extra to use with the most popular Windows' development language ever?" - installing a few extra files probably "looks good."

                      (As Tom Peters pointed out years ago in his book In Search of Excellence, perception IS reality!).
                      Michael Mattias
                      Tal Systems (retired)
                      Port Washington WI USA
                      [email protected]
                      http://www.talsystems.com

                      Comment


                        #31
                        MCM, I see your point and would do the same if marketing a commercial product to the various market segments. However, in this case, the whole project is free and open source. The primary focus here is ease of code maintainability in the long term rather than profits.
                        Paul Squires
                        FireFly Visual Designer (for PowerBASIC Windows 10+)
                        Version 3 now available.
                        http://www.planetsquires.com

                        Comment


                          #32
                          >However, in this case, the whole project is free and open source

                          If you weren't Canadian, you'd be an Obama man.
                          Michael Mattias
                          Tal Systems (retired)
                          Port Washington WI USA
                          [email protected]
                          http://www.talsystems.com

                          Comment


                            #33
                            Originally posted by Michael Mattias View Post
                            >If you weren't Canadian, you'd be an Obama man.


                            I learned a long time ago to keep my opinions of politics and religion away from programming. Programming for me is fun and enjoyable - politics and religion is better left between me and a voting booth and a church pew.
                            Paul Squires
                            FireFly Visual Designer (for PowerBASIC Windows 10+)
                            Version 3 now available.
                            http://www.planetsquires.com

                            Comment


                              #34
                              If you weren't Canadian, you'd be an Obama man.
                              So would that make MCM a Bush man? And want to change the laws to allow a 3rd term?

                              I see Paul's point of it depends on the market, but in most cases a lil freedom code and maintainability can go a LONNNNNNNGGG way in profits later

                              Especially if you are the poor shlump handed down a project to make compatible and no source to go from, and user wants it to work (and refuses to change) and you can not afford to say no

                              Sure thats a lil extreme, but how many of us can afford to turn down a job just cause we have made enough to pick and choose our battles????

                              A "Real Man" would have a map of the battlefield to go by, and share with others iAnd if called to fight the battle again, or others, then willing to share intelligence (no matter how dated, may hold a key to the current situation)
                              Engineer's Motto: If it aint broke take it apart and fix it

                              "If at 1st you don't succeed... call it version 1.0"

                              "Half of Programming is coding"....."The other 90% is DEBUGGING"

                              "Document my code????" .... "WHYYY??? do you think they call it CODE? "

                              Comment


                                #35
                                I *WAS* a Bush supporter... until I discovered that while he may be compassionate, he sure as hell is no conservative.

                                (Mr. S: I see you had no comment on YOUR recent election. Not that a whole lot changed anyway. I think you must be getting close to election fatigue. What's that, three in the last four or five years?)
                                Last edited by Michael Mattias; 22 Oct 2008, 06:30 PM.
                                Michael Mattias
                                Tal Systems (retired)
                                Port Washington WI USA
                                [email protected]
                                http://www.talsystems.com

                                Comment


                                  #36
                                  I found my function where in PB I wanted ByVal String
                                  Maybe these lines will help you, I have had no problem calling the function from any of the languages Especially Vb6

                                  Code:
                                  FUNCTION DeviceSendToPort ALIAS "DeviceSendToPort" (BYVAL CommandOut AS STRING) EXPORT AS LONG
                                       LOCAL StringPointer AS ASCIIZ PTR     'Setup a pointer in case commandout is a pointer
                                       StringPointer = STRPTR(CommandOut)  'Get the location of the pointer
                                       SendText = @StringPointer
                                  Engineer's Motto: If it aint broke take it apart and fix it

                                  "If at 1st you don't succeed... call it version 1.0"

                                  "Half of Programming is coding"....."The other 90% is DEBUGGING"

                                  "Document my code????" .... "WHYYY??? do you think they call it CODE? "

                                  Comment


                                    #37
                                    Very nice! That may be the route to go!
                                    I am going to use another DLL that calls the 3rd party DLL so all my
                                    code is in PB, but this works with VB6.
                                    Never found a way to modify the caller in VB6, but there is probably a way to do that, too. I don't want to modify the open source code so we
                                    will wait to see what Fred thinks.
                                    Thank you.



                                    Code:
                                    Private Declare Function Test Lib "connect.dll" Alias "TEST" (ByVal s As String) As String
                                     
                                    Private Sub Command6_Click()
                                     
                                      Dim s1 As String
                                      Dim s2 As String
                                      s1 = String$(12000, "A") + String$(12000, "B")
                                      s2 = Test(s1)
                                      If s1 = s2 Then MsgBox "They match" Else MsgBox "They do not match"
                                     
                                    End Sub
                                     
                                     
                                    FUNCTION Test ALIAS "TEST" (BYVAL CommandOut AS STRING) EXPORT AS STRING
                                     
                                      LOCAL StringPointer AS ASCIIZ PTR 'Setup a pointer in case commandout is a pointer
                                      StringPointer = STRPTR(CommandOut) 'Get the location of the pointer
                                      FUNCTION = @StringPointer
                                     
                                    END FUNCTION
                                    Last edited by Mike Doty; 23 Oct 2008, 10:33 AM. Reason: Can't spell

                                    Comment


                                      #38
                                      Passing a byte array from VB6 didn't work.
                                      Just posted this as reference.

                                      Code:
                                      Private Sub Command6_Click()
                                        Dim x As Long
                                        
                                        Dim bsIP() As Byte
                                        Dim brsModChars() As Byte
                                        
                                        Dim result As Long
                                        Dim sIp    As String
                                        Dim PortNumber As Long
                                        Dim rsModChars As String
                                        
                                        sIp = "192.168.0.101"
                                        PortNumber = 0
                                        rsModChars = "E0"
                                        
                                        bsIP = StrConv(sIp, vbFromUnicode)
                                        brsModChars = StrConv(rsModChars, vbFromUnicode)
                                        
                                        'result = slConnect(ByVal StrPtr(sIp), ByVal PortNumber, ByVal StrPtr(rsModChars))
                                        'result = slConnect(ByVal StrPtr(bsIP), ByVal PortNumber, ByVal StrPtr(brsModChars))
                                        'result = slConnect(ByVal bsIP, ByVal PortNumber, ByVal brsModChars)
                                         'result = slConnect(bsIP, ByVal PortNumber, brsModChars)
                                            
                                            
                                         'For x = 1 To 10  'This works using another PB/DLL to accept as ASCIIZ and passes as BYVAL STRING
                                         ' result = mConnect(sIp, ByVal PortNumber, rsModChars)  'works using CALL to PB/DLL which CALLs BYVAL
                                         ' Me.Caption = result
                                         ' Sleep 500
                                         ' mDisconnect
                                         ' Sleep 500
                                         'Next
                                         'result = slConnect(ByVal sIp, ByVal PortNumber, ByVal rsModChars)   'original call which GPF's 3rd time
                                      
                                         
                                      End Sub

                                      Comment


                                        #39
                                        Mike
                                        Seems this thread is actually about nothing
                                        Downloaded the source and looked and yes he does use BYVAL STRING but Fred is obviously a very good programmer so reversed the definitions in my two prior simple programs, now they are
                                        Code:
                                        #COMPILE EXE
                                        #DIM ALL
                                        DECLARE SUB test LIB "test.dll" ALIAS "TEST" ( t AS ASCIIZ)
                                        
                                        FUNCTION PBMAIN () AS LONG
                                           LOCAL s AS ASCIIZ * 4
                                           s = "DEF"
                                           test s
                                        END FUNCTION
                                        
                                         'and for the DLL test
                                        
                                        #COMPILE DLL
                                        #DIM ALL
                                        SUB test(BYVAL t AS STRING) EXPORT
                                            ? t
                                        END SUB
                                        Still works, tested from VB6 no problem (declared as BYVAL STRING of course)
                                        Seems Fred knew the same trick I did but that it worked just as well with the reverse declares
                                        So doesn't seem like any converting intermediate DLLs are needed.
                                        The site does say documentation is a little but I guess he thought people would just use his declares without question.
                                        John

                                        Comment


                                          #40
                                          Not sure what you mean this thread is for nothing since it doesn't work?
                                          There are a set of headers for VB. Did you recompile SQLitening.DLL using ASCIIZ?

                                          The call to slConnect GPF's the 3rd time when calling from VB6 from within the environment.
                                          Code:
                                          FUNCTION slConnect ALIAS "slConnect" (OPTIONAL BYVAL rsServer AS STRING, _
                                                                                OPTIONAL BYVAL rlPort AS LONG, _
                                                                                OPTIONAL BYVAL rsModChars AS STRING) EXPORT AS LONG
                                          Last edited by Mike Doty; 23 Oct 2008, 12:08 PM.

                                          Comment

                                          Working...
                                          X
                                          😀
                                          🥰
                                          🤢
                                          😎
                                          😡
                                          👍
                                          👎