Announcement

Collapse
No announcement yet.

FUNCTION Test(pz() AS ASCIIZ PTR) AS LONG ???

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

  • Semen Matusovski
    replied
    Peter --
    As you know, it's not possible to declare Asciiz * n and String * n, because compiler directly uses length' value.
    If you want to win competion against simple
    Code:
        Dim Lof1 As Long, p1 As Long, p2 As Long
        Open "Test.Dat" For Binary As #1 Len = 16384
        Lof1 = Lof(1): Get$ #1, Lof(1), a$: Close #1
        p1 = 1
        Do
           If p1 > Lof1 Then Exit Do
           p2 = Instr(p1, a$, $CRLF): If p2 = 0 Then p2 = Lof1
           w$ = Mid$(a$, p1, p2 - p1)
           ' ... Processing ...  
           p1 = p2 + 2
        Loop
    I'm very doubt in success (sorry).
    If to replace Instr and Mid by inline assembler commands - beleive.

    Anyway, alone Line Input, if to open with big LEN, works very fast (see results of my benchmark or do it by yourself).
    I like also Patrice's approach.
    To read whole file is fast, but not very good solution for gigant files.

    ------------------

    Leave a comment:


  • Peter Stephensen
    Guest replied
    Semen --

    Your method works for fixed length asciiz's. I need it for variable length.

    I need it for the code i have posted to "Win32: Regular Expression replacement for LINE INPUT" at the source code - forum.
    There i would prefer : FUNCTION GetLines(BYVAL File AS STRING, pLine() AS ASCIIZ PTR) AS LONG

    Regards
    Peter

    ------------------

    Leave a comment:


  • Semen Matusovski
    replied
    Peter --
    don't know why, but know how to bypass
    Code:
    #Compile Exe
    #Register None
    #Dim All
    Function aa (pAr As Asciiz Ptr) As String
       ReDim Ar(0) As Asciiz * 50 At pAr
       Function = Ar(1) + " + "  + Ar(3) + " + "  + Ar(5)
       Ar(2) = "Qu-qu"
    End Function
    Function PbMain
       ReDim B(5) As Asciiz * 50
       B(1) = "Moscow"
       B(3) = "St.Peterburg"
       B(5) = "Wladiwostok"
       MsgBox aa(b(0))
       MsgBox b(2)
    End Function
    Such approach works even with strings' array, multi-dimensional arrays:
    Code:
    #Compile Exe
    #Register None
    #Dim All
    Function aa (pAr As String Ptr) As String
       ReDim Ar(0) As String At pAr
       Function = Ar(1) + " + "  + Ar(3) + " + "  + Ar(5)
       Ar(2) = "Qu-qu"
    End Function
    
    Sub xx (pAr As Double Ptr, m1 As Long, m2 As Long, n1 As Long, n2 As Long)
       ReDim Ar(m1 : m2, n1 : n2) As Double At pAr
       MsgBox Str$(Ar(8, 35)), , "C(8,35)"
    End Sub
    
    Function PbMain
       ReDim B(5) As String
       B(1) = "Moscow"
       B(2) = "Kiew"
       B(3) = "St.Peterburg"
       B(4) = "Kaliningrad"
       B(5) = "Wladiwostok"
       MsgBox "Old location of b(2) was " + Hex$(StrPtr(b(2))), , b(2)
       MsgBox aa(b(0)), , "Function"
       MsgBox "New location of b(2) is " + Hex$(StrPtr(b(2))), , b(2)
       
       ' Multi-dimensional arrays   
       Dim i As Long, j As Long
       ReDim c(5 To 20, 7 : 40) As Double
       For i = 5 To 20: For j = 7 To 40: c(i, j) = 1000 * i + j: Next: Next
       xx c(5, 7), 5, 20, 7, 40
       
    End Function

    [This message has been edited by Semen Matusovski (edited April 22, 2000).]

    Leave a comment:


  • Peter Stephensen
    Guest started a topic FUNCTION Test(pz() AS ASCIIZ PTR) AS LONG ???

    FUNCTION Test(pz() AS ASCIIZ PTR) AS LONG ???

    Why can't i do this ?:

    FUNCTION Test(pz() AS ASCIIZ PTR) AS LONG
    ' ...
    END FUNCTION

    I can do this:
    FUNCTION Test(pz AS ASCIIZ PTR) AS LONG
    ' ...
    END FUNCTION

    Regards
    Peter
Working...
X