Normal Topic Duplicate Info when displaying search results. (Read 11146 times)
NHUser
Full Member
***
Offline



Posts: 320
Location: Amherst, NH
Joined: Aug 2nd, 2010
Duplicate Info when displaying search results.
Apr 30th, 2020 at 2:51pm
Print Post Print Post  
I'm using the programming below to display the sales history from one of my files.  It works fine, except i get a duplicate of the first result.

For example - note below the first two lines are both from 01/19/10.


2226AA  Pc Price:29.7300  Date: 01/19/10 -- Quantity: 105
2226AA  Pc Price:29.7300  Date: 01/19/10 -- Quantity: 105
2226AA  Pc Price:  Date: 04/29/10 -- Quantity: 80
2226AA  Pc Price:  Date: 08/24/10 -- Quantity: 80
2226AA  Pc Price:  Date: 11/15/10 -- Quantity: 80
2226AA  Pc Price:  Date: 03/25/11 -- Quantity: 250

How do I eliminate this duplicate?

NHUser

Programming-----

var vDCNo as string
var vHandle as Int
var vloop as int
var VNoOfRecords as Int
var v1 as string
var v2 as string
var v3 as string
var vPartNo as string
var vname as string
var vStatus as string
var vQuantity as String
var vLine as string
var vTemp1 as int
var vStr as string
var vA as Int


#include "sbasic_include.sbas"


// View Shipment History


If @mode() = 1

{

     vDCNo = @left(DC#,4)
     
     
     vHandle=@xResultSetSearch(@FN,"Sales", SEARCH_MODE_AND,SEARCH_SYNTAX_QA, "!PartNo="+vDCNo+"..")

     XResultSetSort(vHandle,"Partno:-1;date1:-1")

     vLoop=vA

     
     If(vHandle>-1)
     {
     
           vNoOfRecords = @XResultSetTotal(vHandle)

           If vNoOfRecords>500 then vA=vNoOfRecords-500
     
           For vLoop= vA to vNoOfRecords
     
                 xResultSetCurrentPosition(vHandle,vLoop)
     
                 vPartNo = @xResultSetValue(vHandle,"PartNo")
                 vName = @xResultSetValue(vHandle,"Diaphragms")
                 vStatus = @xResultSetValue(vHandle,"Date1")
                 v2 = @right(vStatus,2)
                 v3 = @mid(vStatus,3,2)
                 v1 = @mid(vStatus,6,2)
                 vStatus = v1 + "/" + v2 + "/" + v3
                 vQuantity = @AsFormattedByLE(OverRun,0,(@xResultSetValue(vHandle,"PCS")))   


           // create the variable
                 
                 vLine=vline + vPartNo + "  Date: " + vStatus + " -- Quantity: " + vQuantity+ @Newline()
     
                 vTemp1=1
                 Next
     
                 xResultSetClose(vHandle)
     }
     
     
     if vTemp1<1
     {
           Writeln("NO PARTS ARE ON ORDER.")
     }
     else
     {
           vStr=@SortStringArray(vLine,0)
           Writeln(vStr)
     }

}
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: Duplicate Info when displaying search results.
Reply #1 - Apr 30th, 2020 at 4:16pm
Print Post Print Post  
Hi Paul,

You are setting vLoop equal to vA which has not been initialized so the first loop through it's 0. So you try to go to the 0th record, invalid number, so it stays on record 1. Then next loop through it goes to record 1. So you're on record 2 twice.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged