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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing from multiple IF functions 1

Status
Not open for further replies.

GDJP

Technical User
Oct 16, 2001
9
CA
I am trying to get three IF/ELSE results to print their results all on the same line of a report. The following is the code I am using which works to get the results printing in the right position on three separate lines of the report.

I have tried removing the "APPEND BLANK" commands which does not work. Can anyone please help me with the proper method to tie these togehter and have the results print on the same line?

code:

IF A->ronameok = .Y.
REPLACE reportline WITH 'RO IN INSUREDS NAME? YES'
ELSE
REPLACE reportline WITH 'RO IN INSUREDS NAME? NO '
END IF
APPEND BLANK
IF A->rosigned = .Y.
REPLACE reportline WITH SPACE(30)+' RO SIGNED? YES'
ELSE
REPLACE reportline WITH SPACE(30)+' RO SIGNED? NO '
ENDIF
APPEND BLANK
IF A->consmatch = .Y.
REPLACE reportline WITH SPACE(52)+' RO CONCNERS MATCH? YES'
ELSE
REPLACE reportline WITH SPACE(52)+' RO CONCERNS MATCH? NO '
ENDIF

End code

Thanks in advance

G
 
Check the default page width. REPLACE reportline WITH SPACE(52)+' RO CONCNERS MATCH? YES' leads me to think that your default line width is less than the 75 characters that this field requires.

If you have the line width set for less than this, the printer will automatically start a new line.


Hope this helps There's always a better way...
 
Hi

I am asuming that reportline is a field in a .dbf

If so, read on, if not then I am on the wrong track.

The code you have will add a new record when .T. after the first IF statement. Therefore, if all IF's are true, you will have 3 records that store the required data you want to print.

If you want to evaluate the IF's and store the line you want to print in the current record, you need to build the string after each IF statement.

e.g.
I am trying to get three IF/ELSE results to print their results all on the same line of a report. The following is the code I am using which works to get the results printing in the right position on three separate lines of the report.

I have tried removing the "APPEND BLANK" commands which does not work. Can anyone please help me with the proper method to tie these togehter and have the results print on the same line?

code:

myString = "" && just to show whats happening

IF A->ronameok = .Y.
myString = 'RO IN INSUREDS NAME? YES'
ELSE
myString = 'RO IN INSUREDS NAME? NO'
END IF

IF A->rosigned = .Y.
myString = myString + ' RO SIGNED? YES'
ELSE
myString = myString + ' RO SIGNED? NO'
ENDIF
IF A->consmatch = .Y.
myString = myString + ' RO CONCNERS MATCH? YES'
ELSE
myString = myString + ' RO CONCNERS MATCH? NO'
ENDIF

REPLACE reportline with myString

End code

There are shorter ways of cding this using the IIF() function, but the above example shows step by step waht's happening.

Hope that helps.
Ormsk
 
Thanks. I think I follow and will try the code changes you suggest.

G
 
It appears that you also want the characters to align their starting positions in col1, col31, and col53. Just a little more tweaking to Ormsk's code will get you what you want, I think:

code:

myString = "" && just to show whats happening

IF A->ronameok = .Y.
myString = 'RO IN INSUREDS NAME? YES'
ELSE
myString = 'RO IN INSUREDS NAME? NO'
END IF
myString = PADR(mystring,30," ")

IF A->rosigned = .Y.
myString = myString + ' RO SIGNED? YES'
ELSE
myString = myString + ' RO SIGNED? NO'
ENDIF
myString = PADR(myString,52," ")

IF A->consmatch = .Y.
myString = myString + ' RO CONCNERS MATCH? YES'
ELSE
myString = myString + ' RO CONCNERS MATCH? NO'
ENDIF

REPLACE reportline with myString

End code

Hope this helps.
1oldfoxman
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top