Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Making strings into underlines

Author
Message
Towelie
20
Years of Service
User Offline
Joined: 21st Apr 2004
Location:
Posted: 29th Apr 2004 14:35
I'm making hangman and I need to make the quote that it chooses into underlines but I can't figure out a way without having a new string of underlines for everquote or use the Par command to find every letter or something HELP?!?!?!
John H
Retired Moderator
21
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 29th Apr 2004 14:43 Edited at: 29th Apr 2004 14:49
Hold on I'll whip up a function really quick


We need help! Email us! join@eternaldestinyonline.com
John H
Retired Moderator
21
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 29th Apr 2004 14:48


There ya go


We need help! Email us! join@eternaldestinyonline.com
Towelie
20
Years of Service
User Offline
Joined: 21st Apr 2004
Location:
Posted: 29th Apr 2004 14:59
...Woops I meant I need to make all the letters into underlines like in a hangman program so "Don't forget to bring a towel." becomes "_ _ _'_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _."

Notice the spaces and the 's don't turn into underlines...
John H
Retired Moderator
21
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 29th Apr 2004 15:15
Meh ok that complecates things a bit but still very do-able. I gotta go to school now though, but Ill give you a brief descreption of how one would go about doing this.

First use the Len() command to check how many characters are in the string, Thats how many underlines you will have to have. Find out the width of a space in a string, save it as SpaceSize# or something. Next your going to have to make a formula that finds out how many spaces are in the string, something like

Your A Towel

Has 12 Characters, 11 spaces (counting inbetween letters) So your space count is going to be Length# - 1. Divide The Text Width() of your string by how many characters are in your string to get the width of one letter. Then just make a for next loop that goes something like

Make a Line
Jump ahead the SpaceWidth#
Make another line

Over and over again till youve underlined the last letter.

Cheers

RPGamer


We need help! Email us! join@eternaldestinyonline.com
the_winch
21
Years of Service
User Offline
Joined: 1st Feb 2003
Location: Oxford, UK
Posted: 29th Apr 2004 22:08
I would do it by having a string for the word that the user tries to guess and a string that you display on the screen.



i won't see you in the pit
Towelie
20
Years of Service
User Offline
Joined: 21st Apr 2004
Location:
Posted: 30th Apr 2004 01:21 Edited at: 30th Apr 2004 03:13
Well...I'd rather not have a 2 strings for every one...I was thinking using the par command to check every letter in the string and then if the letter = a-z then print an underscore on the screen or something like that


For x = 1 to len(String$)

Printunderline = par(string, x)

If print underline = a-z then print "_ "

But that won't work as is so I need some help


RPGamer...You...Totaly...Lost...Me

Also I wan't to put 3 spaces for every real space... But this takes away spaces past one so tahts why my second post looked kinda weird with the underlines...
Towelie
20
Years of Service
User Offline
Joined: 21st Apr 2004
Location:
Posted: 30th Apr 2004 03:17 Edited at: 30th Apr 2004 03:18
Oh winch yea thanks that works I read it wrong the first time...

and now that I look at it thats alot like the code I came up with lol...
Towelie
20
Years of Service
User Offline
Joined: 21st Apr 2004
Location:
Posted: 30th Apr 2004 04:16
is there a way to instead of doing ! or ' can you test a latter to see if its from a - z
Towelie
20
Years of Service
User Offline
Joined: 21st Apr 2004
Location:
Posted: 30th Apr 2004 04:39 Edited at: 30th Apr 2004 04:51
Alright here is what I have please PLEASE help me with this I am getting so lost...

if you can't figure out whats wrong with it try compling it it has some problem with line 90
hyrichter
20
Years of Service
User Offline
Joined: 15th Feb 2004
Location: Arizona
Posted: 30th Apr 2004 06:20
In your code, you're not using the "or" command properly. You have

It should go...


Quote: "is there a way to instead of doing ! or ' can you test a latter to see if its from a - z "


Yes, there is Just check the ASCII value of each letter you are using. So change your subroutine to this:



However, I would recommend putting that into a function that you just pass a string to, and it returns the "underscore" string.

Hope I helped...

Towelie
20
Years of Service
User Offline
Joined: 21st Apr 2004
Location:
Posted: 30th Apr 2004 14:14 Edited at: 30th Apr 2004 14:24
Alright thanks

Oh yea with the or thing thats what I get for copy pasting
Towelie
20
Years of Service
User Offline
Joined: 21st Apr 2004
Location:
Posted: 30th Apr 2004 14:53
Ok well I'm having a pbroblem with the For Next command




I've tried changeing the X's to A's and then I tried putting an ENDIF after the second If statement that I put in there....


Heres the code incase it is something in the rest of the code
Towelie
20
Years of Service
User Offline
Joined: 21st Apr 2004
Location:
Posted: 30th Apr 2004 14:54
Woops...Ok heres the real code ignore that top one
spooky
22
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 30th Apr 2004 17:57
You were just missing an endif



Boo!
John H
Retired Moderator
21
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 1st May 2004 01:04
Heh...sorry yesterday I had school practice then city baseball practice and wasnt home till 8 >_< Well looks like you got help.

Cheers

RPGamer


We need help! Email us! join@eternaldestinyonline.com
Towelie
20
Years of Service
User Offline
Joined: 21st Apr 2004
Location:
Posted: 1st May 2004 18:59
Alright I think I got most of it working...How come when I make my quote apear on the screen it comes up with the punctuiations in the center of the line instead of the bottom like a period looks like
_ _ _ _ _ • instaed of _ _ _ _ .

Login to post a reply

Server time is: 2024-09-22 07:36:35
Your offset time is: 2024-09-22 07:36:35