Ooops
November 28, 2020, 01:46:51 PM

Author Topic: [bb] Question$() by Reaper [ 1+ years ago ]  (Read 535 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] Question$() by Reaper [ 1+ years ago ]
« on: June 29, 2017, 12:28:40 AM »
Title : Question$()
Author : Reaper
Posted : 1+ years ago

Description : This allows you to have an input style command that you can place at any screen coords. also the typed response may be placed at any coords.

Code :
Code: BlitzBasic
  1.  
  2. ;           *****************************************
  3. ;           *  Question Function  * By Nick Stacey  *
  4. ;           *****************************************
  5. ;
  6. ;        A more versatile version of the input command
  7. ;
  8. ;
  9. ;Format  a$=Question(r,g,b,x,y,question,minlength,maxlength,r2,g2,b2,x2,y2)
  10. ;        where rgb,x&y are colour and coords of question
  11. ;                and r2,b2,g2,x2 & y2 are color and coords of typed response
  12. ;                minlength and maxlength are then minimum/maximum length of returned string
  13. ;                optional format of
  14. ;                a$=Question(r,g,b,x,y,question$,0,0,0,0,0,0,0)
  15. ;                which means the function will behave more like a normal input and typed
  16. ;                response will appear straight after question.
  17. ;
  18. ;                Feel free to use and/or modify this code as much as required
  19. ;
  20.  
  21. Function Question$(r,g,b,x,y,question$,minlength,maxlength,r2,g2,b2,x2,y2)
  22. Frontbuff = FrontBuffer() : setbb =0
  23. If GraphicsBuffer() <>FrontBuff Then SetBuffer FrontBuffer():setbb=1
  24. oldr=ColorRed() :oldg=ColorGreen():oldb=ColorBlue()
  25. GetColor -1,-1
  26. br= ColorRed(): bg=ColorGreen(): bb=ColorBlue()
  27. Color br,bg,bb : l=Len(question$)
  28. Rect x,y,(FontWidth()*l),FontHeight(),1
  29. Color r,g,b
  30. Text x,y,question$
  31. value = 0 : a$=""
  32. If r2=0 And b2=0 And g2=0 And x2=0 And y2=0 Then
  33.         r2=r:g2=g:b2=b:y2=y: x2=x+(FontWidth()*Len(question$))
  34. EndIf
  35. Color r2,g2,b2
  36. l=Len(a$)
  37. While (Not KeyHit(28)) Or l <minlength
  38.         While Not value
  39.                 value = GetKey()
  40.         Wend
  41.         l = Len(a$)
  42.         If KeyHit(14) Then
  43.                 If l >0 Then
  44.                         a$=Left$(a$,l-1)
  45.                         Color br,bg,bb
  46.                         Rect x2,y2,(FontWidth()*l),FontHeight(),1
  47.                         Color r2,g2,b2
  48.                         Text x2,y2,a$
  49.                 EndIf
  50.                 Delay 50
  51.                 FlushKeys
  52.                 Delay 50
  53.         EndIf
  54.         If value >=32 And value <= 126 And (l < maxlength Or maxlength =0) Then
  55.                 a$=a$+Chr$(value):Delay 10
  56.                 If typ=1 Then
  57.                         Text x+(FontWidth()*(Len(question$))),y,a$
  58.                 Else
  59.                         Text x2,y2,a$
  60.                 EndIf
  61.         EndIf
  62.         value=0
  63. Wend
  64. Delay 10
  65. FlushKeys
  66. Color oldr,oldg,oldb
  67. If setbb =1 Then SetBuffer BackBuffer()
  68. Return a$
  69. End Function
  70.  
  71.  


Comments : none...

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal