Click to See Complete Forum and Search --> : Split function work-around in SQABasic
GregNolle
Jul 14th, 2000, 07:58 AM
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.
The Split Function:
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
GregNolle
Jul 14th, 2000, 01:54 PM
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.
vbBinaryCompare is a constant of 0. vbCompareMethod is just an enumeration (enum) consisting of several constants.
GregNolle
Jul 17th, 2000, 08:16 AM
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:
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?
SachinKN
Jan 31st, 2006, 06:41 AM
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
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.