Posts: 7
Threads: 3
Joined: Sep 2004
first of all...i apologise...this really isn't a newbie question...but since i'm a newbie...i think this is the right place for this post
i was curious...is there a possible way to do this?
i can't explain exactly, what i want(mostly because i don't speak english that well), so i'll try to show:
let's say i have a program code:
Code: print"Hello! Answer to my questions"
input"What is your name?"; name$
input"How old are you?"; age$
print"Name: "; name$
print"Age: "; age$
//here should be the textbox code..!!if u press ENTER, it counts the answer..
and then the program should look like this:
Code: Hello! Answer to my questions
What is your name
_______________________
|______________________| //<<--this is where i could type
Code: Hello! Answer to my questions
What is your name
_______________________
|dezell ______________| //<<--this is where i could type
Code: Hello! Answer to my questions
What is your name
How old are you
_______________________
|2_____________________| //<<--this is where i could type
Code: Hello! Answer to my questions
What is your name
How old are you
name dezell
age 2
_______________________
|______________________| //<<--this is where i could type
if somehing was not understandable, post here or send a private message...
thanks
Posts: 2,771
Threads: 96
Joined: Oct 2003
Well, you could do something like this:
[syntax="qbasic"]LOCATE 1, 1
PRINT "Hello! Answer to my questions"
PRINT "What is your name?"
LOCATE 7, 1
INPUT nam$
LOCATE 7, 1
PRINT " " 'Erase the text
LOCATE 3, 1
PRINT "How old are you?"
LOCATE 7, 1
INPUT age
LOCATE 7, 1
PRINT " " 'Erase the text
LOCATE 4, 1
PRINT "Name: "; nam$
PRINT "Age: "; age[/syntax]
I havent actually tested it, but it should work.
Posts: 394
Threads: 16
Joined: Jun 2003
If you want a box made out of lines, you'll have to switch to a graphics mode (or make a crummy one using those extended ascii bars).
ammit potato!
Posts: 719
Threads: 72
Joined: Mar 2003
Code: TYPE TextBoxType
selected AS INTEGER
x AS INTEGER
y AS INTEGER
length AS INTEGER
height AS INTEGER
END TYPE
Code: SUB Gui.Outline (xmin AS INTEGER, ymin AS INTEGER, xmax AS INTEGER, ymax AS INTEGER, blight AS LONG, bdark AS LONG)
Future.Line xmin, ymin, xmax, ymin, blight, -1
Future.Line xmin, ymin, xmin, ymax, blight, -1
Future.Line xmin, ymax, xmax, ymax, bdark, -1
Future.Line xmax, ymin, xmax, ymax, bdark, -1
END SUB
Code: SUB Gui.TextBox (info AS TextBoxType, text AS STRING)
DIM kbd AS STRING
DIM tkey AS STRING * 1
jj% = info.length \ 8
Future.BOX info.x - 2, info.y - 2, info.x + info.length + 2, info.y + info.height + 2, Black&
Gui.Outline info.x + 1, info.y + 1, info.x + info.length + 1, info.y + info.height + 1, lGrey&, dGrey&
Future.FILLBOX info.x, info.y, info.x + info.length, info.y + info.height, White&
IF TIMER MOD 2 = 0 THEN
dx% = info.x + ((LEN(text) + 1) * 8)
Future.Line dx%, info.y + 1, dx%, info.y + info.height - 1, Black&, -1
END IF
kbd = INKEY$
tkey = kbd
IF kbd = CHR$(32) THEN text = text + "_"
IF ASC(tkey) > 32 AND ASC(tkey) <= 126 THEN
text = text + tkey
ELSEIF tkey = CHR$(13) THEN
info.selected = 0
ELSEIF tkey = CHR$(8) AND LEN(text) > 0 THEN
text = LEFT$(text, (LEN(text) - 1))
ELSEIF tkey = CHR$(8) AND LEN(text) = 0 THEN
SOUND 200, .5
END IF
keyboard = kbd
Gui.Print text, info.x, info.y, Black&
END SUB
Its using future library, so just translate it........
Oz~
Posts: 719
Threads: 72
Joined: Mar 2003
Gui.PRINT is basically Future.PRINT, but with a constant transparent background......ignore it
Oz~
Posts: 7
Threads: 3
Joined: Sep 2004
dark_prevail, thank you, that's what i wanted...
potato ...no, the box made out of lines is not very important...but this is an other possibility...still, right now i'll stick to this first example...
Oz, thank you too...though, I didn't get your program to work :-?
Posts: 719
Threads: 72
Joined: Mar 2003
Where was teh program error?
I'll actually make the program if i can know where the problem is...
Oz~
Posts: 383
Threads: 14
Joined: Mar 2004
Maybe he didn't even think of converting it and just copy/pasted
Posts: 719
Threads: 72
Joined: Mar 2003
More than likely
I guess taht means he wants me to do the dirty work [no, not rectal surgery...lol]
Code: TYPE TextBoxType
PosX AS INTEGER
PosY AS INTEGER
Length AS INTEGER 'in characterrs....not pixels
Text AS STRING * 256
Selected AS INTEGER
END TYPE
DECLARE SUB TextBox (info AS TextBoxType)
DECLARE SUB RelPRINT (text AS STRING, x%, y%, col%)
SCREEN 12
DIM Test AS TextBoxType
Test.PosX = 1
Test.PosY = 1
Test.Length = 15
Test.Text = "Erease me"
Test.Selected = 1
DO UNTIL Test.Selected = 0
CALL TextBox (Test)
LOOP
END
'
' I borrowed this code from Relsoft
' I did minor editting to incorperate CHR$(13)
'
SUB RelPRINT (text AS STRING, x%, y%, col%)
'Prints the standard 8*8 CGA font
'Paramenters:
'Segment=the Layer to print to
'Xpos,Ypos=the coordinates of the text
'Text$=the string to print
'col= is the color to print(gradient)
oldx = x%
oldy = y%
DIM crap AS STRING * 1
Spacing% = 8
FOR i% = 0 TO LEN(text$) - 1
x% = x% + Spacing%
crap = MID$(text$, i% + 1, 1)
IF crap = CHR$(13) THEN
crap = ""
y% = y% + 8
x% = oldx
END IF
Offset% = 8 * ASC(crap) + 14
FOR j% = 0 TO 7
DEF SEG = &HFFA6
Bit% = PEEK(Offset% + j%)
IF Bit% AND 1 THEN PSET (x%, y% + j%), col%
IF Bit% AND 2 THEN PSET (x% - 1, y% + j%), col%
IF Bit% AND 4 THEN PSET (x% - 2, y% + j%), col%
IF Bit% AND 8 THEN PSET (x% - 3, y% + j%), col%
IF Bit% AND 16 THEN PSET (x% - 4, y% + j%), col%
IF Bit% AND 32 THEN PSET (x% - 5, y% + j%), col%
IF Bit% AND 64 THEN PSET (x% - 6, y% + j%), col%
IF Bit% AND 128 THEN PSET (x% - 7, y% + j%), col%
NEXT j%
NEXT i%
DEF SEG
x% = oldx
y% = oldy
END SUB
SUB TextBox (info as TextBoxType)
DIM kbd AS STRING
DIM tkey AS STRING * 1
LINE (info.x, info.y)-(info.x + info.length, info.y + info.height), 15,BF
IF TIMER MOD 2 = 0 THEN
dx% = info.x + ((LEN(text) + 1) * 8)
LINE (dx%, info.y + 1)-(dx%, info.y + info.height - 1), 0
END IF
kbd = INKEY$
tkey = kbd
IF kbd = CHR$(32) THEN text = text + "_"
IF ASC(tkey) > 32 AND ASC(tkey) <= 126 THEN
info.text = info.text + tkey
ELSEIF tkey = CHR$(13) THEN
info.selected = 0
ELSEIF tkey = CHR$(8) AND LEN(text) > 0 THEN
text = LEFT$(text, (LEN(text) - 1))
ELSEIF tkey = CHR$(8) AND LEN(text) = 0 THEN
SOUND 200, .5
END IF
keyboard = kbd
RelPRINT text, info.x, info.y, 0
END SUB
That should about do it......
I didn't test it, so be warned,
Oz~
Posts: 7
Threads: 3
Joined: Sep 2004
edit:
still, I made copy-paste...and qb said:
"END SUB or END FUNCTION must be last line in window"
like whatever
|