home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip Hitware 6 A
/
CHIP_HITWARE6_A.iso
/
internet
/
visIrc
/
INSTALL.EXE
/
RCDATA
/
CABINET
/
guessovs.vsc
< prev
next >
Wrap
Text File
|
1996-11-26
|
3KB
|
103 lines
// GUESSOVS.VSC (version 1.01)
// A simple ObjectViRCScript guess-the-number game for ViRC '96 (0.80+)
//
// Simply type "/load guessovs.vsc" to play!!
Name Guess the number game!!
if !($ovsversion)
MessageBox This script requires ViRC '96 0.80 or higher with ObjectViRCScript to function.
Halt
endif
// Make all the controls and set the properties
@ $form = $new(TForm)
@p $form.Left = 234
@p $form.Top = 169
@p $form.Width = 329
@p $form.Height = 135
@p $form.Visible = 1
@p $form.Caption = ObjectViRCScript demonstration
@p $form.BorderStyle = 3
@p $form.OnClose = UnAlias NUMBER_GUESS NUMBER_CANCEL
@ $guesslabel = $new(TLabel ownedby $form)
@p $guesslabel.Left = 10
@p $guesslabel.Top = 9
@p $guesslabel.Width = 299
@p $guesslabel.Height = 25
@p $guesslabel.Caption = Guess the number!!
@p $guesslabel.Font.Color = clBlue
@p $guesslabel.Font.Size = 12
@p $guesslabel.Visible = 1
@ $edit = $new(TEdit ownedby $form)
@p $edit.Left = 12
@p $edit.Top = 44
@p $edit.Width = 121
@p $edit.Height = 24
@p $edit.Visible = 1
@ $guessbtn = $new(TButton ownedby $form)
@p $guessbtn.Left = 144
@p $guessbtn.Top = 44
@p $guessbtn.Width = 75
@p $guessbtn.Height = 24
@p $guessbtn.Caption = &Guess!!
@p $guessbtn.Default = 1
@p $guessbtn.OnClick = NUMBER_GUESS
@p $guessbtn.Visible = 1
@ $cancelbtn = $new(TButton ownedby $form)
@p $cancelbtn.Left = 228
@p $cancelbtn.Top = 44
@p $cancelbtn.Width = 75
@p $cancelbtn.Height = 24
@p $cancelbtn.Caption = Cancel
@p $cancelbtn.Cancel = 1
@p $cancelbtn.OnClick = NUMBER_CANCEL
@p $cancelbtn.Visible = 1
@ $statuslbl = $new(TLabel ownedby $form)
@p $statuslbl.Left = 12
@p $statuslbl.Top = 77
@p $statuslbl.Width = 299
@p $statuslbl.Height = 16
@p $statuslbl.Visible = 1
// We want the edit box to have the focus initially
@p $form.ActiveControl = $edit
@ $num = $rand(1000)
@ $tries = 1
Alias NUMBER_GUESS
@ $guess = $prop($edit.Text)
@ $tries = $($tries + 1)
if ($num > $guess)
@p $statuslbl.Caption = ($guess) The number is higher. Guess again.
@p $edit.Text =
else
if ($num < $guess)
@p $statuslbl.Caption = ($guess) The number is lower. Guess again.
@p $edit.Text =
else
if ($num == $guess)
@p $statuslbl.Caption = ($guess) Well done. You got the number in $tries tries.
@p $guessbtn.Enabled = 0
@p $cancelbtn.Caption = &Close
@p $edit.Text =
endif
endif
endif
EndAlias
Alias NUMBER_CANCEL
if ($guess != $num)
MessageBox Only losers give up. =] The number was $num.
endif
Destroy $form
EndAlias