What code will do this?

I have a TEMP-TABLE with 5 records in it.
Each record has 3 fields.
The records show like this when I run a FOR EACH on the table:

10/7/04 Bill N-12345
10/8/04 Mary N-54321
10/10/04 Ted N-65456
10/12/04 Mark N-55668
10/15/04 Sue N-54390


I want to create an editable browse screen that looks like this:

10/7/04 Bill N-12345
10/8/04 Mary N-54321
10/9/04 ____ _______
10/10/04 Ted N-65456
10/11/04 ____ _______
10/12/04 Mark N-55668
10/13/04 _____ ________
10/14/04 _____ ________
10/15/04 Sue N-54390

The code must FOR EACH thru the table and INSERT the missing days between the original FIRST record and the LAST record and CREATE records inbetween with blanks as shown.
I am in 83.b character environment.
bob
rbender@rosina.com
 

Stefan

Well-Known Member
Use a backup variable to store your last date. If current date minus backup date does not equal 1 then insert extra lines.
 
How about this

Code:
DEF TEMP-TABLE ttNames
	FIELD eDate AS DATE
	FIELD FirstName AS CHAR
	FIELD ID AS CHAR.
 
DEF BUFFER bttNames FOR ttNames.
 
CREATE ttNames. ASSIGN Edate = 10/07/04 FirstName = "Bill" ID = "N-12345".
CREATE ttNames. ASSIGN Edate = 10/08/04 FirstName = "Mary" ID = "N-54321".
CREATE ttNames. ASSIGN Edate = 10/10/04 FirstName = "Ted" ID = "N-65456".
CREATE ttNames. ASSIGN Edate = 10/12/04 FirstName = "Mark" ID =" N-55668".
CREATE ttNames. ASSIGN Edate = 10/15/04 FirstName = "Sue" ID = "N-54390".
 
DEF VAR LastDate AS DATE INIT ? NO-UNDO.
DEF VAR Step AS INT NO-UNDO.
 
FOR EACH ttNames BREAK BY ttNames.eDate:
	IF FIRST-OF(ttNames.eDate) AND ttNames.eDate - LastDate > 1
	THEN DO:
		DO Step = 1 TO eDate - LastDate - 1:
			CREATE bttNames.
			ASSIGN
				bttNames.eDate = LastDate + Step.
		END.
	END.
	LastDate = ttNames.eDate.
END.
 
FOR EACH ttNames BY eDate:
	DISPLAY ttNames.
END.
 
Top