Back to index

Misc functions and procedures:

Sub Delay(expression)

Suspends the execution until a specified time interval has expired.

Where expression is time interval in seconds. Can be floating point value. E.g. 1 is 1 sec, 0.5 half second, 2.5 is 2 seconds and half, etc

Function Rgb(red,green,blue) As Integer

Constructs and returns RGB colour value from 3 colour components. RGB colour return by this function is used in all SBasic functions that operates with colours, e.g. SetPenColour, SetBrushColour, etc

Where red,green,blue are red, green and blue components of the colour (from 0 to 255).
Returns RGB colour value encoded as 32-bit integer number.

Function ReadKey As Integer

Read a key press and returns a key code of pressed key or 0 if there was no key press.

Remarks: Execution is not stoped on ReadKey function and application does not wait till user will press a key. If there was no key press from last call of ReadKey the function simply returns zero. ReadKey is designed to use in loops (repeating calls od readkey is required to work as designed). E.g.:

  While true
    '..... some code there ....
    Code = ReadKey
    If Code = ... Then
      ....
    End if
  Wend


To stop execution and read key you can use f.e. the code below:

  ' This code prints "Press any key to exit" message and then waits for key press
  ' After key press it exists

  Print "Press any key to exit"
  While Not ReadKey WEnd

Function CtrlModifier As Integer
Function ShiftModifier As Integer
Function FuncModifier As Integer

These functions are extension to ReadKey Function only. They return modifier state of LAST HANDLED key press by ReadKey function.

Folowing example displays key codes and modifiers (Can be found in examples section as well):

  Print "Displaying key code example. Press Ctrl-Space to exit..."
  While True
    Code = ReadKey

    If Code = 5 and CtrlModifier Then ' Exit check
       Exit While
    End if

    If Code <> 0 Then ' Something was pressed
      InfoBox "Code:", Code, "; Ctrl:", CtrlModifier, "; Shift:", ShiftModifier, "; Func:", FuncModifier
    End if
  WEnd



Copyright (c) 2000-2005 by SymbianWare OHG. All rights reserved.
SymbianWare and SymbianWare logo are trademarks of SymbianWare OHG.