Announcement

Collapse
No announcement yet.

Large Strings compare to arrays

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

  • Large Strings compare to arrays

    I need to share data of 50 KB to 100 KB between my powerbasic DLL and a vb.net front end. I have not been able to get the two progams to share arrays. (At least,, not yet !)

    I was thinking of using a work around by creating a string that contains all the data seperated by some delimiter, and then sharing it with the vb.net application.

    Will this cause substantial detoriation in performance ? Is this a practical idea ? All advice will be helpful.

    Thanks!

  • #2
    Other than building the strings - and breaking them apart again - there is no particular performance hit involved. But for that you have the JOIN$ function, which can do it faster than anyone can code it.

    Size of passed data is immaterial, always.. since all that is actually "passed" is a 32-bit address.
    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      Originally posted by Sudarshan Sukhani View Post
      Will this cause substantial detoriation in performance ? !
      My two bob's worth - try it, and if you don't like the results, post the code here. There are some brilliant coders watching this forum who will contribute. Which is not to say that your are not a brilliant coder yourself!

      Comment


      • #4
        If you know the exact format of your vb.net array, you might even be able to match it with a PB absolute array overlapping your string, and wouldn't even need the delimiters and associated handling code. It's very efficient and high performance:
        Code:
        #COMPILE EXE
        #DIM ALL
        %STRINGsIZE = 100000
        %ARRAYsIZE  = %STRINGsIZE \ 50 - 1
        
        FUNCTION PBMAIN () AS LONG
        
            LOCAL ii AS LONG
            LOCAL fixString100 AS STRING * %STRINGsIZE
            LOCAL dynString100 AS STRING
            dynString100 = REPEAT$(2000, SPACE$(49) & $NUL)  'effectively you could now have ASCIIZ elements ready for an array,
                                                             'or create the string in any other format you need.
            DIM fArr50(%ARRAYsIZE) AS STRING * 50 AT VARPTR(fixString100) 'absolute array overlaps string
            DIM dArr50(%ARRAYsIZE) AS STRING * 50 AT STRPTR(dynString100) '             "           "
            
            FOR ii = 1 TO 20       'can be as large as %ARRAYsIZE
               fArr50(ii) = " "    'make spaces instead of nulls
               MID$(fArr50(ii), ii AND 31) = "A little data"
               MID$(dArr50(ii), ii AND 31) = "Some other data"
               ? fArr50(ii) & $CRLF & dArr50(ii)
            NEXT
            
        END FUNCTION

        Comment


        • #5
          Thanks for your suggestions. I will try some alternatives and report back on what happened. (I will need to work with my vb.net programmer!).

          Comment


          • #6
            I don't know ".NET" but if it uses safearrays the VB code provided with the compiler in the samples folders may be usable for your purposes.
            Michael Mattias
            Tal Systems (retired)
            Port Washington WI USA
            [email protected]
            http://www.talsystems.com

            Comment


            • #7
              Dot Net arrays are different from VB 6

              Michael,

              Unfortunately, NET arrays are different from VB 6. I have been using the safearrays examples with vb 6 for past few years. But these examples do not work with VB.NET.

              Comment

              Working...
              X