If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!
Moderators: Pete , Mods
lurah-
Veteran
Posts: 206 Joined: Mon Nov 01, 2004 10:47 am
Location: Finland
Contact:
Post
by lurah- » Sat Feb 19, 2005 8:53 am
Code: Select all
CLS
INPUT "Write text:";t$
FOR y = 1 TO LEN(t$)
LOCATE 10, y
PRINT MID$(t$, y, 1)
NEXT
[END]
Ok, that works but how i can LOCATE it so that it will be centerd on screen?
Some how i need to find out how long t$ is so i can place it so that finally it?s middle of screen.
LOCATE 10, 40 - y(- half of lenght of t$) something like this. Lol, hope you got my point here =)
Screen is 80,50 width
Mitth'raw'nuruodo
Veteran
Posts: 839 Joined: Sat Jan 22, 2005 11:04 am
Location: Eastern Coast of US
Contact:
Post
by Mitth'raw'nuruodo » Sat Feb 19, 2005 9:01 am
Ok sme thing except:
Here's your new locate statement:
LOCATE 25, (40-INT(LEN(t$)/2)+y)
Got that? Good....
I just tyoed that so it should work let me know...
"But...It was so beutifully done"
lurah-
Veteran
Posts: 206 Joined: Mon Nov 01, 2004 10:47 am
Location: Finland
Contact:
Post
by lurah- » Sat Feb 19, 2005 9:07 am
Yah, Mitth. You are DA MAN
thx a lot.
Mitth'raw'nuruodo
Veteran
Posts: 839 Joined: Sat Jan 22, 2005 11:04 am
Location: Eastern Coast of US
Contact:
Post
by Mitth'raw'nuruodo » Sat Feb 19, 2005 10:31 am
Glad to help, your welcome.
"But...It was so beutifully done"
Rattrapmax6
Veteran
Posts: 1055 Joined: Sun Jan 02, 2005 2:11 pm
Location: At my computer
Contact:
Post
by Rattrapmax6 » Sat Feb 19, 2005 12:02 pm
Yep, Mitth's code is correct, but this is shorter..
LOCATE 1, 40 - (LEN(text$) \ 2): PRINT text$
There, you can chose..
( \ ) rounds while dividing if you want to know.
Last edited by
Rattrapmax6 on Sat Feb 19, 2005 1:54 pm, edited 1 time in total.
-Kevin (aka:Rattra)
(x.t. r.GRA PHICS )
Mitth'raw'nuruodo
Veteran
Posts: 839 Joined: Sat Jan 22, 2005 11:04 am
Location: Eastern Coast of US
Contact:
Post
by Mitth'raw'nuruodo » Sat Feb 19, 2005 12:08 pm
Well I was truncating it which divide in QB doesn't do other wise it would be a decimal.
And you are right that is shorter, cause its the whole program you need no LOOP or MID$!
BUT you're partically right that even though / doesn't round in QB, the LOCATE statement does. But I didn't want to round it up I preferr down.
"But...It was so beutifully done"
Rattrapmax6
Veteran
Posts: 1055 Joined: Sun Jan 02, 2005 2:11 pm
Location: At my computer
Contact:
Post
by Rattrapmax6 » Sat Feb 19, 2005 12:13 pm
Yeah, you use this in raycasting to limit some floating points ( \ ) to encreace running speed... yours would slow it down, but applied to what larah wants, yours works, but mine will save for typing..
-Kevin (aka:Rattra)
(x.t. r.GRA PHICS )
Mitth'raw'nuruodo
Veteran
Posts: 839 Joined: Sat Jan 22, 2005 11:04 am
Location: Eastern Coast of US
Contact:
Post
by Mitth'raw'nuruodo » Sat Feb 19, 2005 1:15 pm
Oh that a back space, your right!
Well thats just another optimization for my program to do...
"But...It was so beutifully done"
Rattrapmax6
Veteran
Posts: 1055 Joined: Sun Jan 02, 2005 2:11 pm
Location: At my computer
Contact:
Post
by Rattrapmax6 » Sat Feb 19, 2005 1:53 pm
Heh heh, yep...
-Kevin (aka:Rattra)
(x.t. r.GRA PHICS )
Z!re
Veteran
Posts: 887 Joined: Wed Aug 04, 2004 11:15 am
Post
by Z!re » Sat Feb 19, 2005 3:27 pm
/ is floating point division
\ is integer division, it does NOT round, it IGNORES any decimals.
I have left this dump.
Rattrapmax6
Veteran
Posts: 1055 Joined: Sun Jan 02, 2005 2:11 pm
Location: At my computer
Contact:
Post
by Rattrapmax6 » Sat Feb 19, 2005 3:30 pm
Okay, not round, I'm misstaken.. but still, the effects are close to the same...
-Kevin (aka:Rattra)
(x.t. r.GRA PHICS )