Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing changed records

Status
Not open for further replies.

pcollins1

Technical User
Jun 19, 2002
72
US
Hello,
Using VFP 6.0.I have some code to run through some files and make some changes to data for conversion. I would like to print the fields of the records I am changing. I can not figure our how to make it print. I need the code to print the records I have touched. Currently just get a blank page.

*******************
Close Data


Select 1
use c:\dir\table1.dbf shared in A

select 2
use c:\dir\table2.dbf shared IN B

select 1
use c:\dir\table1 .dbf shared in A
Select 2
use c:\dir\table2.dbf shared in B
index on alltrim(upper(table2.title)) to test
go top
Do while ! eof()
str_Title = alltrim(upper(table1.Old_title))
Select 2
seek str_Title
IF FOUND()
replace table2.Title with alltrim(upper(table1.new_title))
ENDIF
SELECT 1
SKIP
ENDDO


Select 2
index on alltrim(upper(table2.title)) to test2
go top
Do while .not. eof()
replace title with "" for title = "DELETE"
ENDDO

Select 3
Use c:\dir\table3.dbf shared in C
index on mainphone to test3
Do while not eof()
replace mainphone with "" for mainphone = "( ) - "
ENDDO

Select 3
Use c:\dir\table3.dbf shared in C
index on faxnum to test4
Do while not eof()
replace faxnum with "" for faxnum = "( ) - "
ENDDO


Select 3
Use c:\dir\table3.dbf shared in C
index on alltrim(pnum) + alltrim(gnum) to test4
go top
Select 4
use c:\dir\table4.dbf shared in D
index on alltrim(pnum) + alltrim(gnum) to test5

Do while ! eof()
str_PRid = alltrim(table4.pnum) + alltrim(table4.gnum)
Select 3
seek str_PRid
If Found()
If (table3.expdate) = {} .or. null .and. alltrim(table3.reason) = "V"
Crdate = alltrim(table4.updatedby)
replace table3.expdate with ctod(right(crdate,8))

set console off
set printer on
set device to printer
if prow() > 55
eject
prow() = 1
@prow(), col() + 12 say "PNUM"
@prow(), col() + 33 say "GNUM"
@prow(), col() + 53 say "REASON"
@prow(), col() + 73 say "EXPDATE"
@prow(), col() + 93 say "EXPDATE"
endif
prow() = prow() + 1
@prow(), col() + 12 say table3.pnum
@prow(), col() + 33 say table3.gnum
@prow(), col() + 53 say table4.reason
@prow(), col() + 73 say table3.expdate
else
If table3.expdate = {}
replace table3.expdate with ctod("12/31/2099")
Endif
Endif
Endif
Select 4
Skip
Enddo
set console off
set printer on
set device to printer
set printer to
 
First, let me point out a couple things. When you select a specific work area, as in issuing a "SELECT 1", USEing a table at that time USEs it in that work area. So adding "IN A" is redundant, since work area 1 and work area A are identical.
That said, it's always less confusing to use aliases rather than specific work areas. As in:
Code:
SELECT 0  &&... let VFP find the next available work area
use c:\dir\table1.dbf shared ALIAS table1
Now when you want to close it, you can just say
SELECT table1
USE

Or even:
USE IN table1

Not caring whether it is work area 1, 2, or whatever.

Anyway, for your stated issue, I'm way confused. But one issue I see is this line:
Code:
 If (table3.expdate) = {} .or. [COLOR=red]null[/color] .and. alltrim(table3.reason) = "V"
Since 'null' all by itself is never going to evaluate to anything but .NULL., which is neither .T. or .F., your statement is totally unpredictable. But chances are, since it isn't .T., it will default to .F. and go right past it.

You probably meant to say:
Code:
 If (table3.expdate = {} .or. [COLOR=red]table3.expdate = .null.)[/color] .and. alltrim(table3.reason) = "V"
or some such combination. Notice that the table field needs to be referenced in order to be compared with .null. .

Another issue is you turn printing on for every iteration of the loop, but you turn it off at the end. I'm guessing nothing inside the loop happens, but when you turn printing off at the end of the loop, a blank page gets ejected.
set console off
set printer on
set device to printer
set printer to

Now for the printing part, PROW() is a function to return the current position of the print head. You can't assign it a value or you will get an error. COL() returns the current SCREEN column. It doesn't really have anything to do with the printer.
You should use variables to replace those functions:
Code:
STORE 1 TO nRow
STORE 1 TO nCol

set console off
set printer on
set device to printer

Do while ! eof()
  str_PRid = alltrim(table4.pnum) + alltrim(table4.gnum)
   Select 3
    seek str_PRid
     If Found()
      If (table3.expdate = {} .or. table3.expdate = null ) ;
         .and. alltrim(table3.reason) = "V"
          Crdate = alltrim(table4.updatedby)
          replace table3.expdate with ctod(right(crdate,8))
         
          if nRow > 55
            eject
            nRow = 1
            @nRow, nCol + 12 say "PNUM"
            @nRow, nCol + 33 say "GNUM"
            @nRow, nCol + 53 say "REASON"
            @nRow, nCol + 73 say "EXPDATE"
            @nRow, nCol + 93 say "EXPDATE"
          endif
          nRow = nRow + 1
          @nRow, nCol + 12 say table3.pnum
          @nRow, nCol + 33 say table3.gnum
          @nRow, nCol + 53 say table4.reason
          @nRow, nCol + 73 say table3.expdate
         else
          If table3.expdate = {}
            replace table3.expdate with ctod("12/31/2099")  
          Endif  
      Endif
     Endif
     Select 4
     Skip
    Enddo  
[code]
You should probably set a breakpoint in the debugger and step through your code, check the values, make sure the SEEK works, and go from there.

  -Dave Summers-  
 [cheers]
Even more Fox stuff at:
[URL unfurl="true"]http://www.davesummers.net/foxprolinks.htm[/URL]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top