Page Index Toggle Pages: [1] 2  Send Topic Send Topic Print Print
Hot Topic (More than 10 Replies) Check for missing Sequential numbers (Read 2063 times)
CapitalG
Full Member
Members
***
Offline



Posts: 143
Location: Phoenix, Arizona
Joined: Mar 4th, 2003
Check for missing Sequential numbers
Sep 16th, 2008 at 6:10pm
Print Post Print Post  
How would one (me) go about checking for missing numbers from a field that should be sequential?

Thank you.
  
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1350
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Check for missing Sequential numbers
Reply #1 - Sep 16th, 2008 at 11:31pm
Print Post Print Post  
I do this in a report to find missing check numbers in a checkbook application. But, you can set it up faster in a Mass Update. Here's how:

1. Sort your records in ascending order on the field you want to check.
2. Place this in the Global Code event of the Mass Update spec:
Code
Select All
stat sPrevNo as int
stat sCounter as int
stat sList as string 


3. Place this in any other Mass Update event:
Code
Select All
var vMissing as int

sCounter += 1

If sCounter > 1
{
	If @TN(Check No) > (sPrevNo + 1)
	{
		vMissing = (@TN(Check No) - sPrevNo) - 1
		sList += "There's " + vMissing + " number(s) missing, starting with " + @Str(sPrevNo + 1) + @NL()
	}
	Else If @TN(Check No) = sPrevNo
		sList += @Str(sPrevNo) + " is a duplicate!" + @NL()
}

If sCounter = @ResultSetTotal()
	WriteLn(sList)

// Create a delayed copy of Check No to compare with next record.
sPrevNo = @TN(Check No) 



You will need to replace "Check No" with the name of the element that contains the numbers you want to check. BTW, I enclosed Check No inside of @TN() because, in my app, that element is bound to a TEXT field. If the element you are checking is bound to a NUMBER field, you can remove the @TN()'s, but it wouldn't hurt to leave them in there in any case.

That's it. Just run the Mass Update, and if there are any duplicates or missing numbers the slate (WriteLn window) will display them when the update is finished.

Good luck!
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1350
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Check for missing Sequential numbers
Reply #2 - Sep 16th, 2008 at 11:36pm
Print Post Print Post  
Here's an example (the green portion) of what the slate might display if it finds errors:

21282 is a duplicate!
There's 1 number(s) missing, starting with 21284
 Where 21284 is the missing number.
There's 5 number(s) missing, starting with 21305  Where 21305 through 21309 are missing, 21304 and 21310 are present.
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
CapitalG
Full Member
Members
***
Offline



Posts: 143
Location: Phoenix, Arizona
Joined: Mar 4th, 2003
Re: Check for missing Sequential numbers
Reply #3 - Sep 17th, 2008 at 2:16pm
Print Post Print Post  
Thank you.   It was just what I needed.  Worked perfectly.

  
Back to top
 
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Check for missing Sequential numbers
Reply #4 - Sep 17th, 2008 at 7:18pm
Print Post Print Post  
This is marvelous Carl, thanks for posting this.
  

**
Captain Infinity
Back to top
IP Logged
 
Amor
Full Member
Members
***
Offline


No personal text

Posts: 366
Location: Germany
Joined: Feb 7th, 2004
Re: Check for missing Sequential numbers
Reply #5 - Sep 17th, 2008 at 7:30pm
Print Post Print Post  
Carl This is absolutly  marvelous , thanks.

I want the same Techník to determine whether  Form A involves the same number in the form B or NOT!
How kan i do That?

Thanks.
  

Dr. med. Amor Belhareth&&Medizin Labor &&Germany
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1350
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Check for missing Sequential numbers
Reply #6 - Sep 18th, 2008 at 3:14am
Print Post Print Post  
CapitalG wrote on Sep 17th, 2008 at 2:16pm:
Thank you.   It was just what I needed.  Worked perfectly.


Infinity wrote on Sep 17th, 2008 at 7:18pm:
This is marvelous Carl, thanks for posting this.


You're welcome.
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1350
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Check for missing Sequential numbers
Reply #7 - Sep 18th, 2008 at 3:17am
Print Post Print Post  
Quote:
Carl This is absolutly  marvelous , thanks.

I want the same Techník to determine whether  Form A involves the same number in the form B or NOT!
How kan i do That?

Thanks.


I'm not sure I understand you. Do you mean that you just want to know if two databases contain the same numbers?
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
Amor
Full Member
Members
***
Offline


No personal text

Posts: 366
Location: Germany
Joined: Feb 7th, 2004
Re: Check for missing Sequential numbers
Reply #8 - Sep 18th, 2008 at 3:27pm
Print Post Print Post  
Yes Carl!
  

Dr. med. Amor Belhareth&&Medizin Labor &&Germany
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1350
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Check for missing Sequential numbers
Reply #9 - Sep 22nd, 2008 at 4:16am
Print Post Print Post  
Try this Mass Update. Of course, you will need to modify the parameters in @XListValues as required to fit your needs.

Make sure you run it on a single record, by using "Max 1" or "Min 1" in the search spec.

Code
Select All
var vA as string
var vB as string

vA = @XListValues(@Fn, "Checkbook!Check No")
vB = @XListValues(@Fn, "Checkbook Transactions!Check No")

WriteLn(@DifferenceStringArray(vA, vB)) 



This code will produce a list of values that appear in one of the databases, but not the other. Here's an example of what it might show in the slate window:
20776;20777;20778;20779;21229

Otherwise, if there are no differences, the slate will be blank.
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
Amor
Full Member
Members
***
Offline


No personal text

Posts: 366
Location: Germany
Joined: Feb 7th, 2004
Re: Check for missing Sequential numbers
Reply #10 - Sep 23rd, 2008 at 6:37pm
Print Post Print Post  
Hello Carl!
Thank you for your example: it works perfectly.
Using a button  the slate window appears very, very little time and close.
Have you an idea how  to stop that.?

Hier is the Code in the button:

var vRet as String
var vMass as String
var vStr as Int

vRet   = "Min 1"
vMass  = "Missing Chemie LabNr"

vStr = @SpecCommand(SPEC_OPERATION_LOAD, SPEC_TYPE_RETRIEVE, vRet)
vStr = @SpecCommand(SPEC_OPERATION_RUN, SPEC_TYPE_RETRIEVE, "")
vStr = @SpecCommand(SPEC_OPERATION_LOAD, SPEC_TYPE_MASS_UPDATE, vMass)
vStr = @SpecCommand(SPEC_OPERATION_RUN, SPEC_TYPE_MASS_UPDATE, "")
  

Dr. med. Amor Belhareth&&Medizin Labor &&Germany
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1350
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Check for missing Sequential numbers
Reply #11 - Sep 24th, 2008 at 2:55am
Print Post Print Post  
Are you sure the slate is closing? Sometimes it will simply end up behind the main Sesame window. In any case, I think this may solve the problem:

Code
Select All
// Close and open the slate to make it display on top of the Sesame window.
CloseSlate()
OpenSlate() 

  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
Amor
Full Member
Members
***
Offline


No personal text

Posts: 366
Location: Germany
Joined: Feb 7th, 2004
Re: Check for missing Sequential numbers
Reply #12 - Sep 24th, 2008 at 3:34pm
Print Post Print Post  
Hello Carl!

I ´m sure the slate is closing and the OpenSlate() does not work for me.

Hier is the code in Massupdate:
var vA as string
var vB as string
var vBPath as String
var vDiff as String

vBPath = "C:\Labor\MDLCHEMIE.DB"


vA = @XListValues(@Fn, "Aufnahme!LabNr")
vB = @XListValues(vBPath, "Orders!LabNr")
vDiff = @DifferenceStringArray(vA, vB)
WriteLn(vDiff)
OpenSlate()
  

Dr. med. Amor Belhareth&&Medizin Labor &&Germany
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1350
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Check for missing Sequential numbers
Reply #13 - Sep 25th, 2008 at 2:17am
Print Post Print Post  
It won't hurt to use CloseSlate() if the it's already closed. But, if it's not actually closed, and simply behind another window, you need to close it and re-open it to make it come to the forefront. Just using OpenSlate() will not bring it to the front, if it were already open.

Otherwise, if it really is closing without you asking it to, maybe you should send it in to support to have them see what is happening.
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
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: Check for missing Sequential numbers
Reply #14 - Sep 25th, 2008 at 7:33pm
Print Post Print Post  
Hello Amor,

Why program your command button to run a Mass Update spec that does what the command button itself could do? You can simply program the command button to run the code that is in the Mass Update. Just program your command button as

Code
Select All
var vA as string
var vB as string
var vBPath as String
var vDiff as String

vBPath = "C:\Labor\MDLCHEMIE.DB"

vA = @XListValues(@Fn, "Aufnahme!LabNr")
vB = @XListValues(vBPath, "Orders!LabNr")
vDiff = @DifferenceStringArray(vA, vB)
WriteLn(vDiff)
 



Note: That code will give you the Numbers in Aufnahme that do not exist in Orders. If you also want the Numbers that exist in Orders but not in Aufnahme, Your code will be

Code
Select All
var vA as string
var vB as string
var vBPath as String
var vDiff as String

vBPath = "C:\Labor\MDLCHEMIE.DB"


vA = @XListValues(@Fn, "Aufnahme!LabNr")
vB = @XListValues(vBPath, "Orders!LabNr")
vDiff = @DifferenceStringArray(vA, vB)
Writeln("Numbers in Aufnahme that do not exist in Orders..."
WriteLn(vDiff)
Writeln("--------------")
vDiff = @DifferenceStringArray(vB, vA)
Writeln("Numbers in Orders that do not exist in Aufnahme..."
WriteLn(vDiff) 



-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send Topic Send Topic Print Print