I have a fairly long script that prints any one of about 17 reports. To save script space, I created a Print_it function that does the Preview/Print prompt and then runs the preview or print as requested.
The weird thing is that there are always two prompts before the preview is shown - but only one prompt when printing without a preview. HOWEVER, if I copy the exact code that is in the function and run it as part of the script, only one prompt is shown.
An example script is shown below. It should even work on your own system if you just change the report name to a valid name in your own app - see the line rname = "xxx". I will attach the same script in a text file where it will be easier to read and/or copy to your code editor.
FUNCTION print_it as C( rname as C )
print_type = ui_get_list( "PRINT TYPE", 1, "Preview First", "Direct to Printer" )
IF print_type = ""
EXIT FUNCTION
END IF
SELECT
CASE print_type = "Preview First"
report.preview( rname )
CASE print_type = "Direct to Printer"
report.print( rname, filter, order )
END SELECT
END FUNCTION
'Using the function, I always get 2 preview/print prompts.
rname = "CMR51_BONUS_Pool"
'REM out the next two lines to test it without the function.
print_it( rname )
END
'If I replace the function call with the following, there is only one prompt.
'NOTE: This is copied directly from the function except EXIT FUNCTION is now END.
print_type = ui_get_list( "PRINT TYPE", 1, "Preview First", "Direct to Printer" )
IF print_type = ""
END
END IF
SELECT
CASE print_type = "Preview First"
report.preview( rname )
CASE print_type = "Direct to Printer"
report.print( rname, filter, order )
END SELECT
END
The weird thing is that there are always two prompts before the preview is shown - but only one prompt when printing without a preview. HOWEVER, if I copy the exact code that is in the function and run it as part of the script, only one prompt is shown.
An example script is shown below. It should even work on your own system if you just change the report name to a valid name in your own app - see the line rname = "xxx". I will attach the same script in a text file where it will be easier to read and/or copy to your code editor.
FUNCTION print_it as C( rname as C )
print_type = ui_get_list( "PRINT TYPE", 1, "Preview First", "Direct to Printer" )
IF print_type = ""
EXIT FUNCTION
END IF
SELECT
CASE print_type = "Preview First"
report.preview( rname )
CASE print_type = "Direct to Printer"
report.print( rname, filter, order )
END SELECT
END FUNCTION
'Using the function, I always get 2 preview/print prompts.
rname = "CMR51_BONUS_Pool"
'REM out the next two lines to test it without the function.
print_it( rname )
END
'If I replace the function call with the following, there is only one prompt.
'NOTE: This is copied directly from the function except EXIT FUNCTION is now END.
print_type = ui_get_list( "PRINT TYPE", 1, "Preview First", "Direct to Printer" )
IF print_type = ""
END
END IF
SELECT
CASE print_type = "Preview First"
report.preview( rname )
CASE print_type = "Direct to Printer"
report.print( rname, filter, order )
END SELECT
END
Comment