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 strongm 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.
 
Try:
Code:
CLEAR
? CRYPTOGRAM("The Quick brown Fox Jumped over the lazy Dog")

FUNCTION CRYPTOGRAM
PARAMETERS m.INSTRING
PRIVATE m.INSTRING,m.OUTSTRING1,m.OUTSTRING2,I,m.CRLF
m.CRLF=CHR(13)+CHR(10)
m.OUTSTRING1 = ""
m.OUTSTRING2 = ""
IF LEN(m.INSTRING) > 0
	FOR I = 1 TO LEN(m.INSTRING)
		IF SUBSTR(m.INSTRING,I,1) <> " "
			m.OUTSTRING1 = m.OUTSTRING1 + "_ "
		ELSE
			m.OUTSTRING1 = m.OUTSTRING1 + "  "
		ENDIF
		m.OUTSTRING2 = m.OUTSTRING2 + SUBSTR(m.INSTRING,I,1)+" "
	NEXT


ENDIF
RETURN(m.OUTSTRING1+m.CRLF+m.OUTSTRING2)


_ _ _   _ _ _ _ _   _ _ _ _ _   _ _ _   _ _ _ _ _ _   _ _ _ _   _ _ _   _ _ _ _   _ _ _ 
T h e   Q u i c k   b r o w n   F o x   J u m p e d   o v e r   t h e   l a z y   D o g

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.
 
It's just a matter of using a non-proportional (aka monospaced) font.

I don't see a solution to get an overline in the width of a letter together with a letter. Such modifiers are available in Unicode, but VFP is ANSI.

So use Griff's code and print these two output line with Font Courier New and you're done. The underline one line above the text is the simplest solution and the only one I think works straight out of the box. There is that foxypreviwer extension to allow some HTML like tags to format output, but as far as I remember that's more about easily mixing bold, italic and print in colors, not about Unicode or printing Unicode modifiers.

Bye, Olaf.

Olaf Doschke Software Engineering
 
Just use a font where all characters are the same length. Is Courier one?

Olaf already suggested that (same width rather than same length). Courier is indeed one, although nowadays it's more likely to be Courier New.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
I suppose it could be done in an HTML table in a proportional font, using just one row, and enabling the
border on the top of each occupied character position, and a &nbsp; in each of the blanks.

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.
 
Thank you GriffMG, Mike, Olaf, TheProgrammerGuy,

I appreciate all your answers - I think I will use the function that GriffMG laid out for me. As far as using a uniform font, I'll experiment with that also maybe in an export and see what happens with Courier New. Not home now, so when I get back to my project I will let you know how it goes.
Happy Holidays, :cool:



 
Hello Aimskee,
Only a small point.
If you intend to use 'the quick brown fox' etc. then the word jumped should be JUMPS.
This sentence (pangram) is intended to use all the letters of the alphabet.

Regards
 
The usage of "quick brown fox" is not applicable to what I'm doing even tho it jumps and didn't "jumped" as you reminded me. I could have said "the sky is green with blue turnips" or "dighd id sdifnd ilk". The point is, in my project I'm encrypting famous quotes and just used "any text" to show that I need to place overlines over each letter so the text lines up with the overline. .


 
To all who gave me programming tips here: I found that even though I ran the function offered by GriffMG, on exporting the nicely aligned script to a PDF the letters and overlines once again don't line up in a report which I'm planning as my final printed output. I guess I would need a uniform font and those are hard to find on Windows PC.
I checked Courier fonts and they also didn't work (I'm using WIndows on a PC).
So I used a free app and created my own font and drew an overline over each letter I created so it was built right into the letter, and then installed the new font on my computer. That seems to work great so far. It eliminates the need for any extra programming too and it guarantees the line will always be directly above the letter. The only problem I have is that the font I created is not as pretty as professional fonts but I guess over the next week I'll perfect it and become a fontologist!
Thanks for all your help
Cheers. :)
 
Aimskee,

Good to hear that you have got it working, but you didn't need to create your own font. You simply needed to use a monospaced font, of which there are many. I'll bet you already have a few on your computer.

Examples of common monospaced fonts include Consolas, Letter Gothic, Lucida Console, Monaco, Prestite Elite, Typewriter, and anything with the word Mono in the name - as well as Courier New, which comes with all versions of Windows.

These fonts are worth knowing because you can also use them in code editors, such as the MODIFY COMMAND editor in VFP.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
I did try just about every font on my computer and eventually gave up. Maybe I missed them. I'll probably look into it in the next few days but it only took me a few minutes to make my own font.
 
Courier New exists on any Windows. You can't go wrong with that.
And yes, Griff's function output will also only align underscores and letters with such a font. Besides, I'd put that into a memo and print it in one report field, not as two separate strings in two fields. That'll give it the same left offset. Of course that report element has to have that font.

Bye, Olaf.


Olaf Doschke Software Engineering
 
I did courier new but it didn't line up. It was close but not perfect. by the time it got to "dog" it was off by a letter. I'll try it in a memo field. Thanks
 
In the code snippet I gave - the output was generated by the function.
Code snippets are in a monospaced font - so you can see it should stay lined up.

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.
 
aimskee said:
by the time it got to "dog" it was off by a letter

The only way I see this could hapen is, you have a) two report controls, one per line and b) set up different fonts/font sizes.

Using one control and printing a memo with the two lines as one value is simpler, as you print with a single control, that can only have one font and fontsize and one offset from the left margin. So yes, go for it, but the problem can't be the font itself.

Bye, Olaf.


Olaf Doschke Software Engineering
 
Won't printing CHR(196) once and re-printing the line with the alphabet do it? I am back to programming after a long long break (2000), so I'm not sure.
 
Yes, just saw that. I'm more used to Foxpro for DOS. This CHR(196) was a long hyphen like character. We used it to draw borders.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top