Progress 4GL report with centered header - openedge

How can I create a report with a centered header? In the header I would like to put a variable too.

In the plain old 4GL you can specify the left edge of a field in a frame using AT or the right edge with TO.
There is no attribute that centers a field within a frame.
You end up coding something similar to this:
define variable middle as character no-undo format "x(40)".
middle = "some text".
display
"left" at 1 middle at 20 "right" to 80 skip
with frame hdrFrame1 with no-labels.
pause.
middle = fill( " ", integer( 20 - ( length( middle ) / 2 ))) + middle.
display
"left" at 1 middle at 20 "right" to 80 skip
with frame hdrFrame2 no-labels.
(assumes a width of 80 chars and a "middle" field 40 chars wide...)
If you are using a fancy report generator or creating HTML then those tools have their own solutions.

Related

How to make the strip text in 1 row?

a part of my facet-wrap command structure contains this:
facet_wrap(scales= "free",day~type~cellline)
and the strips I got spread in 3 lines and make up a lot of space so I want them just in 1 line. (DAY1 K562 Parent)
How can I do that?

Dynamic Rstudio Code Snippet

I tend to use a lot of line breaks in my code like the following:
# Data =========================================================================
Where the entire comment is always 80 characters long (including the hashtag). What I would like to do is write a code snippet for Rstudio that will insert the hashtag, then a space, then allow the user to type out a series of words, then insert another space, and finally fill in a bunch of "=" until the 80 character limit is reached.
I'm not familiar with how snippets work at all so I'm not sure how difficult this is.
I have this much:
snippet lb
# ${1:name}
but I have no idea how to add a dynamic number of "=" signs. Also, lb = linebreak.
You can't do this with snippets, unfortunately; a snippet is a text template that contains fixed text with slots for user-inserted text.
There is a command built into RStudio to do something very similar, however; from the Code menu, choose Insert Section (or Ctrl+Shift+R). This will do exactly what you're describing, with two small differences:
The line will extend to 5 characters before the print margin (you can adjust the print margin in Tools -> Global Options -> Code.
The line is composed of - rather than = characters.
One advantage to sections marked in this way is that you can use them to fold and navigate inside the file (look at the editor status bar after adding one).
You can use the rstudioapi (which can return column position) inside the snippet to get something like what you want.
Below is a snippet I use called endhead. I use it by commenting my header title and then applying the snippet, eg:
# Section name endhead
which results in:
# Section name -----------------------------------------------------------------
snippet endhead
`r paste0(rep.int("-", 88 - rstudioapi::primary_selection(rstudioapi::getActiveDocumentContext())$range$start[2]), collapse = "")`
You can write a snippet to manipulate text (somewhat). I wrote the snippet below to do something similar to what you want to do. I'm still ironing out the issues (just asked this question).
snippet comm
`r paste0(
"#######################################><###################\n## ",
date(),
" -------------------------------\n## ",
eval(
paste0(
gsub(
".{1,51}\\s?\\K\\b",
"\n## ",
gsub("\\.", " ", paste0(text)),
perl = T
)
)
),
"###################################><###################\n"
)`
I think if you write an R code snippet using an anonymous function that accepts text input via $$, counts the nchar in the text, calculates the number of -'s needed at the end, and then uses eval(paste0()) to insert the comment you should be able to make it work. I'll post a comment or answer here if I figure it out. Please do the same on my question if you get it to work. Thanks. (P.S. Go Badgers!)
Inspired by nick's answer above I designed two snippets that allow the user to choose what level section to insert.
The first will fill-in the rest of the line with #, =, or -.
snippet end
`r strrep(ifelse(substr("$$", 1, 1) %in% c("-", "="), substr("$$", 1, 1), "#"), 84 - rstudioapi::primary_selection(rstudioapi::getActiveDocumentContext())$range$start[2])`
Just specify the character you want to use after end (will default to # if nothing or any other character is given). For example:
## Level 1 Header end<shift+tab>
## Level 2 Header end=<shift+tab>
## Level 3 Header end-<shift+tab>
end<shift+tab>
end=<shift+tab>
end-<shift+tab>
Produces the following lines:
## Level 1 Header ##############################################################
## Level 2 Header =============================================================
## Level 3 Header -------------------------------------------------------------
################################################################################
===============================================================================
-------------------------------------------------------------------------------
Similarly to what Josh was suggesting, the following snippet uses th $$ notation to pass the text following the snippet as described here.
snippet !
`r paste("##", substr("$$", 4, nchar("$$")), strrep(substr("$$", 2, 2), 79-nchar("$$")))`
Again this allows user to select the section level (#, =, or -). The first character after !# should be the header level character you want followed by a space and the header text. For example:
!## Level 1 Header<shift+tab>
!#= Level 2 Header<shift+tab>
!#- Level 3 Header<shift+tab>
Produces the following lines:
## Level 1 Header ##############################################################
## Level 2 Header ==============================================================
## Level 3 Header --------------------------------------------------------------
I prefer the end snippet above because it is more robust and only allows the characters #, =, or - to be inserted where as ! will allow anything, but it is shorter and, I think, easier to understand than calls to the rstudioapi.
!loon<shift+tab>
## n ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo

Having issue with fixed length data while displaying into front end

I am using MultiLineLabel component to display fixed length data in to front end,
But it has issue while displaying the data
when data line contains multiple spaces in between e.g.
1234232 44343 4343343
11111111111144343 4343343
Here the first line getting truncated
1234232 44343 4343343
11111111111144343 4343343
as i saw this component its using <p></p>
to display data and <P> has property it will truncate the spaces on display.
Can somebody assist me how can display my fixed length data on front end ?
There is nothing to do with the <p>. This is a common property of HTML - multiple spaces are collapsed into one.
You can pre-process the String you pass to MultiLineLabel with: Strings.replace(original, " ", " ");

abcpdf7 vb6 is letter wrapping, rather than word wrapping

I am working on some legacy code and system, and trying to get auto -resizing of text working.
however, despite the code working really well. This also wraps actual single words into two words.
for example QUALITY
becomes
Has anybody any idea how to keep the word wrapping, but remove the letter wrapping.
thanks
the code:
truncated = 1
fontSize = 127
thewords = Request("words") ' try QUALITY
do while Cint(truncated) = 1
set theDoc = Server.CreateObject("ABCpdf7.Doc")
fontSize = fontSize - 2
if fontSize <= 0 Then
exit do
end if
theDoc.Rect.Width = 273
theDoc.Rect.Height = 202
theDoc.Color.Alpha = 0
theDoc.FillRect()
theDoc.Color.Alpha = 255
theDoc.FrameRect()
theFont1 = "C:\inetpub\wwwroot\fonts\fonts\Helvetica.ttf"
theDoc.Font = theDoc.EmbedFont(theFont1, Latin, False, False, True)
theDoc.Fontsize = fontsize
theDoc.VPos = 0.5
theDoc.color = "75 68 67 90"
oText = theDoc.AddTEXT(thewords)
truncated = theDoc.GetInfo(oText, "Truncated")
'Response.Write(truncated & "<br>")
Loop
Data = theDoc.Rendering.GetData("testing.png")
Response.ContentType = "image/png"
Response.BinaryWrite Data
I know this is old code, and even an old version but this is what the system runs. If anyone has a clue then it would be much appreciated.
thanks
abcPDF will only letter wrap if:
wrapping is on
There is not enough horizontal space to fit one of the words being set
There is vertical room for another line in the active rect
These conditions therefore amount to there being plenty of vertical room but not enough horizontal room for some particularly long word. So a heuristic for finding the correct font size would be to test horizontally first, using only the longest word from your string, in a temporary rect that shrinks to one more than the font size as you reduce font size; then, once you have the right font size to avoid letter wrapping, go back to testing with the original rect and full string, continuing to decrease font size until truncation completely disappears.
This will get much hairier if what you're trying to set is actually HTML with variant fonts or sizes; but for plain text in a single font and style, it should be ok.

Crystal Reports Hiding Columns

I have a crystal report with several columns.i need to hide a column and remove the blank space based on a condition.currently what i have done is.i have dragged and dropped the fields inside TextObject and tick the "Suppress Embedded Blank Field Lines" and "Can Grow".it'll hide the detail field and also remove the blank space but the issue is header is still visible.
condition to hide a column is if the field data is null or empty
Try creating a formula for your conditionally displaying column heading. Something like:
SomeFieldLabel:
If DistinctCount({#SomeField}) > 0 Then "The Column Label"
or
If Not IsNull({#SomeField}) And {#SomeField} <> "" Then "The Column Label"
Then create a text object with {#SomeFieldLabel} and all your other labels, and select Suppress Embedded Blank Field Lines.
You may need to experiment to find the right condition – one which evaluates to True whenever the field is present in your detail records, and False the rest of the time.

Resources