No announcement yet.

Large Strings compare to arrays

  • 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 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 application.

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


  • #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]


    • #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!


      • #4
        If you know the exact format of your 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:
        #COMPILE EXE
        #DIM ALL
        %STRINGsIZE = 100000
        %ARRAYsIZE  = %STRINGsIZE \ 50 - 1
            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)


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


          • #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]


            • #7
              Dot Net arrays are different from VB 6


              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.