Microsoft Small Basic
Program Listing:
Embed this in your website
<object id='sbapp' data='data:application/x-silverlight-2,' type='application/x-silverlight-2' width='640' height='480'> <param name='source' value='http://smallbasic.com/program/ClientBin/SBWeb.xap'/> <param name='onError' value='onSilverlightError' /> <param name='background' value='white' /> <param name='minRuntimeVersion' value='3.0.40624.0' /> <param name='autoUpgrade' value='true' /> <param name='initParams' value='programId=CCG458' /> </object>
posicaoX
=
1
texto
=
""
linha
=
1
flagCaps
=
1
maxLinhas
=
10
arquivoEndereco
=
"arquivo.txt"
For
i
=
1
To
maxLinhas
Array
.
SetValue
(
"linha"
,
i
,
""
)
EndFor
GraphicsWindow
.
KeyDown
=
OnKeyDown
GraphicsWindow
.
Title
=
"Edit"
GraphicsWindow
.
FontSize
=
12
comandosTopo
(
)
Sub
OnKeyDown
texto
=
Array
.
GetValue
(
"linha"
,
linha
)
strKey
=
GraphicsWindow
.
LastKey
If
(
strKey
=
"Back"
)
Then
texto
=
Text
.
GetSubText
(
texto
,
0
,
Text
.
GetLength
(
texto
)
-
1
)
Array
.
SetValue
(
"linha"
,
linha
,
texto
)
If
(
Text
.
GetLength
(
texto
)
=
0
)
Then
linha
=
linha
-
1
If
(
linha
=
0
)
Then
linha
=
1
EndIf
EndIf
ElseIf
(
strKey
=
"Space"
)
Then
texto
=
texto
+
" "
Array
.
SetValue
(
"linha"
,
linha
,
texto
)
ElseIf
(
strKey
=
"Return"
)
Then
linha
=
linha
+
1
If
(
linha
>
maxLinhas
)
Then
GraphicsWindow
.
ShowMessage
(
"Maximo de "
+
maxLinhas
+
" linhas"
,
"Atencao"
)
EndIf
ElseIf
(
strKey
=
"Tab"
)
Then
texto
=
texto
+
" "
' 2 espacos
Array
.
SetValue
(
"linha"
,
linha
,
texto
)
ElseIf
(
strKey
=
"F1"
)
Then
linha
=
1
limpaLinhas
(
)
ElseIf
(
strKey
=
"F2"
)
Then
Buffer
=
""
for
i
=
1
To
linha
Buffer
=
Buffer
+
Array
.
GetValue
(
"linha"
,
i
)
Buffer
=
Buffer
+
Text
.
GetCharacter
(
13
)
EndFor
' The following line could be harmful and has been automatically commented.
' resultado = File.WriteContents(arquivoEndereco, Buffer)
If
(
resultado
=
"SUCCESS"
)
Then
GraphicsWindow
.
ShowMessage
(
"Arquivo "
+
arquivoEndereco
+
" salvo com sucesso"
,
"Informacao"
)
linha
=
1
limpaLinhas
(
)
Else
'
GraphicsWindow
.
ShowMessage
(
"Erro ao salvar"
,
"Informacao"
)
EndIf
ElseIf
(
strKey
=
"Capital"
)
Then
flagCaps
=
flagCaps
*
(
-
1
)
ElseIf
(
strKey
=
"Escape"
)
Then
Program
.
End
(
)
Else
if
(
flagCaps
>
0
)
then
texto
=
texto
+
Text
.
ConvertToLowerCase
(
strKey
)
else
texto
=
texto
+
Text
.
ConvertToUpperCase
(
strKey
)
endif
Array
.
SetValue
(
"linha"
,
linha
,
texto
)
EndIf
'Limpa tela
GraphicsWindow
.
Clear
(
)
comandosTopo
(
)
'Escreve Linhas que estao na memoria
For
i
=
1
To
maxLinhas
texto
=
Array
.
GetValue
(
"linha"
,
i
)
GraphicsWindow
.
DrawText
(
posicaoX
,
i
*
12
,
texto
)
EndFor
EndSub
Sub
comandosTopo
GraphicsWindow
.
DrawText
(
1
,
1
,
"F1-NOVO F2-SALVAR ESC-SAIR"
)
EndSub
Sub
limpaLinhas
For
i
=
1
To
maxLinhas
Array
.
SetValue
(
"linha"
,
i
,
""
)
EndFor
EndSub
Copyright (c) Microsoft Corporation. All rights reserved.