Results 1 to 6 of 6

Thread: Split function work-around in SQABasic

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2000
    Location
    UK
    Posts
    13
    Dear all,
    I wonder if anyone could help me with this problem. I'm using Rational's SQA suite and its inbuilt SQABasic to create a robot script that reads data from a .csv file. Unfortunately, SQABasic does not come with the Split function that I am used to in VB so I am stumped as to how to solve this problem effectively. Unfortunately, I do not have access to VB whilst doing this job, so I can't use that with SQA suite. The only way I've managed it so far is to use a collection of loops to split it manually but it is a very time-consuming process when working with large .csv files. Has anyone got any ideas as to how to go about effectively reproducing the Split function?

    Thanks in advance,

    Greg.

  2. #2
    Guest
    The Split Function:

    Code:
    Function Split(ByVal sIn As String, Optional sDelim As String, Optional nLimit As Long = -1, Optional bCompare As VbCompareMethod = vbBinaryCompare) As Variant
        Dim sRead As String, sOut() As String, nC As Integer
        If sDelim = "" Then
            Split = sIn
        End If
        sRead = ReadUntil(sIn, sDelim, bCompare)
        Do
            ReDim Preserve sOut(nC)
            sOut(nC) = sRead
            nC = nC + 1
            If nLimit <> -1 And nC >= nLimit Then Exit Do
            sRead = ReadUntil(sIn, sDelim)
        Loop While sRead <> ""
        ReDim Preserve sOut(nC)
        sOut(nC) = sIn
        Split = sOut
    End Function

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2000
    Location
    UK
    Posts
    13
    Brilliant! Thank you so much, I can't thank you enough! I will try it first thing on Monday.

    However, one thing bothers me. Will the "VbCompareMethod = vbBinaryCompare" variable type work in SQABasic which does differ from VB in some ways?

    Thanks again,

    Greg.

  4. #4
    Guest
    vbBinaryCompare is a constant of 0. vbCompareMethod is just an enumeration (enum) consisting of several constants.

  5. #5

    Thread Starter
    New Member
    Join Date
    May 2000
    Location
    UK
    Posts
    13
    OK, I've tried it out but there are a few problems. It didn't like the compare method variable (and its type) but I just set it to 0. It also didn't like doing the -1 bit on nLimit so I set it to do it at the beginning of the function. Therefore I now have:

    Code:
    Function Split(ByVal sIn As String, sDelim As String, nLimit As Long) As Variant
      nLimit = nLimit - 1
      Dim sRead As String, sOut() As String, nC As Integer, bCompare As Variant
      bCompare = 0
      If sDelim = "" Then
        Split = sIn
      End If
      sRead = ReadUntil(sIn, sDelim, bCompare)
      Do
        ReDim Preserve sOut(nC)
        sOut(nC) = sRead
        nC = nC + 1
        If nLimit <> -1 And nC >= nLimit Then Exit Do
        sRead = ReadUntil(sIn, sDelim)
      Loop While sRead <> ""
      ReDim Preserve sOut(nC)
      sOut(nC) = sIn
      Split = sOut
    End Function
    However, I now get the following errors when compiling:

    - BYVAL is only supported in external functions argument 'sIn')
    - Variable ReadUntil undefined
    - Missing or incorrect subscripts for array sOut

    I don't know what the first or last ones mean but the second one obviously means that SQABasic doesn't support the ReadUntil function either. Any ideas?

  6. #6
    New Member
    Join Date
    Jan 2006
    Posts
    1

    Re: Split function work-around in SQABasic

    For split function I am getting following error after compilation

    "Invalid procedure definition" for the split function

    Also could you please help me in getting the function ReadUntil function.

    Thanks & Regards.
    Sachin

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width