The Command Line Interface (CLI) is actually quite a useful tool. It allows you test out code in real time. It's helpful for debugging and trying out different things.
Let's do a few experiments to see how it works. First, copy this code into DarkEDIT or the standard DB editor:
Set display mode 800,600,32
sync on
sync rate 60
autocam off
rem make a matrix for scale and reference
make matrix 1,1000,1000,25,25
rem add a bunch of cones so there's an environment
for obj=1 to 50
make object cone obj,25
scale object obj,100,400,100
position object obj,rnd(1000),50,rnd(1000)
color object obj,rgb(0,100,0)
next obj
rem position the camera in the middle of the matrix
position camera 500,30,500
sync
rem our main loop
speed# = 5
do
rem move the camera around
gosub _move_camera
sync
loop
`----------------------------------------------------------------
_move_camera:
rem move camera around a certain speed
move camera (upkey()-downkey())*speed#
yang#=wrapvalue(camera angle y()+mousemovex())
yrotate camera yang#
return
`----------------------------------------------------------------
Now, before launching the program, you may want to print or write down the following tests. Once you have the information, go ahead and run the program and try out these tests:
1. Activate the CLI
Once the program is running, you'll see a make-shift forest on a grid. Move the camera around with the Up/Down arrow keys and steer with the mouse.
Now press ESCAPE
The CLI will open. You'll have noticed that the mouse is moving around the screen as you were steering the camera. Without rewriting code in our source script, we can send a command directly through the CLI to do what we want. In this case, we'll hide the mouse.
Type : hide mouse
Press ENTER
Now Press ESCAPE again
You are back in the forest and you'll see the mouse is hidden. Move around a bit so you can see the prgram is running just fine.
One might use the CLI to test how things would look if they changed something (besides just hiding the mouse). Instead of writing new source, we can do some of the tests while the program is running so on to test 2:
2. Change Your Objects
Press ESCAPE - the CLI window opens
Type the following exactly as you see it in the CLI then press ENTER
for obj=1 to 50 : scale object obj,100,100,100 : next obj
Did all of the trees shrink? They should have! You can control objects directly from the CLI and see immediate results. The shrunken trees in their current state don't look so great so let's switch them back. Type the following in the CLI and press ENTER
for obj=1 to 50 : scale object obj,100,400,100 : next obj
Instead of typing that whole line a second time with the slight adjustment, you could have pressed the UP key and that will cycle through the previous things typed or the last text message displayed. If you pass the text you are looking for, press the DOWN key. Once you find the command you are looking for, use the LEFT or RIGHT arrow keys to move the cursor to the place on the line you want to change the text. In this case, we want to change the 100 to a 400. If you didn't already, try using the UP and DOWN arrow keys to bring up
for obj=1 to 50 : scale object obj,100,100,100 : next obj
and the use the LEFT/RIGHT keys to position the cursor in the correct place to change the line to read:
for obj=1 to 50 : scale object obj,100,400,100 : next obj
After you change the line, press ENTER. If you had changed it already, you won't notice any differenc in the forest.
Press ESCAPE to return to the program and move around some more.
When you are done moving around, press ESCAPE to return to the CLI
3. Changing Variables
I created a variable labeled speed# that controls how fast the camera moves forward. See if you can figure out how to change it's value to 10 in the CLI and then return to the program to see if the change worked. The try changing it to 1. Check below for the procedure:
press ESCAPE to open the CLI
type speed#=10
press ENTER
press ESCAPE to return to the program
4. Check Values
Sometimes you may want to check the values of variables or other things. We can query with PRINT directly from the CLI to check a value. But because my example is in 3d, a print will return a 2d value that the 3d redraw will wipe out. In this case in order to see our 2d values printed on the screen, we'll have to temporarily turn the 3d refresh off, print our value(s) then turn the 3d refresh back on. Let's check the value of speed# first. By now you should understand how to enter the CLI window and return from it so I'll only type the codes you should be inputting into the CLI:
backdrop off
press ENTER
print speed#
press ENTER
backdrop on
Return to the program.
Try and use the same process to return the screen fps()
If you did everything like in the previous example, you shouldn't have had any problems.
That wraps up this quick tutorial on the CLI. You can use the CLI pretty much to test anything that you could write in code. However, you are limited to 255 characters on a line as a single command or string of commands.
Also keep in mind that if a value is reset in a loop in your program's source, if you change it in the CLI, the program's loop will just change it back.
Enjoy your day.