1 – GENERALS |
1.1 - What is the structure of a program? The adviced structure of a program is as follow: 1 - Statement: LABEL and DIM 2 - Main program: definition of components (objects), calculations, behaviour, END 3 - Events handling Example : create a button displaying "Clic on me", then "Hello!" when it is clicked. rem
declaration of used labels rem
declaration of used variables rem
--- MAIN PROGRAM --- rem
--- END OF MAIN PROGRAM--- rem
--- EVENT HANDLING --- |
2 - 3D WORLD |
2.1- How to create a 3D world? 1 - First of all, create an object to display your 3D world with the keyword scene3d and give it a number: scene3d 1 Then, a 3D camera and a 3D light are automatically created with your scene3d and now you can use them (to position them and to aim a point with the camera) 2 – Place objects in your 3D world You can create predefined 3D objects (3d_box, 3d_cube, 3d_cone, 3d_torus, 3d_sphere, 3d_cylinder, 3d_text, 3d_teapot, 3d_dodecahedron) or 3d objects formatted : 3d_mesh (in "3DS", format of 3D Studio Max) or 3d_actor (in "MD2", format of Quake). With the corresponding keyword, you give it a 3D number: 3d_teapot 1 3 – You can then move, scale, rotate, color, texture your objects... |
2.2 - How to have a 3D world taking all the available space? Create a 3d world : scene3D 1 Give it all the available space in FORM number 0 : full_space 1 Remark : to give all the space of the screen to FORM number 0 : full_space 0 Combining the 2 commands, you have a 3D world taking all the screen : full_space
0 : rem FORM0 take all the space on the screen |
2.3 - How to have two 3D worlds with 3D objects? Use 3D_TARGET_IS to designate the receiver of 3D object scene3d
1 : rem
create the first 3D world |
2.4 - How to color the background of a 3D world? Use the number N of the scene3D (3D world has been created by command scene3d N) in the command color: color N, Red, Green, Blue |
2.5 - How to use 3D rotations ? 3D_X_rotate, 3D_Y_rotate, 3D_Z_rotate are relating to the own axes of the object. The own axes of the 3D object are the axes which were parallel to the world axes when the 3D object was created. The rotation angles are expressed in relation to the initial position: 3D_X_rotate N,30 : rem rotate the 3D object N of 30° in relation to its initial position to the top |
2.6 - How to move a 3D object? All the 3D objects are created at position (0,0,0). To move a 3D object, use the commands : 3d_x_position, 3d_y_position, 3d_z_position Example:
|
2.7 - How to use a 3D object created in 3DS format (3D Studio Max)?
|
2.8 - How to use a 3D object created in MD2 format (Quake)?
|
3.1 - How to color the background of a FORM ? Use the number N of the FORM in the command color (0 for Base FORM, or N for a FORM created by command form N) : color N, Red, Green, Blue |
3.2 - It is adviced to pause after coloring a form : rem
color background in white color |
3.3 - How to color the background of a PICTURE? A picture has been created by command picture N. Use the number N in the command color: color N, Red, Green, Blue |
See the following example : rem
create the object "main menu" rem
create 2 objects "sub menus" at the same level (sons of the
object number 1) rem
create 3 "sub menus" sons of the object number 2 rem
create 3 "sub menus" sons of the object number 3 |
3.5 - How to use LEFT, TOP, WIDTH, HEIGHT ? left and top are used to position an object on its father (the container). width and height are used to dimension an objectt. |
3.6 - How to place a BUTTON (or another OBJECT) on another FORM than FORM number 0 ? First possibility : form
3 :
rem
create another form (number 3) Second possibility : form
3 :
rem
create another form (number 3) |
3.7 - How to place a MENU on another FORM than FORM number 0 ? form
3 :
rem
create another form (number 3) |
3.8 - How to use an OPEN_DIALOG to chose a file ? An open_dialog is created by the command open_dialog N, and is used by the command file_name$(N), N being the number of the open_dialog. As file_name$ returns either the name of file chosen by the user or the character underscore "_" if no file is chosen, the returned value must be stored in a string variable then compared with "_". dim a$ : rem declare a string variable open_dialog
1 : rem
create an open_dialog |
3.9 - How to save a MEMO in a file using a SAVE_DIALOG ? A save_dialog is created by the command save_dialog N, and is used by the command file_name$(N), N being the number of the save_dialog.
to the top |
3.10 - How to load a PICTURE with a file, the absolute name of which is in a$ ? dim a$ : rem declare a string variable picture
1 : rem create a picture |
3.11 - How to load a PICTURE with a file pointed by an OPEN_DIALOG ? dim a$ : rem declare a string variable picture
1 : rem create a picture Recall : the function file_name returns the underline character "_" if no file is chosen by the user. It is why the variable a$ must be compared with "_" : if a$ <> "_" |
3.12 - How to load a MEMO with a file chosen by an OPEN_DIALOG ? dim a$ : rem declare a string variable memo
1 : rem create a memo Recall : the function file_name returns the underline character "_" if no file is chosen by the user. It is why the variable a$ must be compared with "_" : if a$ <> "_" |
3.13 - CAPTION is possible only with BUTTON, OPTION, CHECK, ALPHA or FORM caption N,"Hello" : rem N must be button, option, check, alpha or form number This command on another type of object generates an error. |
3.14 - TEXT is possible only with EDIT or COMBO text N,"Hello" : rem N must be the number of an EDIT or of a COMBO. This command on another type of object generates an error. to the top |
There are 3 kinds of bars : track_bar, scroll_bar and progress_bar. - To read the position of the cursor : A=position(N) : rem N is the object number of the bar. - To change the position of cursor : position N,P : rem P is the position to be taken by the cursor of the bar number N. When you create the bars, they have standard values for the minimum and the maximum. - To change the minimum value : min N,M : rem M is the minimum value, N is the object number of the bar. - To change the maximum value : max N,M : rem M is the maximum value, N is the object number of the bar. |
4.1 - How to load and play a MIDI music file ? sound
1 : rem
create a sound |
4.2 - How to load and play a WAV sound file ? sound
1 : rem
create a sound |
4.3 - How to load and play a MP3 music file ? sound
1 : rem
create a sound |
4.4 - How to load and play a movie with a file, the absolute name of which is in a$ dim a$ : rem declare a string variable a$="c:\MyMovie.avi"
: rem define the file name |
5.1 - How to use missing mathematic functions ? Tan(x) = Sin(x) / Cos(x) -> use SIN(X)/COS(X) ArcSin(x) = ArcTan(x/sqr(1-sqr(x))) -> use ATN(X/SQR(1-SQR(X))) ArcCos(x) = ArcTan(sqr(1-sqr(x))/x) -> use ATN(SQR(1-SQR(X))/X) to the top |
See the following example : dim
a$ loop: rem here, a$ is the pressed key |
5.3 - How to use the subroutines ? A subroutine is a group of commands which can be processed a certain number of times. A subroutine begins by a label (which has to be declared by the keywordd LABEL) and ends by RETURN. When RETURN is executed, the program execution returns to the command immediately after the GOSUB command. to the top |
When an event (click, change) occurs on an object, you define in a subroutine the commands to be processed to respond to the event. A subroutine begins by a LABEL and ends by RETURN. Attention : some events are not possible with some objects ! to the top |
Last update : April 25, 2008