lunes, 25 de junio de 2012

Programas/Varios: Balistica

Descripción del programa:
Simula la trayectoria del vuelo de un proyectil.
Datos de ejemplo:
Angulo:45
Gravedad (terrestre):9.8
Velocidad inicial (m/s):20
Tiempo (seg):0.1

Programa:

AmigoBasic V.1
1. Rem BALISTICA
2. Input a 'Angulo?'
3. Input g 'Gravedad?'
4. Input vi 'Velocidad inicial?'
5. Input tt 'Tiempo?'
6. t = 0
7. a = a * PI / 180
8. xc = Cos(a)
9. ys = Sin(a)
10. x = 1
11. y = 20
12. Do
13. Locate(x,y):Print '*',
14. t = t + tt
15. x = vi * xc * t
16. y1 = t ^ 2 / 2 * g
17. y2 = vi * ys * t
18. y = y1 - y2
19. x = Int(x)
20. y = Int(y)
21. x = x + 1
22. y = y + 20
23. Loop Until x < 1 Or x > 40 Or y < 1 Or y > 20

Programas/juegos: Simon


Descripción del programa: 
Intenta recordar la serie de números aleatorios que van apareciendo en la pantalla hasta llegar a 10!

Programa:

AmigoBasic V.1
1. Rem SIMON
2. For a = 1 To 10 Step 1
3. matrix1,a,1 = Rnd(1,4,true)
4. Next
5. For a = 1 To 10 Step 1
6. For b = 1 To a Step 1
7. Locate(,):Print '', matrix1,b,1
8. Pause(250)
9. Cls
10. Next
11. Buttons On
12. For b = 1 To a Step 1
13. Do
14. Loop Until but > 0
15. If matrix1,b,1 <> but Then
16. a = a - 1
17. Locate(,):Print 'Fallaste! Total numeros recordados ', a
18. Stop
19. End If
20. but = 0
21. Next
22. Buttons Off
23. Next
24. Locate(,):Print 'Muy bien! Recordaste los 10 numeros',

domingo, 24 de junio de 2012

Programas/Juegos: Acertijo

Descripción del programa:
Mediante preguntas, el programa adivina el número que hayamos pensado (1-999) en muy pocos intentos.

Programa:


AmigoBasic V.1
1. Message 'Piense un numero del 1 al 999'
2. h = 1000
3. l = 0
4. r = 500
5. t = 0
6. b = 1000
7. Do
8. t = t + 1
9. Input i 'El numero que ha pensado es Igual, Menor o Superior que ' r
10. If i = 's' Then
11. l = r
12. b = h - r
13. b = b / 2
14. b = Int(b)
15. r = r + b
16. End If
17. If i = 'm' Then
18. h = r
19. b = r - l
20. b = b / 2
21. b = Int(b)
22. r = r - b
23. End If
24. Loop Until i = 'i' Or b = 0
25. Locate(,):Print 'Lo he acertado, total intentos=', t

Vídeo AmigoBasic for Android

sábado, 23 de junio de 2012

Programas/Varios:Stars




Descripción del programa:
Se imprimen 800 estrellas por la pantalla en posiciones aleatorias.

Programa:

AmigoBasic V.1
1. For a = 1 To 800 Step 1
2. x = Rnd(1,40,true)
3. y = Rnd(1,20,true)
4. Locate(x,y):Print '*',
5. Next


Handbook in english








AmigoBasic for Android

Version 1


Jordi Sorroche Pérez
jsptron@gmail.com
Barcelona in June 2012






  



What is AmigoBasic? 
It is a programming language for high level (close to natural language)
especially designed for mobile platforms, further PM-as tablets and
smartphones.
It is inspired by the original Basic language (Beginners All-purpose Symbolic
Instruction Code), 1964, although as we shall see below, with significant
differences, especially in the edition of the program.
  
Who is it for? 
It is intended for all those people who want to learn to program and / or also to
those already initiated in the matter, who want to solve a problem in any place
and at any moment by the flexibility and convenience we provide the PM.  And
of course, for enthusiasts to programming.
  
Key features of AmigoBasic; Modules: 
In most programming languages, if not all, as the Basic, enter the instructions
for creating a program, we make them freely by an editor.  Unfortunately, this is
painfully slow and tedious when we do from a mobile or tablet, as most of them
have no physical keyboard and / or too small at their keyboards and screens.  In
addition, we must add the inconveniences which publishers when entering the
instructions and that the PM can be accentuated even more:  

  • We must remember the syntax of the instructions. 
  • We have to write it in the form and proper order. 
  • We do not know in advance the parameters of the same. 
  • High probability of committing syntax error misspelled. 
  • High probability of making incorrect parameter error. 
Given this, AmigoBasic had to have an intuitive editor, easy and fast, and the
overall operation of the program.
To overcome these drawbacks, the introduction of instructions performed by the
modules AmigoBasic.  Modules are forms in which the values that make a
particular statement is parameterized to form an expression (combination of
operands, operators, and data-operations to be performed-).  In other words, a
module is the sheet with a statement that contains all the necessary data to be
processed correctly.  In fact, the lines that make up a program modules are in
reality.

There are three types of modules: Input, Process and Output:

Input: 
Data entry, example: from the keyboard, buttons, etc ...

Process:
Data processing, example: math, conditions, etc ...

Output:
Data output, example: on screen, sound, etc ...

Thoroughly explained later operation of each module.

Operation and programming environment AmigoBasic: 
Wen running the screen will appear AmigoBasic editor-blue background and                                                                        
the legend of 'Ready!' - Indicating that we can begin programming.
 Pressing the Menu button, will show us the General Menu the following  
options:

Input Modules: 
Are represented in a list all the input modules.

Process Modules: 
In this option, displays the process modules.

Output Modules: 
Here we will output modules.

Run Program: 
We click on this option to run the program.

Edit Program: 
You can select four options:

Program List: 
With this option we can list the current program.

Delete Program: 
To delete the program we have loaded in memory PM.

Delete Module: 
Deletes a specific module of the program (prompts you to enter the line number
to delete).

Insert Module: 
This option allows us to insert a module between two lines, example if we want
to insert a module between lines one and two, simply enter the number two.

More: 
Here are seven options:
 
Load Program: 
Loads a program from the SD card installed in our PM to the memory of the
device.
You can also import a program from the email (for example).
To do this, open the e-mail in particular, save the attachment (the program) and
store it in the location (/ / SD), plain and simple.

Save Program: 
With this option will save the program we found created in the SD of our PM.
We can also export the program that we created by an email, for example.
To do this, we go to the-file option in her menu Android-(in the location / / SD)
and at the end of the list are all of our programs saved.  We choose what
interests us, and give the 'share-send mail Elec ..', as an attachment, that simple.

Save Program_List: 
It allows us to save the program readable format any text editor (on a PC or
even in PM), to be able to print if you so desire.  Because, if we view a program
previously saved with 'Save Program', would not understand anything, because
the program consists of codes that can only interpret AmigoBasic.

Save Screen: 
Save the image created by the last execution of the program (not visible
buttons).

Time Change Process: 
It gives us the possibility to change the processing time in the execution of a
program, in milliseconds between modules.  By default, is configured with a
value of 100, being able to change this value to at least 1 and up to 2000 (2
seconds). It is important to note that you should not abuse really short time,
since our device has to process other tasks other than ours, and this may lead to
malfunction of the program.  Without overheating and excessive consumption of
the battery.  It is advisable not to drop below 10 milliseconds.

Help (English/Spanish): 
Tutorial program performance in English / Spanish.

About AmigoBasic: 
About creating AmigoBasic.


Beginning programming with AmigoBasic: 
First, briefly explain the basics of programming, for those initiated into the
matter.
What is a program?
 A program is an ordered set of instructions that the computer will 'read' one
after another vertically-from top to bottom.  Most programs, if not all, are
composed of input, memory, process and output data.  For example, a program
introduced by multiply the number 9 would be something like:
Input to
b = a * 9
Print b
The first line would be a data input, then asks you to enter a number that is
assigned to variable 'a'.
The second line is the process, it multiplies the value of the variable 'a' by 9 and
assigned to variable 'b'.
And the third line would output data, as we print the value of 'b'.
The variables used would be the memory.  This simple, is the basis of any
program.
What you need to be clear before you start coding, it's like to face a particular
problem and structure as possible.  That is, by analogy, to build a house, start up
the walls and the roof.

Important: 
Fields marked with '*' are required.
Assignment variables are automatically converted to lowercase.
The constants PI and E are all uppercase.
String constants are enclosed in single quotes, example: 'name'
Both variables as the matrix are of the generic type, or may contain numbers or
strings.  Ex: a = 5 or a = 'hello'.
You must initialize the variables.
In our programs, we can use an array of two dimensions, always call: matrix1,
a, b, where 'a' index and 'b' the subscript of the table.
The maximum value for the array index is 999 for 5 of subscripts.
It is not necessary to initialize the values of the matrix.

Our first program written in AmigoBasic: 
Let's make a simple program which we call 'Hello_World'.
In the editor, press 'Menu', select the option Output Modules, and it will press
Screen / Print.  We will open the module relative to Print (Print Screen).  Fill the
box 'Text' with the phrase 'hello_world', immediately afterwards press the 'OK'
button.  Will appear in the editor our first line of program.  If you look, a little
above, tells us what position the next line inserted.  Now let's run it.  This will
press the key again 'Menu' then 'Run Program'.
 We see that the phrase appears on the screen that we introduced earlier: 'Hello
World _'.  Also displays a button labeled 'Esc' at the top left, with him we can
interrupt the execution of the program at any time, provided we are not in the
input (Input Module).  Logically, this button only appears when the program is
running.

Detailed information about the modules: 
Here we will explain the characteristics of each module: type location,
configuration, and the functions it performs:


Input Modules: 

Input 
Type: Data input from the keyboard.
Location: Menu / Input Modules / Keyboard / Input
1 º field: * Variable allocation
2 nd field: Text
3 rd field: Variable: Numeric value / string
Function: Responsible for collecting the data entered from the keyboard to
assign to the variable of 1 field.  Also shown are optionally display the text of
the 2nd field and / or value of the variable on the 3 rd field and waits for you to
press a button.

Message 
Type: Input data from button
Location: Menu / Input Modules / Button / Message
1 º field: Text
2 nd field: Variable: Numeric value / string
Function: Displays text from 1 field and the value of the variable from 2 ° field
and waits for you to press a button.

Buttons On 
Type: Input data from button
Location: Menu / Input Modules / Buttons On
Direct input.
Function: Display can display four buttons control which button was pressed by
the system variable but.
These are the values returned by the variable but when one of the four buttons:
Button1 = 1, boton2 = 2, 3 and boton3 = Button4 = 4.  To initialize but, we use
the value 0: but = 0.

Buttons Off 
Type: Input data from button
Location: Menu / Input Modules / Off Buttons
Direct input.
Function: They disappear from the screen the four buttons.


Process Modules: 

Rem 
Type: Process / Rem
Location: Menu / Process Modules / Rem
1 º field: * Text
Operation: there is no process is simply a text that will help us discuss the
different lines of our program.

Stop 
Type: Process / Stop
Location: Menu / Process Modules / Stop
Direct input.
Function: Stops the program execution.

Pause 
Type: Process / Pause
Location: Menu / Process Modules / Pause
1 º field: * Constant: Numeric value
Function: Stops the program execution for the specified time on 1 field in
milliseconds.

Let 
Type: Process / Assignment
Location: Menu / Process Modules / Let
1 º field: * Variable allocation
2 nd field: * Variable / Constant: Numeric value / string
Function: Assigns the value of 2 ° field with the variable of 1 field.

Math / Operators 
Type: Process / Math / Operators
Location: Menu / Process Modules / Math / Operators
1 º field: * Variable allocation
2 nd field: * Variable / Constant: Numeric value
3 rd field: * Variable / Constant: Numeric value
4 th field: * Self-expression
Function: We select an operator to perform the calculation between 2 º and 3 º
field.  Clicking the Insert button, the previous result is added to the 4 th field,
adding more stones at a time if you like.  The value of the 4 th field is assigned
to the variable of 1 field.
Operators: +, -, *, /, ^
The order of processing for calculation is from left to right.
Parentheses are not allowed.

Math / Functions 
Type: Process / Math / Functions
Location: Menu / Process Modules / Math / Functions
1 º field: * Variable allocation
2 nd field: * Variable: A numeric value
Function: We select a function to perform for the variable value of the 2 nd half.
The return value is assigned the variable to 1 field.
Features:
Sqr: is the square root.
Int: returns the integer
Abs: turns a negative into a positive value.
Log: gives the logarithm to base 10.
Exp: raises the number mathematician E.
Sin: returns the sine.
Cos: gives the cosine.
Tan: returns the tangent.
Atn: gives the arc tangent.

Rnd 
Type: Process / Math / Random
Location: Menu / Process Modules / Math / Rnd
1 º field: * Variable allocation
2 nd field: * Variable / Constant: Numeric value
3 rd field: * Variable / Constant: Numeric value
Function: sets the variable to 1 field a random number between the ranges of 2
and 3 field.
With the option Integer, you can specify whether or not we want to decimal.
  
If ... Then 
Type: Process / Conditional
Location: Menu / Process Modules / Condition / If ... Then
1 º field: * Variable: Numeric value / string
2 nd field: * Variable / Constant: Numeric value / string
3 rd field: * Self-expression
Function: We select a relational operator to determine the values of 1 and 2
field.  Also, optionally, will choose the logical operator to build the condition.
Clicking the Insert button, the above condition is added to 3 ° field, adding more
conditions at once if you like.
Relational operator: =, <>, <,>, <=,> =
Logical operator: And, Or, Xor, Not
The order of process conditions is from left to right.
Parentheses are not allowed.

Else 
Type: Process / Conditional
Location: Menu / Process Modules / Condition / Else
Direct input.
Function: If the condition preceded by If ... Then is not met, the modules are
processed just under Else.

End If 
Type: Process / Conditional
Location: Menu / Process Modules / Condition / End If
Direct input.
Function: ends the conditional If...Then / Else.

For 
Type: Process / Loop
Location: Menu / Process Modules / Loop / For
1 º field: * Variable allocation
2 nd field: * Variable / Constant: Numeric value
3 rd field: * Variable / Constant: Numeric value
4 th field: * Variable / Constant: Numeric value
Function: performs a For ... Next loop, since the value of 2 ° to 3 ° field value
with increases in the value of the 4 th field, and finally assign it to the variable of
1 field.

Next 
Type: Process / Loop
Location: Menu / Process Modules / Loop / Next
Direct input.
Function: close the loop For ... Next.

Exit For 
Type: Process / Loop
Location: Menu / Process Modules / Loop / Exit For
Direct input.
Function: exit the For ... Next loop.

Do 
Type: Process / Loop
Location: Menu / Process Modules / Loop / Do
Direct input.
Function: Starts the Do ... Loop Until loop.

Until Loop 
Type: Process / Loop
Location: Menu / Process Modules / Loop / Loop Until
1 º field: * Variable: Numeric value / string
2 nd field: * Variable / Constant: Numeric value / string
3 rd field: * Self-expression
Function: using a combo you can select the relational operator to determine the
values of 1 and 2 field.  Also, optionally, in a 2nd combo, will choose the logical
operator to build the condition.  Clicking the Insert button, the above condition
is added to 3 ° field, adding more conditions at once if you like.
Relational operator: =, <>, <,>, <=,> =
Logical Operator: And, Or, Xor, Not
The order of process conditions is from left to right.
Parentheses are not allowed.

Exit Do 
Type: Process / Loop
Location: Menu / Process Modules / Loop / Exit Do
Direct input.
Function: Loop Until loop exits.

Mid 
Type: Process / String
Location: Menu / Process Modules / String / Mid
1 º field: * Variable allocation
2 nd field: * Variable / Constant: Value String
3 rd field: * Variable / Constant: Numeric value
4 th field: * Variable / Constant: Numeric value
Function: Select the string value of field 2 ° the characters from the value of 3 °
to 4 ° field value to assign to the variable of 1 field.

String / Functions 
Type: Process / String
Location: Menu / Process Modules / String / Functions
1 º field: * Variable allocation
2 nd field: * Variable / Constant: Numeric value / string
Function: We select the function to perform for the value of 2 ° field.  The
return value is assigned the variable to 1 field.
Features:
Length: Returns the character length
Chr: gives a character code value corresponding to the numeric ASCII
       (American  Standard  Code  for Information Interchange).
Asc: returns a number corresponding to the ASCII character code

Concatenate 
Type: Process / String
Location: Menu / Process Modules / String / Concatenate
1 º field: * Variable allocation
2 nd field: * Variable / Constant: Value String
3 rd field: * Variable / Constant: Value String
4 th field: * Self-expression
Function: we concatenate the field values 2 º and 3 º pressing the Insert button.
The union of the strings are added to the 4 th field, adding more linkages at a
time if you like. The value of the 4 th field is assigned to the variable of 1 field.
The process order for the concatenations is from left to right.
Parentheses are not allowed.

Sub 
Type: Process / Subroutine
Location: Menu / Process Modules / Subrutine / Sub
1 º field: * Text
Function: subroutine names the Sub ... End Sub.

End Sub 
Type: Process / Subroutine
Location: Menu / Process Modules / Subrutine / End Sub
Direct input.
Function: Ends the subroutine Sub ... End Sub.

Call 
Type: Process / Subroutine
Location: Menu / Process Modules / Subrutine / Call
1 º field: * Text
Function: call the subroutine with the name of 1 field.

Exit Sub 
Type: Process / Subroutine
Location: Menu / Process Modules / Subrutine / Exit Sub
Direct input.
Function: exit the subroutine Sub ... End Sub.

Point 
Type: Process / Display
Location: Menu / Process Modules / Screen / Point
1 º field: * Variable allocation
2 nd field: * Variable / Constant: Numeric value
3 rd field: * Variable / Constant: Numeric value
Function: Checks if a character printed on the screen in the X (value of 2 ° field)
and Y (value of 3 ° field).  If yes, assign the variable to 1 field the value of True.
The opposite is False.
  

Output Modules: 

Print 
Type: Output / Display
Location: Menu / Output Modules / Screen / Print
1 º field: Text
2 nd field: Variable: Numeric value / string
3 rd field: Variable / Constant: Numeric value
4 th field: Variable / Constant: Numeric value
Function: prints out the text from 1 field with the value of the 2nd field in the X
(3 ° field) and Y (4 ° field)-optional.

Cls 
Type: Output / Display
Location: Menu / Output Modules / Screen / Cls
Direct input.
Function: Clears the screen.

Color Paper 
Type: Output / Display
Location: Menu / Output Modules / Screen / Color Paper
1 º field: Variable / Constant: Numeric value
Function: Defines the background color for the value of 1 field to the following
code:
0 = black       1 = dark gray       2 = medium gray  3 = light gray
4 = red          5 = green              6 = blue               7 = yellow
8 = magenta     9 = cyan           10 = white

Color Ink 
Type: Output / Display
Location: Menu / Output Modules / Screen / Color Ink
1 º field: Variable / Constant: Numeric value
Function: Set the text color for the value of 1 field to the following code:
0 = black       1 = dark gray       2 = medium gray  3 = light gray
4 = red          5 = green              6 = blue              7 = yellow
8 = magenta   9 = cyan             10 = white

Beep 
Type: Output / Sound
Location: Menu / Output Modules / Sound / Beep
Direct input.
Function: generates a sound of short duration.



List of errors 
No. 1: No program in memory.
No. 2: The variable x is not initialized.
No. 3: If ... Then without Else or End If.
No. 4: Else without End If.
No. 5: You can only determine between numbers.
No. 6: Loop without Do.
No. 7: For without Next.
No. 8: Next without For.
No. 9: The Subroutine x does not exist.
No. 10: End  Sub without Call.
No. 11: You have exceeded the maximum allowed nested subroutines (99).
No. 12: Exit  For without Next.
No. 13: Exit Do without Loop Until.
No. 14: Exit Sub without Call.
No. 15: Error processing overhead.
No. 16: You have exceeded the maximum allowed of variables (99).
No. 17: You have reached the maximum permitted modules (199).

Manual de instrucciones en español













AmigoBasic for Android

Versión 1


Jordi Sorroche Pérez
jsptron@gmail.com
Barcelona Junio 2012











¿Qué es AmigoBasic?
Es un lenguaje de programación de alto nivel (próximo al lenguaje natural) especialmente 
diseñado para plataformas móviles –más adelante PM- como tabletas y smartphones.
Está inspirado en el original lenguaje Basic (Beginners All-purpose Symbolic Instruction Code) 
de 1964, aunque –como veremos más adelante-, con importantes diferencias, sobre todo, en la 
edición del programa.

¿A quién va dirigido?
Va dirigido para  todas aquellas personas que quieran aprender a programar y/o también a los 
ya iniciados en la materia, que quieran resolver un problema en cualquier lugar y en cualquier 
momento –por la flexibilidad  y comodidad que nos brindan las PM-. Y como no, para los 
entusiastas a la programación.

Características principales de AmigoBasic; los Módulos:
En la mayoría de lenguajes de programación –por no decir todos- como el Basic, las 
instrucciones que introducimos para la creación de un programa, éstas las hacemos libremente 
mediante un editor. Lamentablemente, esto es exasperadamente lento y tedioso cuando lo 
hacemos desde un móvil o tableta, ya que la mayoría de ellos, no disponen de teclado físico y/o 
también por lo pequeños de sus teclados y pantallas. Además, hay que sumarle los 
inconvenientes propios de los editores a la hora de introducir las instrucciones y que en las PM 
se pueden acentuar aún más:
  • Debemos acordarnos de la sintaxis de las instrucciones.
  • Tenemos que escribirlo en la forma y orden correcto.
  • No conocemos de antemano la parametrización de los mismos.
  • Probabilidad alta de cometer error por sintaxis mal escrita.
  • Probabilidad alta de cometer error por parametrización incorrecta.
Dado este panorama, AmigoBasic tenía que disponer de un editor intuitivo, fácil y rápido, así 
como el funcionamiento global del programa.
Para subsanar estos inconvenientes, la introducción de las instrucciones con AmigoBasic la 
realizamos mediante Módulos. Los Módulos son formularios en el que los valores que 
componen una instrucción determinada están parametrizados para formar una expresión 
(combinación de operandos -los datos- y operadores -las operaciones a realizar-). En otras 
palabras, un Módulo es la ficha completa de una instrucción que contiene todos los datos 
necesarios para que pueda ser procesada correctamente. De hecho, las líneas que componen un 
programa son en realidad Módulos.

Existen tres tipos de Módulos: Input, Process y Output:

Input:
Entrada de datos, p.e:. desde el teclado, botones, etc...

Process:
Procesamiento de datos, p.e.: cálculos matemáticos, condiciones, etc...

Output:
Salida de datos, p.e.: por pantalla, sonido, etc...
Más adelante se explicará exhaustivamente el funcionamiento de cada Módulo.


Funcionamiento y entorno de programación de AmigoBasic:
Al ejecutar AmigoBasic nos aparecerá la pantalla del editor –con fondo azul y con la leyenda 
de 'Ready!'- indicándonos que podemos comenzar a programar.

Pulsando el botón 'Menú', nos aparecerá  el Menú General con las siguientes opciones:

Input Modules:
Se representan en una lista todos los Módulos de entrada.

Process Modules:
En esta opción, se visualizan los Módulos de proceso.

Output Modules:
Aquí nos aparecerán los módulos de salida.

Run Program:
Pulsaremos sobre esta opción para ejecutar el programa.


Edit Program:
Podemos seleccionar cuatro opciones:

List Program:
Con esta opción podemos listar el programa en pantalla.

Delete Program:
Para eliminar el programa que tengamos cargado en la memoria de la PM.

Delete Module:
Permite eliminar un módulo concreto del programa (nos pedirá que introduzcamos el número 
de línea a eliminar).

Insert Module:
Esta opción nos permite intercalar un módulo entre dos líneas, p.e. si queremos insertar un 
módulo entre las líneas uno y dos, bastará con introducir el número dos.


More:
Aquí tenemos siete opciones:
    
Load Program:
Permite cargar un programa desde la tarjeta SD instalada en nuestra PM a la memoria del 
dispositivo.
También podemos importar un programa desde el correo electrónico (por ejemplo).
Para ello, abrimos el e-mail en concreto, guardamos el archivo adjunto (el programa) y lo 
guardamos en la ubicación (//SD), así de simple.

Save Program:
Con esta opción, podremos guardar el programa que hallamos creado en la tarjeta SD de 
nuestra PM.
También podemos exportar el programa que hayamos creado mediante un correo electrónico, 
por ejemplo.
Para ello, nos vamos a la opción de archivos –en le menú de Android- (en la ubicación //SD) y 
al final de la lista aparecerán todos nuestros programas salvados. Escogemos el que nos 
interesa, y le damos la opción 'compartir-enviar correo Elec..', como archivo adjunto, así de 
sencillo.

Save Program_List:
Nos permite salvar el programa con formato legible para cualquier editor de textos (en un PC o 
incluso en PM), para poderlo imprimir si así lo deseamos. Ya que, si quisiéramos visualizar un 
programa guardado con anterioridad con la opción 'Save Program', no entenderíamos nada, ya 
que el programa está compuesto por códigos que sólo puede interpretar AmigoBasic.

Save Screen:
Guarda la imagen creada por la última ejecución del programa, (no serán visibles los botones).

Change Time Process:
Nos brinda la posibilidad de cambiar el tiempo de proceso en la ejecución de un programa -en 
milisegundos- entre módulo y módulo. Por defecto, viene parametrizado con valor de 100, 
pudiéndose cambiar este valor a un mínimo de 1 y un máximo de 2000 ( 2 segundos). Es 
importante remarcar que no se debe abusar de tiempos realmente cortos, ya que nuestro 
dispositivo tiene que procesar otras tareas aparte de las nuestras, y que esto puede conllevar al 
mal funcionamiento del programa. Sin contar del sobrecalentamiento y a un consumo excesivo 
de la batería. Es recomendable no bajar de los 10 milisegundos.

Help (English/Spanish):
Tutorial del funcionamiento del programa en inglés/español.

About AmigoBasic:
Acerca de la creación de AmigoBasic.


Empezando a programar con AmigoBasic:
Antes que nada, explicaré brevemente los fundamentos de la programación –para los iniciados 
en la materia-.
¿Qué es un programa?
Un programa es una serie de instrucciones ordenadas que el computador va 'leyendo' una tras 
otra en sentido vertical –de arriba a bajo-. La mayoría de programas –por no decir todos-están 
compuestos por Entrada, Memoria, Proceso y Salida de datos. Por ejemplo, un programa que 
multiplicase el numero introducido por 9 sería algo así:
Input a
b=a*9
Print b
La primera línea sería una Entrada de datos, pues nos pide que introduzcamos un numero que 
será asignado a la variable 'a'.
La segunda línea es el Proceso, pues multiplica el valor de la variable 'a' por el 9 y la asigna a 
la variable 'b'.
Y la tercera línea sería de Salida de datos, ya que nos imprime el valor de 'b'.
Las variables utilizadas serían la Memoria. Esto tan simple, es la base de todo programa.
Lo que hay que tener bien claro antes de empezar a programar, es como afrontar un 
determinado problema y estructurarlo lo máximo posible. Es decir, por analogía, al construir 
una casa, hay que empezar por las paredes y no por el tejado.

Importante:
Los campos marcados con '*' son obligatorios.
Las variables de asignación son convertidas en minúsculas automáticamente.
Las constantes como PI y E se escriben en mayúsculas.
Las constantes de cadena se escriben entre comillas simple, ejem: 'nombre'
Tanto las variables como la matriz son del tipo genéricos, o sea, pueden contener números o 
cadenas. Ejem: a=5 o a='hola'.
Es necesario inicializar las variables.
En nuestros programas, podemos utilizar una matriz de dos dimensiones, la llamaremos 
siempre: matrix1,a,b, siendo 'a' el índice y 'b' el subíndice de la tabla.
El valor máximo de índices para la matriz es de 999 por 5 de subíndices.
No es necesario inicializar los valores de la matriz.

Nuestro primer programa escrito en AmigoBasic:
Vamos hacer un sencillo programa al que llamaremos 'Hola _ Mundo'.
En el editor, pulsamos 'Menú', seleccionamos la opción Output Modules, y en ella pulsaremos 
sobre Screen/Print. Se nos abrirá el formulario concerniente al Módulo Print (Imprimir en 
pantalla). Rellenamos la casilla 'Text' con la frase 'Hola_Mundo', acto seguido pulsamos el 
botón 'Ok'. Nos aparecerá en el editor nuestra primera línea de programa. Si nos fijamos, un 
poco más arriba, nos indica en que posición se insertará la próxima línea. Ahora vamos a 
ejecutarlo. Para ello, pulsaremos nuevamente la tecla 'Menú' y a continuación 'Run Program'.
Vemos que aparece en pantalla la frase que habíamos introducido anteriormente: 'Hola _ 
Mundo'. También, se visualiza un botón con la leyenda 'Esc' en la esquina superior izquierda, 
con él podemos interrumpir la ejecución del programa en cualquier momento, siempre y 
cuando no estemos en la introducción de datos (Módulo Input). Lógicamente, este botón sólo 
aparece cuando el programa se está ejecutando.

Información detallada de los Módulos:
Aquí vamos a explicar las características de cada Módulo: tipo ubicación, parametrización, y 
las funciones que realiza:


Módulos de Entrada:

Input
Tipo: Entrada de datos desde el teclado.
Ubicación: Menu/Input Modules/Keyboard/Input
1º campo: * Variable de asignación
2º campo: Texto
3º campo: Variable: Valor numérico / cadena
Función: Se encarga de recoger los datos introducidos desde el teclado para asignarlo a la 
variable del 1º campo. También se representan en pantalla opcionalmente el texto del 2º campo 
y/o del valor de la variable del 3º campo y espera a que se pulse un botón.

Message
Tipo: Entrada de datos desde botón
Ubicación: Menu/Input Modules/Button/Message
1º campo: Texto
2º campo: Variable: Valor numérico/cadena
Función: Muestra en pantalla el texto del 1º campo y del valor de la variable del 2º campo y 
espera a que se pulse un botón.

Buttons On
Tipo: Entrada de datos desde botón
Ubicación: Menu/Input Modules/Buttons On
Introducción directa.
Función: Se muestran en pantalla cuatro botones pudiendo controlar que botón ha sido pulsado 
gracias a la variable del sistema but.
Estos son los valores que devuelve la variable but al pulsar uno de los cuatro botones:
Boton1=1, boton2=2, boton3=3 y boton4=4. Para inicializar but, podemos usar el valor 0: 
but=0.

Buttons Off
Tipo: Entrada de datos desde botón
Ubicación: Menu/Input Modules/Buttons Off
Introducción directa.
Función: Desaparecen de la pantalla los cuatro botones.


Módulos de Proceso:

Rem
Tipo: Proceso/Comentario
Ubicación: Menu/Process Modules/Rem
1º campo: * Texto
Funcionamiento: no hay proceso alguno, simplemente es un texto que nos ayudaran a comentar 
las diferentes líneas de nuestro programa. 

Stop
Tipo: Proceso/Parada
Ubicación: Menu/Process Modules/Stop
Introducción directa.
Función: detiene la ejecución del programa.

Pause
Tipo: Proceso/Pausa
Ubicación: Menu/Process Modules/Pause
1º campo: * Constante: Valor numérico
Función: detiene la ejecución del programa durante el tiempo especificado en el 1º campo 
expresado en milisegundos.

Let
Tipo: Proceso/Asignación
Ubicación: Menu/ Process Modules /Let
1º campo: * Variable de asignación
2º campo: * Variable/Constante: Valor numérico/cadena
Función: asigna el valor del 2º campo a la variable del 1º campo.

Math/Operators
Tipo: Proceso/Matemático/Operadores
Ubicación: Menu/ Process Modules/Math/Operators
1º campo: * Variable de asignación
2º campo: * Variable/Constante: Valor numérico
3º campo: * Variable/Constante: Valor numérico
4º campo: * Autoexpresión
Función: Podremos seleccionar un operador para realizar el calculo entre el 2º y el 3º campo. 
Pulsando el botón Insert, el resultado anterior se añadirá al 4º campo, agregando más cálculos a 
la vez si así lo deseamos. El valor del 4º campo se asigna a la variable del 1º campo.
Operadores: +, -, *, /, ^
El orden de proceso para los cálculos es de izquierda a derecha.
No son permitidos los paréntesis.

Math/Functions
Tipo: Proceso/Matemático/Funciones
Ubicación: Menu/ Process Modules/Math/Functions
1º campo: * Variable de asignación
2º campo: * Variable: Valor numérico
Función: Podremos seleccionar una función a realizar para el valor de la variable del 2º campo. 
El valor devuelto se asigna la variable del 1º campo.
Funciones:
Sqr: halla la raíz cuadrada.
Int: devuelve el íntegro
Abs: convierte un valor negativo en positivo.
Log: da el logaritmo en base 10.
Exp: eleva al número matemático E.
Sin: devuelve el seno.
Cos: da el coseno.
Tan: devuelve la tangente.
Atn: da el arco tangente.

Rnd
Tipo: Proceso/Matemático/Aleaotrio
Ubicación: Menu/ Process Modules/Math/Rnd
1º campo: * Variable de asignación
2º campo: * Variable/Constante: Valor numérico
3º campo: * Variable/Constante: Valor numérico
Función: asigna a la variable del 1º campo un número aleatorio comprendidos entre los rangos 
del 2º y 3º campo.
Mediante la opción Integer, podemos especificar si queremos decimales o no.


If...Then
Tipo: Proceso/Condicional
Ubicación: Menu/ Process Modules/ Condition/If…Then
1º campo: * Variable: Valor numérico/cadena
2º campo: * Variable/Constante: Valor numérico/cadena
3º campo: * Autoexpresión
Función: Podremos seleccionar un operador relacional para condicionar los valores del 1º y 2º 
campo. Además, opcionalmente, escogeremos el operador lógico para construir la condición. 
Pulsando el botón Insert, la condición anterior se añadirá al 3º campo, agregando más 
condiciones a la vez si así lo deseamos.
Operador relacional: =, <>, <, >, <=, >=
Operador lógico: And, Or, Xor, Not
El orden de proceso para las condiciones es de izquierda a derecha.
No son permitidos los paréntesis.

Else
Tipo: Proceso/Condicional
Ubicación: Menu/ Process Modules/ Condition/Else
Introducción directa.
Función: si la condición precedida de If...Then no se cumple, se procesan los Módulos justo por 
debajo de Else.

End If
Tipo: Proceso/Condicional
Ubicación: Menu/ Process Modules/ Condition/End If
Introducción directa.
Función: acaba con el condicional If...Then/Else.

For
Tipo: Proceso/Bucle
Ubicación: Menu/ Process Modules/Loop/For
1º campo: * Variable de asignación
2º campo: * Variable/Constante: Valor numérico
3º campo: * Variable/Constante: Valor numérico
4º campo: * Variable/Constante: Valor numérico
Función: efectúa un bucle For...Next, desde el valor del 2º hasta el valor del 3º campo con 
incrementos del valor del 4º campo, para finalmente asignarlo a la variable del 1º campo. 

Next
Tipo: Proceso/Bucle
Ubicación: Menu/ Process Modules/ Loop/Next
Introducción directa.
Función: acaba con el bucle For...Next.

Exit For
Tipo: Proceso/Bucle
Ubicación: Menu/ Process Modules/ Loop/Exit For
Introducción directa.
Función: sale del bucle For...Next.

Do
Tipo: Proceso/Bucle
Ubicación: Menu/ Process Modules/Loop/Do
Introducción directa.
Función: inicia el bucle Do...Loop Until.

Loop Until
Tipo: Proceso/Bucle
Ubicación: Menu/ Process Modules/ Loop/Loop Until
1º campo: * Variable: Valor numérico/cadena
2º campo: * Variable/Constante: Valor numérico/cadena
3º campo: * Autoexpresión
Función: mediante un combo podemos seleccionar el operador relacional para condicionar los 
valores del 1º y 2º campo. Además, opcionalmente, en un 2º combo, escogeremos el operador 
lógico para construir la condición. Pulsando el botón Insert, la condición anterior se añadirá al 
3º campo, agregando más condiciones a la vez si así lo deseamos.
Operador relacional: =, <>, <, >, <=, >=
Operador lógico: And, Or, Xor, Not
El orden de proceso para las condiciones es de izquierda a derecha.
No son permitidos los paréntesis.

Exit Do
Tipo: Proceso/Bucle
Ubicación: Menu/ Process Modules/Loop/Exit Do
Introducción directa.
Función: sale del bucle Loop Until.

Mid
Tipo: Proceso/Cadena
Ubicación: Menu/ Process Modules/String/Mid
1º campo: * Variable de asignación
2º campo: * Variable/Constante: Valor de cadena
3º campo: * Variable/Constante: Valor numérico
4º campo: * Variable/Constante: Valor numérico
Función: selecciona del valor de la cadena del campo 2º los caracteres desde el valor del 3º 
hasta el valor del 4º campo para asignarlo a la variable del 1º campo. 

String/Functions
Tipo: Proceso/Cadena
Ubicación: Menu/ Process Modules/String/Functions
1º campo: * Variable de asignación
2º campo: * Variable/Constante: Valor numérico/cadena
Función: Podremos seleccionar la función a realizar para el valor del 2º campo. El valor 
devuelto se asigna la variable del 1º campo.
Funciones:
Length: devuelve la longitud de caracteres
Chr: da un carácter correspondiente al valor del código numérico ASCII (American Standar 
Code for Information Interchange).
Asc: devuelve un número correspondiente al código de carácter ASCII

Concatenate
Tipo: Proceso/Cadena
Ubicación: Menu/ Process Modules/ String/Concatenate
1º campo: * Variable de asignación
2º campo: * Variable/Constante: Valor de cadena
3º campo: * Variable/Constante: Valor de cadena
4º campo: * Autoexpresión
Función: podemos concatenar los valores de los campos 2º y el 3º pulsando el botón Insert. La 
unión de las cadenas se añadirá al 4º campo, agregando más concatenaciones a la vez si así lo 
deseamos. El valor del 4º campo se asigna a la variable del 1º campo.
El orden de proceso para las concatenaciones es de izquierda a derecha.
No son permitidos los paréntesis.

Sub
Tipo: Proceso/Subrutina
Ubicación: Menu/ Process Modules/Subrutine/Sub
1º campo: * Texto
Función: nombra a la subrutina Sub...End Sub.

End Sub
Tipo: Proceso/Subrutina
Ubicación: Menu/ Process Modules/Subrutine/End Sub
Introducción directa.
Función: finaliza la subrutina Sub...End Sub.

Call
Tipo: Proceso/Subrutina
Ubicación: Menu/ Process Modules/Subrutine/Call
1º campo: * Texto
Función: llama a la subrutina con el nombre del 1º campo.

Exit Sub
Tipo: Proceso/Subrutina
Ubicación: Menu/ Process Modules/Subrutine/Exit Sub
Introducción directa.
Función: sale de la subrutina Sub...End Sub.

Point
Tipo: Proceso/Pantalla
Ubicación: Menu/ Process Modules/Screen/Point
1º campo: * Variable de asignación
2º campo: * Variable/Constante: Valor numérico
3º campo: * Variable/Constante: Valor numérico
Función: comprueba si existe un carácter impreso en la pantalla en las coordenadas X (valor 
del 2º campo) e Y (valor del 3º campo). Si es afirmativo, asignará a la variable del 1º campo el 
valor de True. Lo contrario será False.


Módulos de Salida:

Print
Tipo: Salida/Pantalla
Ubicación: Menu/ Output Modules/Screen/Print
1º campo: Texto
2º campo: Variable: Valor numérico/cadena
3º campo: Variable/Constante: Valor numérico
4º campo: Variable/Constante: Valor numérico
Función: imprime en la pantalla el texto del 1º campo junto con el valor del 2º campo en las 
coordenadas X (3º campo) e Y (4º campo) –opcional-.

Cls
Tipo: Salida/Pantalla
Ubicación: Menu/ Output Modules/Screen/Cls
Introducción directa.
Función: borra la pantalla.

Color Paper
Tipo: Salida/Pantalla
Ubicación: Menu/ Output Modules/Screen/Color Paper
1º campo: Variable/Constante: Valor numérico
Función: define el color de fondo para el valor del 1º campo según el siguiente código:
0 = negro        1 = gris oscuro 2 = gris medio 3 = gris claro
4 = rojo          5 = verde 6 = azul          7 = amarillo
8 = magenta 9 = cian       10 = blanco

Color Ink
Tipo: Salida/Pantalla
Ubicación: Menu/ Output Modules/Screen/Color Ink
1º campo: Variable/Constante: Valor numérico
Función: define el color del texto para el valor del 1º campo según el siguiente código:
0 = negro        1 = gris oscuro   2 = gris medio 3 = gris claro
4 = rojo          5 = verde 6 = azul          7 = amarillo
8 = magenta 9 = cian       10 = blanco

Beep
Tipo: Salida/Sonido
Ubicación: Menu/ Output Modules/Sonido/Beep
Introducción directa.
Función: genera un sonido de corta duración.





Listado de errores
Nº1:  No hay programa en memoria.
Nº2:  La variable x no se ha inicializado.
Nº3:  If...Then sin Else o End If.
Nº4:  Else sin End If.
Nº5:  Sólo se puede condicionar entre números.
Nº6:  Loop sin Do.
Nº7:  For sin Next.
Nº8:  Next sin For.
Nº9:  La Subrutina x no existe.
Nº10: End Sub sin Call.
Nº11: Se ha superado el máximo permitido de subrutinas anidadas (99).
Nº12: Exit For sin Next.
Nº13: Exit Do sin Loop Until.
Nº14: Exit Sub sin Call.
Nº15: Error general de proceso.
Nº16: Se ha superado el máximo permitido de variables (99).
Nº17: Se ha llegado al máximo de Módulos permitidos (199).