Page 1 of 1
Posted: Sun Sep 01, 2002 1:25 pm
by BackupUser
Restored from previous forum. Originally posted by merendo.
I need an example-code for a full working input which allows to enter a multi-lined string$.I.e: If the line is full, the input shall automatically do a line-return (Chr(13)). Can anyone help me???
Cu @ll, merendo
--
I've been hiding - What am I hiding from???
Posted: Sun Sep 01, 2002 3:10 pm
by BackupUser
Restored from previous forum. Originally posted by Paul.
Code: Select all
StringGadget(0,10,10,300,200,"",#ES_MULTILINE|#ESB_DISABLE_LEFT|#ESB_DISABLE_RIGHT|#ES_AUTOVSCROLL|#WS_VSCROLL)
Probably the wrong constants (I kinda guessed) but it works.
Posted: Sun Sep 01, 2002 3:33 pm
by BackupUser
Restored from previous forum. Originally posted by merendo.
No, In screen mode, not in Window-mode!!!
Cu @ll, merendo
--
I've been hiding - What am I hiding from???
Posted: Sun Sep 01, 2002 7:17 pm
by BackupUser
Restored from previous forum. Originally posted by PB.
> I need an example-code for a full working input which allows to enter
> a multi-lined string$.I.e: If the line is full, the input shall
> automatically do a line-return (Chr(13)). Can anyone help me???
I would suggest modifying my example found here:
viewtopic.php?t=1590
What you could do, is alter the Repeat...Until loop to keep track of
the number of characters typed, then force a return when 80 are typed.
If you need any further help, I'll do a full example, but it shouldn't
be too hard to figure out.
PB - Registered PureBasic Coder
Posted: Sun Sep 01, 2002 11:39 pm
by BackupUser
Restored from previous forum. Originally posted by merendo.
Already tried. In BlitzBasic there is an example how to catch a string, limit the lenght, only certain letters can be entered and so on. I tried to translate, wait a minute, I'm gonna fetch it...
Code: Select all
InitSprite()
; Thanks to PB at the international PureBasic forum at: forums.purebasic.com for the code: GetKey()
; GetKey() routine by PB -- do what you want with it. :)
; Obviously it can be expanded to handle more keys...
; Function: Waits for a keypress and returns ASCII code of the key.
; Usage: c=GetKey() ; c = ASCII value of pressed key.
;
For k=8 To 13 : getasynckeystate_(k) : Next ; Clear backspace, tab, enter buffers.
For k=48 To 57 : getasynckeystate_(k) : Next ; Clear number key buffers.
For k=65 To 90 : getasynckeystate_(k) : Next ; Clear letter key buffers.
; Clear key buffers of other keys.
getasynckeystate_(#VK_SPACE)
getasynckeystate_(#VK_ESCAPE)
;
Procedure GetKey()
sleep_(1) ; To stop 100% CPU usage.
For k=8 To 13 ; Check backspace, tab, enter keys.
If getasynckeystate_(k)=-32767 : r=k : EndIf ; Pressed!
Next
For k=48 To 57 ; Check number keys.
If getasynckeystate_(k)=-32767 : r=k : EndIf ; Pressed!
Next
For k=65 To 90 ; Check letter keys.
If getasynckeystate_(k)=-32767 : r=k : EndIf ; Pressed!
Next
; Check other keys (add more here if you like).
If getasynckeystate_(#VK_SPACE)=-32767 : r=32 : EndIf ; Space pressed.
If getasynckeystate_(#VK_ESCAPE)=-32767 : r=27 : EndIf ; Escape pressed.
ProcedureReturn r
EndProcedure
Global Name$
Global Zeiger
Global Font
Global a
Dim ZwischenName$(10)
OpenScreen(640,480,16,"asded")
Zeiger = 1
While a 13 ; Return ends input
StartDrawing(ScreenOutput())
FrontColor(0,0,0)
Box(0,0,200,200)
FrontColor(255,0,255)
Locate(0,0):DrawText("Please type your name:")
For x = 1 To 10
Locate(10 * x - 10,20)
DrawText(ZwischenName$(x))
StopDrawing()
Next
a = GetKey()
If Zeiger 64 And a 96 And a 1 And a = 8
; Backspace
Zeiger = Zeiger - 1
ZwischenName$(Zeiger) = ""
EndIf
FlipBuffers()
Wend
For x = 1 To 10
Name$ = Name$ + ZwischenName$(x)
Next
ClearScreen(0,0,0)
MessageRequester("",Name$,0)
Cu @ll, merendo
--
I've been hiding - What am I hiding from???