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!

String Function problem or any solution would be helpful 2

Status
Not open for further replies.

aimskee

Programmer
Feb 3, 2000
60
US
I'm writing some cryptograms in VFP 6.0 and I am using the report generator to print out my cryptograms.

I want to place an overline (as opposed to an underline) over each letter of the encrypted sentence with a space
in between each letter so that each underline clearly represents each letter.


_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
T h e q u i c k b r o w n f o x

What is the function I would use in the report to place a line directly over each letter in an frx?

I tried just programming the underlines I want that correspond to the letters in a table, but the
underlines and the letters do not line up.

So I would I guess want to use a function for each letter of the encryption.

Thanks for any help.
When I posted my post, I noticed it took away the spaces between the words "The quick brown fox", one of the problems
I would be trying to avoid in a solution to this problem in VFP.
 
QuickBrownFox_uwu5wh.jpg


When I ran the function it did not line up perfectly. See the attached jpg of my output. I had my font set to Courier New. It was close until the last 3 words.

I need to present this in a PDF and after I export it using the suggested monospaced fonts, I still run into similar problems there where it's not quite lining up especially with longer sentences.

But it's very useful to know this function - when I play around with it some more I'll probably get it worked out when I export it into a PDF and then print out which will be the final output which has to be perfect.

I should prob. upgrade to more recent Foxpro although I do not know if it would cost benefit me at this time.

I also put
set printer font "Courier New", 12

in the program before the function runs.
Maybe you can tell by looking at my attached jpg here what the problem is.
Output does not look like Courier New so maybe my old installation of VFP 6.0 on my new computer is missing components although no errors are popping up.
 
Yes, this simply doesn't look like Courier New, it isn't Courier New and it obviously isn't monospaced.

What is your printer? Maybe it only prints an embedded font and doesn't adhere to any font settings you do.

When you use a PDF Printer, which acts as a printer hardware emulator addressable in the same ways as a real printer, just instead of printing outputting a PDF file, then you will be able to print True Type fonts. Unless you use some weird PDF printer or have some weird setting of it to always use a predefined font. But then printing the DOS way also woulndn't work. To print a layout of your choice with multiple fonts and images and more features, you can't print with ??? or @ commands, you have to migrate to FRX printing.

If you don't use an FRX to print you will not be guaranteed to define fonts used by the printer. FRXes use the GDI model of Windows and most any printer is supporting that, so you can print with any true type font (and more, but that's the usual norm for fonts also on displays).

Bye, Olaf.


Olaf Doschke Software Engineering
 
Aimskee, the jpg you posted is definitely not Courier New. To see what Courier New looks like, take a look at the code that Griff posted near the start of this thread - or any other formatted code in this forum. That's Courier New.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
It's close - but no cigar

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Mike Lewis said:
To see what Courier New looks like, take a look at the code that Griff posted near the start of this thread - or any other formatted code in this forum. That's Courier New.

Or in other words, if you set _SCREEN.Fontname = "Courier New" and run his code that would align. And if you don't see Griffs example aligned even in your browser, indeed something is wrong in the fonts of your Windows.

I still think you're actually having a printer with fixed embedded fonts.

Bye, Olaf.

Olaf Doschke Software Engineering
 
I just tested Griff's code with CHR(151) instead of hyphen and it looked like this. There is a huge gap between lines.
asctest_vznq2m.png


I was searching a substitute for the chr(196) in DOS versions. I hope this CHR(151) can replace it.
 
I don't know where you see a hyphen in Griff's code, the underscores are generated here: [tt]"_ "[/tt] in case there is a letter in the text and spaces [tt]" "[/tt] in the other case, so there always is the one separation space to have individual lines and not one continuous line.

You can use whatever character fits in the DOS codepage you use. In DOS screens you'd have a character grid anyway, all DOS fonts are monospaced that way. So all that matters is the ASCII code is a line.

It will depend on what DOS codepage you're using, there are several depending on the OS locale, also for DOS. See supported codepages in the VFP help, find out the DOS codepage used in your locale and see which codes then are lines. Hyphens would obviously appear higher and not full width. In many DOS codepages you have full-width centered lines as part of a charset in the upper half that's available to draw boxes so you don't use hyphen, plus, and pipe or even exclamation mark to create pseudo boxes. There are only about 128 chars to test. Just print out all of them to see what fits.

Bye, Olaf.

Olaf Doschke Software Engineering
 
I still don't see a problem. When you program in Windows you program in a Windows Codepage. If you then run that in DOS it displays with a DOS Codepage. When you see an underscore in Windows, that might or might not be one on DOS.

If I MODIFY COMMAND new.prg AS 850 the umlauts for example become other characters. Not while editing the code, when executing it and printing to the VFP Windows _SCREEN, for example.

If you mean the gap between the underlines and letters, that looks like you have a whole line in between there. Griff's code adds CRLF. Maybe DOS only needs CR or LF? Or just by chance the character is the line at the top margin, an "overline". Then that'll also look like a whole line vertical gap.

You have to look up what codepage you're really working with under DOS Screens and learn or know some details. We're typically dealing with Windows here, that's using other codepages and under Windows CRLF is necessary just for one linefeed.

And once more, for Griff's code to use Courier new on the _SCREEN you need to set _screen.fontname = "Courier New". Literally "Courier New", There also is Curier New, that is not monospaced, for example.

Bye, Olaf.

Olaf Doschke Software Engineering
 
I really did not expect that tiny bit of code to take on a life of it's own...

B-)

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Your code is fine, in itself the string just has no formatting, so to show it in Courier New you have to use Courier New, and be able to use Courier New on devices used for output, too. Or any other really monospaced font.

Bye, Olaf.

Olaf Doschke Software Engineering
 
To clarify a few things:

How FRXes can use Windows Fonts also is limited to Windows printers. Printing legacy style with SET PRINTER TO usually will be done by installing a Windows printer based on the "Generic/Text" driver and using ??? and @ commands to print. What you can do in terms of Fonts is unknown to me, I doubt the Generic/Text driver will forward any font settings to the real printer, as it's a, well, generic driver.

And if your printer uses embedded fonts you also won't be able to print with other fonts by using this driver or even a driver given by the vendor, embedded fonts are embedded fonts and you'd only have some compatibility.

And a mistake I made in my 12_16 post: "Curier New" also isn't a font I have. I just tried a bit more and it's even simpler, every time you set _SCREEN.FontName to a non-existing fontname you get some font, which looks quite similar to Courier New, looking like a typewriter font, but it's proportional with much narrower spaces than Courier New.

And setting _SCREEN.FontName won't set the font you print with, but it's the basis of what will determine the pixel positions of @say and @get commands, even if you then output with a font clause specifying another font.

Bye, Olaf.

Olaf Doschke Software Engineering
 
What you can do in terms of Fonts is unknown to me, I doubt the Generic/Text driver will forward any font settings to the real printer, as it's a, well, generic driver.

I think that's right. The way to use Generic/Text Only would be to send the printer-specific formatting codes (aka escape sequences). That would include codes to select the required font. But the font in question would have to already be resident in the printer.

So, yes, you can select fonts and also formatting (such as bold and italic) with Generic/Text Only, but you would have to change your code each time you moved to a different printer, or to a printer with different fonts installed. And there would be no way to preview the report on the screen.

Many older printers have Courier installed as a printer-resident font. Of course, Courier is not the same as Courier New.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Thanks Mike,

I was thinking along the lines that you may use the Generic/Text Only printer driver for a new printer, even though there are much better vendor drivers for Windows, because even without using escape sequences and detail knowledge about a printer you can at least print text the old way - while using the Windows GDI+ drivers coming with printers you can only really address them from VFP FRX reports.

Needing to know a command set of a specific printer would be a nightmare. That's not recommendable.

This way some of the functionalities work, ie printing text directly. But I doubt the SET PRINTER FONT or the FONT clause of @ commands would work. I think when a modern printer is addressed by the Generic/Text Only driver it will print with a default font, perhaps in draft mode, perhaps even a good readable but unfortunately not a monospaced font.

How the FONT setting or option worked in legacy Foxpro is beyond me, but I think that has to be in conjunction with a more general command set of printers from that era.

Bye, Olaf.

Olaf Doschke Software Engineering
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top