If PROMPT calsue is used in report
REPORT FORM xxx to PRINT PROMPT
User can select printer where report is printed.
How to get this printer name for logging?
https://support.microsoft.com/en-us/help/162798/how-to-use-the-set-printer-to-name-command-to-print-to-a-specified-printer-in-visual-foxpro
Show hot to use GetPrinter() for this. This requires removing PROMPT clause from REPORT
How to get printer where report was printed using PROMPT clause:
REPORT FORM xxx TO PRINT PROMPT
If this possbible, maybe thereis some sys() function or somethis other or is it possible to get printer name during report print ?
Or should this command re-factored not to use PROMPT clause like:
cPrinter = getprinter()
set printer to name (cPrinter)
REPORT FORM xxx TO PRINT
insert into logfile (PrinterUsedForPrinting) values (cPrinter)
I would suggest using your solution of calling GETPRINTER prior to running the report (without the PROMPT clause). In my long experience using FoxPro/VFP I don't think I've come across a way to determine the printer via REPORT FORM...PROMPT.
Here's an example wrapper function that you may find useful. I typically call "PickPrinter" prior to running a report. If PickPrinter returns an empty string, I abort the report run.
FUNCTION PickPrinter
IF APRINTERS(a_printers) < 1
MESSAGEBOX("No printers defined.")
RETURN ""
ELSE
lcPrnChoice = ""
lcPrnChoice = GETPRINTER()
IF EMPTY(lcPrnChoice)
RETURN ""
ELSE
*** Include quotes around the printer name
*** in case there are spaces in the name
lcPrnChoice = "NAME [" + lcPrnChoice + "]"
SET PRINTER TO &lcPrnChoice
RETURN lcPrnChoice
ENDIF
ENDIF
ENDFUNC
Related
I want the Information Message to show two lines of text.
Can this be done using one message class statement. Ex.
MESSAGE i001(z56_myclass) WITH lv_cust_id.
I tried putting the string of the short text with characters \n # \r \\n etc. but nothing worked. I don't know how to use long text editor for this particular requirement. Any help would be great.
You can't control the message carriage return in MESSAGE statement.
You can try instead with the following information popup
call function 'POPUP_TO_INFORM'
exporting
titel = 'Information'
txt1 = 'Registration successful'
txt2 = 'Customer Id is 0000001234'.
You have 4 text rows at your disposal (from txt1 to txt4).
In my Jenkins step I have windows batch command which runs a java jar file (java -Dfile.encoding=UTF-8 -jar C:\Test1\Test.jar C:\Test\test.log) and output of which is a String value (verified Jenkins console the string is getting printed) . How will I use this string content and insert in the editable email content body so I can send this content as an email . I wouldn't want the whole Jenkins console in the email only this String. I would assume the string has to be set as an environment variable after the script runs . Not sure how exactly I can use EnvInjPlugin for my scenario if at all it can be.
Try to use pre-send script.
For example You have in log the string like: "this random integer should be in email content: 3432805"
and want to add randomly generated integer to email content.
Set the Default Content with whatever you want but add some
value which will be replaced. For example:
This is the random int from build.log: TO_REPLACE
Then click "Advanced Settings" and add Pre-send Script:
String addThisStringToContent = "";
build.getLog(1000).each() { line ->
java.util.regex.Pattern p = java.util.regex.Pattern.compile("random\\sinteger.+\\:\\s(\\d+)");
java.util.regex.Matcher m = p.matcher(line);
if (m.find()) {
addThisStringToContent = m.group(1);
}
}
if (addThisStringToContent == "") {
logger.println("Proper string not found. Email content has not been updated.");
} else {
String contentToSet = ((javax.mail.Multipart)msg.getContent()).getBodyPart(0).getContent().toString().replace("TO_REPLACE", addThisStringToContent);
msg.setContent(contentToSet, "text/plain");
}
where:
build.getLog(1000) - retrieves the last 1000 lines of build output.
Pattern.compile("random\\sinteger.+\\:\\s(\\d+)") - regex to find the proper string
"text/plain" - Content Type
String contentToSet = ((javax.mail.Multipart)msg.getContent()).getBodyPart(0).getContent().toString().replace("TO_REPLACE", addThisStringToContent); - replaces the string TO_REPLACE with your value
Hope it will help you.
Unfortunately I have not enough reputation to comment Alex' great answer, so I write a new answer. The call
msg.setContent(contentToSet, "text/plain")
has two disadvantages:
Special characters are garbled
An attachment gets lost
So I use the following call to set the modified text
((javax.mail.Multipart)msg.getContent()).getBodyPart(0).setContent(contentToSet, "text/plain;charset=UTF-8")
I would like to print directly to an attached label printer without showing the print dialog.
I have searched to see if such a thing is possible but it seems it is not. So, I thought I would ask here in case someone knows a way to do it.
You have to save the Printer SetupString. Then the next time you go to print use that SetupString to initialize the PrinterSetup object. See actual code copied from working project below:
'Now print the mail barcode
dim ps as PrinterSetup
dim page as Graphics
ps = LabelPrinter //See below
if ps<>nil then
page = OpenPrinter(ps)
if page<>nil then
//send stuff to the printer here
Public Function LabelPrinter() as PrinterSetup
if gLabelSetup<>"" then //gLabelSetup is saved in preferences
dim ps as new PrinterSetup
ps.SetupString = gLabelSetup
return ps
else
return nil
end if
End Function
stdin.readByteSync has recently been added to Dart.
Using stdin.readByteSync for data entry, I am attempting to allow a default value and if an entry is made by the operator, to clear the default value. If no entry is made and just enter is pressed, then the default is used.
What appears to be happening however is that no terminal output is sent to the terminal until a newline character is entered. Therefore when I do a print() or a stdout.write(), it is delayed until newline is entered.
Therefore, when operator enters first character to override default, the default is not cleared. IE. The default is "abc", data entered is "xx", however "xxc" is showing on screen after entry of "xx". The "problem" appears to be that no "writes" to the terminal are sent until newline is entered.
While I can find an alternative way of doing this, I would like to know if this is the way readByteSync should or must work. If so, I’ll find an alternative way of doing what I want.
// Example program //
import 'dart:io';
void main () {
int iInput;
List<int> lCharCodes = [];
print(""); print("");
String sDefault = "abc";
stdout.write ("Enter data : $sDefault\b\b\b");
while (iInput != 10) { // wait for newline
iInput = stdin.readByteSync();
if (iInput == 8 && lCharCodes.length > 0) { // bs
lCharCodes.removeLast();
} else if (iInput > 31) { // ascii printable char
lCharCodes.add(iInput);
if (lCharCodes.length == 1)
stdout.write (" \b\b\b\b chars cleared"); // clear line
print ("\nlCharCodes length = ${lCharCodes.length}");
}
}
print ("\nData entered = ${new String.fromCharCodes(lCharCodes).trim()}");
}
Results on Command screen are :
c:\Users\Brian\dart-dev1\test\bin>dart testsync001.dart
Enter data : xxc
chars cleared
lCharCodes length = 1
lCharCodes length = 2
Data entered = xx
c:\Users\Brian\dart-dev1\test\bin>
I recently added stdin.readByteSync and readLineSync, to easier create small scrips reading the stdin. However, two things are still missing, for this to be feature-complete.
1) Line mode vs Raw mode. This is basically what you are asking for, a way to get a char as soon as it's printed.
2) Echo on/off. This mode is useful for e.g. typing in passwords, so you can disable the default echo of the characters.
I hope to be able to implement and land these features rather soon.
You can star this bug to track the development of it!
This is common behavior for consoles. Try to flush the output with stdout.flush().
Edit: my mistake. I looked at a very old revision (dartlang-test). The current API does not provide any means to flush stdout. Feel free to file a bug.
I want to print to a network printer from active reports but it always prints to default printer without throwing error.
Once I try to print with the .net printdocument library it print to specified printer.
I don't know why it is printing to default printer when using activereports.
Set the PrinterName property of the Printer object. Something like the following:
viewer.Document.Printer.PrinterName = "TheNetworkPrinterName";
viewer.Print();
The value of the PrinterName property should be the exact name from windows. To get a list of the valid printer names on a given system you can enumerate the list of printers using PrinterSettings.InstalledPrinters. An example of enumerating the available printers is in the MSDN documentation here.
If you try something and find it doesn't work give us more detailed information and we'll try to help you.
Change printer in end user designer.
Grapecityteam answer:
For a SectionReport, you could inject a Script to change the default printer when the report is loaded, in the LayoutChanged event of the Designer as given below:
private void OnLayoutChanged(object sender, LayoutChangedArgs e)
{
if (e.Type == LayoutChangeType.ReportLoad || e.Type == LayoutChangeType.ReportClear)
{
reportToolbox.Reorder(reportDesigner);
reportToolbox.EnsureCategories();
reportToolbox.Refresh();
RefreshExportEnabled();
CreateReportExplorer();
splitContainerMiddle.Panel2Collapsed = reportDesigner.ReportType == DesignerReportType.Section;
if (reportDesigner.ReportType == DesignerReportType.Section)
{
string script = string.Empty;
script += "public void ActiveReport_ReportStart()";
script += "{";
script += "rpt.Document.Printer.PrinterSettings.PrinterName = System.Drawing.Printing.PrinterSettings.InstalledPrinters[3];";
script += "}";
(reportDesigner.Report as SectionReport).ScriptLanguage = "C#";
(reportDesigner.Report as SectionReport).Script = script;
}
}
thanks to Grapecity Sales and Support