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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Long time since I did basic!!! 1

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
Hey guys, I want to write a quick program that takes the elements of a xxxxx.txt file, and decapitalises the letters in the file (apart from the first letter of words, which are names of people and places!!)

SO: how do i load in a file to be editted then spat back out again??? (Can't remember , it's been Yeeeeaaarrsss!!)

Please advise to darlee@home.com

Thanks

Darren
 
It would take a pretty sophisticated QB program to recognize the names of people and places. Start with the easy stuff. This little snippet opens "c:\myfile.txt" and converts all the letters after the first letter of a word to lowercase.
[tt]
ff = FREEFILE
OPEN "c:\myfile.txt" FOR BINARY AS ff
Gin$ = STRING$(LOF(ff), " ")
GET #ff, 1, Gin$
IF LEN(Gin$) < 2 THEN
CLOSE #ff
PRINT &quot;File too small!&quot;
END
END IF
FOR R = 2 TO LEN(Gin$)
IF MID$(Gin$, R - 1, 1) <> CHR$(32) THEN
IF MID$(Gin$, R - 1, 1) <> CHR$(10) THEN
MID$(Gin$, R, 1) = LCASE$(MID$(Gin$, R, 1))
END IF
END IF
NEXT
PUT #ff, 1, Gin$
CLOSE #ff
[/tt]

Have fun!

VCA.gif
 
Is the file going to be comma delimited or will it have spaces or what, because after you cap the first letter, you can lower all the other letters untill you reach a space or comma, and then cap the first letter after that space or comma. Hope this helps
DarkMercenary
darkmercenary44@earthlink.net

In the real world

As in dreams

Nothing is quite

What it seems

:Book of Counted Sorrows
 
Off Topic:
Quick question, DarkMercenary, in your personal profile you reference the Book of Counted Sorrows. Is that an H.P. Lovecraft reference or personal? Do tell.

On Topic:
You're right about the comma delimited problem. If the file was written with fields separated by commas, my code wouldn't work very well. How can one tell if a file contains pure text or delimited data?

Any thoughts? This problem has pestered me for many years.

VCA.gif

Alt255@Vorpalcom.Intranets.com
 
Well if the output file is written correctly, you would be able to determin whether or not it is fields or paragraphs.

Here's the idea:

Input 2 or 3 lines (notice I said Lines not words).

Count the number of instances of spaces between wordsand compare.

If they match exactly then MOST LIKELY they are fields.

If they don't match then count number of commas and compare.

If the counted commas match exactly then MOST LIKELY they are fields.

If they don't match then there are no fields--MOST LIKELY paragraphs.

End of idea:

Of course this is time consuming to say the least, however, that's the best I can come up with. Hope it at least gives you something to go on, Alt255.

--MiggyD
 
Good thought, MiggyD. It might need some work but it's a start.
VCA.gif

Alt255@Vorpalcom.Intranets.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top