List Of Snippets By Member: "silent"

Detecting Press Of Arrow Keys in Algorithms

Here is a small snippet to detect the press of arrow keys in the form keypress event.

PUBLIC CONST ARROW_LEFT AS INTEGER = 4114
PUBLIC CONST ARROW_RIGHT AS INTEGER = 4116
PUBLIC CONST ARROW_UP AS INTEGER = 4115
PUBLIC CONST ARROW_DOWN AS INTEGER = 4117

PUBLIC SUB Form_KeyPress()

SELECT CASE Key.Code
CASE ARROW_LEFT
PRINT "You pressed the left arrow key."
CASE ARROW_RIGHT
PRINT "You pressed the right arrow key."
CASE ARROW_UP
PRINT "You pressed the  up arrow key."
CASE ARROW_DOWN
PRINT "You pressed the down arrow key."
END SELECT

END

Posted: 2008.09.05 23:15 | Tags: keypress | 0 comments

Copy Collection to Another Collection in Algorithms

DIM cSource AS Collection
DIM cDest AS NEW Collection
DIM vVal AS VARIANT

FOR EACH vVal IN cSource
 cDest[cSource.Key] = vVal
NEXT

Posted: 2008.09.05 23:16 | Tags: collection | 1 comments

Get Input Using InputBox in Miscellaneous

DIM data AS STRING
data = InputBox("TEXT ON INPUTBOX", "THE TITLE", "DEFAULT VALUE")
PRINT data

Posted: 2008.09.06 04:47 | Tags: inputboxinput | 0 comments

Prevent Event To Take Action in Miscellaneous

Taken from http://forum.stormweb.no/index.php/topic,441.msg1196.html#msg1196
This one will prevent SpinBox's _Change to action

PUBLIC SUB Form_Open()
  OBJECT.LOCK(SpinBox1)
  SpinBox1.Value = 50
  OBJECT.UNLOCK(SpinBox1)
END

Posted: 2008.09.15 18:53 | Tags: eventlock | 0 comments

Make a Form Center Screen in Miscellaneous

ME.Center
'or if calling from other form
frmTarget.Center

Posted: 2008.09.16 22:10 | Tags: formcenter | 0 comments

Howto lock file in Files and Directories

by Benoit in gambas-user mailing list

DIM hFile AS File

TRY hFile = LOCK "~/lock"
IF ERROR THEN
 PRINT "Already locked by something else!"
ELSE
 PRINT "Got locked!"

 UNLOCK hFile
ENDIF

Posted: 2008.10.05 19:23 | Tags: filelock | 0 comments

1