Thanks:  0
Likes:  0
Dislikes:  0

# Thread: Determine number of rows

1. ## Determine number of rows

Hi.

OpenSTA could count or determine the rows number of a query results?

example:

There´s any chance to determine the number of rows of that form?

2. ## Re: Determine number of rows

Yes, but you need to write a fairly complex subroutine to do it. I am very busy with a client for the next week or so. After that I can take my subroutine that not only counts them but puts them in an array, document it, and post it.

3. ## Re: Determine number of rows

Here is a copy of the subroutine. It will be a week or so before I can document it. Basically, you give it the left and right delimiters for each "colum" of data you want and tell it how many "rows" you want and it passes back an array of rows and columns, and tells you how many rows it was able to find.

Also is a copy of my global variables file which contains more than you need. Also, my version of OpenSTA has 256KB max variable size. you will need to change the char variables to be a length of 65535. Hope you can figure it out from this!

! Input: Buffer, NumColumns, SkipToStr, LAskipToStrOcc, LAnumCols, ColDelim[LAnumCols,2]
! Output rteArray[], NumRows
if (offset = -1) THEN
SET numRowsReturned = 0
RETURN
ENDIF
SET offset = offset + ~LENGTH(LAskipToStr)
SET LAbuffer = ~EXTRACT(offset, 262143, LAbuffer)
ENDDO
Do numRowsReturned = 1, numRowsWanted
DO j = 1, LAnumCols
set startString = colDelimStr[j,1]
set ENDString = colDelimStr[j,2]
set occurance = 1
CALL GetDelimitedStr2 ! [ LAbuffer, colDelimStr[j,1], colDelimStr[j,2], 1, resultStr ]
if ((resultStr = "") and (resultFound =0)) THEN
SET numRowsReturned = numRowsReturned - 1
RETURN
ENDIF
SET rteArray[numRowsReturned,j] = resultStr
ENDDO
!!wait 50
ENDDO
SET numRowsReturned = numRowsReturned - 1
RETURN
END SUBROUTINE </pre><hr />

<font class="small">Code:</font><hr /><pre> SUBROUTINE GetDelimitedStr2 ![ LABuffer, startString, ENDString, Occurance, resultStr ]
SET resultStr = ''
set resultFound = 0
DO i = 1, occurance
SET offset = ~LOCATE(startString, labuffer)
if (offset = -1) THEN
RETURN
ENDIF
SET offset = offset + ~LENGTH(startString)
SET labuffer = ~EXTRACT(offset, 262143, labuffer)
ENDDO
SET offset = ~LOCATE(ENDString, labuffer)
if (offset = -1) THEN
RETURN
ENDIF
SET resultStr = ~leftstr(offset, labuffer)
set resultFound = 1
RETURN
END SUBROUTINE </pre><hr />

<font class="small">Code:</font><hr /><pre>!/////////////////////////////////////////////////////////////////////////
!// file: global_variables.inc //
!// This file is distributed as part of OpenSTA - http://opensta.org/ //
!// It is included in all generated scripts and is intended to contain //
!// user defined variables and constants required at a global scope. //
!/////////////////////////////////////////////////////////////////////////

! Constants
constant hostname ="myhostname"
CONSTANT hostIP = "127.0.0.1"
CONSTANT USER_NAME = "asdf"
CONSTANT USER_PASS = "asdf"

! WARNING: Dont put script scoped variables in here. Define them in the
! Appropirate script

! Local Scoped Variables
! character*65534 tebv
! character*65534 Buffer
! character*65534 Temp_Buffer
! character*65534 LABuffer
! character*65534 resultstr

character*262143 tebv
character*262143 Buffer
character*262143 Temp_Buffer
character*262143 LABuffer
character*262143 resultstr

Character*512 rteArray [400,3], script ! Target array max 20 rows by 30 cols
Character*512 ColDelimStr[3,2], script ! 30 Cols each having a start and end delimiter
character*256 LAskipToStr ! ignore portion of buffer to the left of the
character*256 startString
character*256 endString
character*256 target
character*256 therest
CHARACTER*512 redirect
character*128 successString
character*100 clientName ! Used to pass the Client Name
character*100 tempChar ! Used in the GenerateUniqueSN Subroutine
CHARACTER*100 synchTokenStr

integer rtePtr
integer LAskipToStrOcc ! of the skipToStrOccurace'th occurance of skipToStr
integer LAnumCols
integer NumRows
integer NumRowsWanted
integer NumRowsReturned
integer loopcounter
integer i
integer j
integer k
integer offset
integer occurance
integer offset1
integer offset2
integer len
integer len1
integer len2
integer targetlen
integer resultindex (1-30)
integer waitforint
integer channelint
integer waitflag
integer debugflag
integer thinktime
integer failureaction
integer run_once_flag
integer timerInt
integer timeInt
integer resultFound

integer randInt100 (1-100), random
integer RandDelay (7-13), random

timer elapsedtime
character*262143 tebv1

!!!!!!!!!!!!!!!! Claimtrust Global Variables

</pre><hr />

Example use...

<font class="small">Code:</font><hr /><pre>set colDelimStr [1,1] = 'mediaItemId="'
set colDelimStr [1,2] = '"'
set colDelimStr [2,1] = 'path="'
set colDelimStr [2,2] = '"'

set LAnumCols = 2
set numRowsWanted = 2

! log numRowsReturned

set foundMediaId = 0
if (numRowsReturned &lt; 2) then
!log "Error, couldn't find at least 2 videos on grid ",mychapter," in ",sbbuffer
set myMediaItemId1 = rtearray[1,1]
set myMediaItemId2 = rtearray[1,1]
set myPath1 = rtearray[1,2]
set myPath2 = rtearray[1,2]
!exit
else
set myMediaItemId1 = rtearray[1,1]
set myMediaItemId2 = rtearray[2,1]
set myPath1 = rtearray[1,2]
set myPath2 = rtearray[2,2]
endif

! </pre><hr />

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.