1. centering display
- Posted by Senator in March
- 436 views
integer RM = 50 display("[c:50]", {"This text is centered"}) display("[c:RM]", {"This text is not centered"}) constant VC=graphcst:video_config() -- or RM = VC[VC_COLUMNS] display("[c:RM]", {"This text is not centered"})
This text is centered This text is not centered This text is not centered
Is there anyway to use a variable to pass a value to the the display center function?
2. Re: centering display
- Posted by euphoric (admin) in March
- 461 views
integer RM = 50 display("[c:50]", {"This text is centered"}) display("[c:RM]", {"This text is not centered"}) constant VC=graphcst:video_config() -- or RM = VC[VC_COLUMNS] display("[c:RM]", {"This text is not centered"})
Is there anyway to use a variable to pass a value to the the display center function?
Since it's a string anyway, you could use
display("[c:" & sprint(RM) & "]", {"This text is not centered"})
That's one way.
3. Re: centering display
- Posted by Senator in March
- 414 views
Since it's a string anyway, you could use
display("[c:" & sprint(RM) & "]", {"This text is not centered"})
That's one way.
Thanks euphoric, works like a charm.
4. Re: centering display
- Posted by petelomax in March
- 394 views
Since it's a string anyway, you could use
display("[c:" & sprint(RM) & "]", {"This text is not centered"})
That's one way.
Thanks euphoric, works like a charm.
Yeah, but doesn't that say This text is not centered when actually it is centered? scnr
On a slightly more serious note,
printf(1,">%6s<\n",{"four"}) -- produces "> four<" printf(1,">%-6s<\n",{"four"}) -- produces ">four <"
Does anyone any have any suggestion/preference for a format string that would produce "> four <"?
(Obviously, there isn't one, but if I were to implement it what would feel right as the third alternative to "%6s" and "%-6s"? "%|6s"? "%=6s"?)
5. Re: centering display
- Posted by ghaberek (admin) in March
- 384 views
On a slightly more serious note,
printf(1,">%6s<\n",{"four"}) -- produces "> four<" printf(1,">%-6s<\n",{"four"}) -- produces ">four <"
Does anyone any have any suggestion/preference for a format string that would produce "> four <"?
(Obviously, there isn't one, but if I were to implement it what would feel right as the third alternative to "%6s" and "%-6s"? "%|6s"? "%=6s"?)
I'd recommend "%^6s" or "%+6s".
-Greg
6. Re: centering display
- Posted by petelomax in March
- 411 views
I'd recommend "%^6s" or "%+6s".
Thanks, unfortunately + is already in use on numbers to show a plus sign on positive values, so using that would mean you cannot centre numbers and/or break existing code.
Is there any preference for splitting say 7 spaces as 4:3 or 3:4?
7. Re: centering display
- Posted by sash in March
- 360 views
How about "%<6s" for left, "%>6s" for right, and "%|6s" for middle (centre) justification? The'|' suggests dividing space in middle to me.
3/4 or 4/3 - why not just toss a coin?
Sasha
8. Re: centering display
- Posted by Senator in March
- 327 views
Quick and Dirty:
-- add this at the end of std/console.e public sequence CS --Center text string public function CenterString(integer RM) --returns center string for the display routine, --given RM, the margin width return "[c:" & sprint(RM) & "]" end function ----------------------------------------------------- -- test sequence text = "this is a test" CS = CenterString(25) display(CS,{txt})