0) USUAL TRUEBASIC BEGINNERS' BUGS

a) All programs must END with an END statement!

b) The "=" sign in TB is an "assignment" symbol (should be seen as "=>"), NOT an "equal to" symbol.

Names assigned to variables go on the left hand side (LHS) of =, and its values on the RHS:

Xn = 0.5 .............is correct

0.5 = Xn............. is not!

c) For the same reason

N = N + 1 ..................(for example, 4 = 4 +1 ?????)

is a "ridiculous" statement if read as an "equation", but

N = N + 1 .............(for example, 5 => 4 )

makes perfect sense as an assignment (means: take the previous value of N, then increment it by 1, and place it in the same memory location as the new value of N). Now this sophisticated computer can COUNT!

d) FOR....NEXT loops follow a precise syntax (notice the same index variable I appears on both FOR and NEXT statements):

FOR I= 1 to 10 STEP 2

LET ISQUARED= I*I

PRINT I, ISQUARED

NEXT I

END

will produce the following output (notice that the next i =11, being > 10 is not executed, the program exits the loop to END):

1 ....................1

3.....................9

5.....................25

7.....................49

9.....................81


1) INPUT REQUESTS:

a) "Long way":

PRINT "What is your name";

INPUT name$

PRINT "How old are you"

INPUT age

PRINT name$; ", you are";age;"years old!"

END

 

b) "Short way":

INPUT PROMPT "What is your name?": name$

INPUT PROMPT "How old are you?": age

PRINT name$; ", you are";age;"years old!"

END


2) MOUSE CONTROL:

 

GET MOUSE x,y,s

x,y is the mouse location in the active window

s is the state of the mouse button according to the following numerical scale:

s=0 .................Not Activated ("Browse mode")

s=1..................Pressed down ("Start Drag mode")

s=2..................Clicked (Most common, equivalent to GET POINT x,y)

s=3..................Released (after s=1, "End Drag mode")

s=4..................Shift-Clicked (not very useful)

 

3) WINDOW CONTROL

 

3a)WINDOW #0 is the default window

OPEN #1: SCREEN l,r,b,t ...............l,r,b,t relative to the 0,1,0,1 standard window

SET WINDOW -2,2,-2,2

 

WINDOW #n switches the output to the nth window.

 

 

3b) For scaling use (to avoid distorsion, 640/480 =4/3=1.333 is standard resolution)

ASK PIXELS hpix,vpix

LET RATIO=hpix/vpix

SET WINDOW -2*RATIO,2*RATIO,-2,2

or

SET WINDOW -2,2,-2/RATIO,2/RATIO

 

3c) To store and redisplay images:

BOX KEEP l,r,b,t IN NAME$

BOX SHOW l',r',b',t' IN NAME$

 

4) FOR ZOOMING INTO A REGION:

 

DO

GET MOUSE x,y,s

LOOP UNTIL s=1

LET x=x1

LET y=y1

 

DO

GET MOUSE x,y,s

BOX AREA x1,x,y1,y

LOOP UNTIL s=3

LET x=x2

LET y=y2

 

!CORRECT FOR POSSIBLE x1>x2, or y1>y2)

 

OPEN #1: SCREEN 0.5,1,0.5,1

SET WINDOW x1,x2,y1,y2


USEFUL MAC TRICK: To get a record of something on the screen you would like to save, take a "snapshot" of the screen using the keyboad combination (+ means all 3 keys pressed simultaneously):

Command (=Apple) + Shift + 3

You will hear a "click" sound, and the snapshot is saved as a PICT file on the hard drive (picture1, picture2, etc...).

Double click on the file (easier to find if you search by date for the the most recent one) to view it, copy, paste, etc.


USEFUL REMINDER: When you use Adobe PageMill to create Web pages, all graphic files that you paste into it are saved "by default" in the computer's hard drive you are working on, and NOT in the server where your document is posted, so they will NOT be displayed correctly when people look at your page using a browser. You need to upload a copy of the graphic file, usually from the "PageMill Resources" folder to the server folder, and rename the file accordingly using Edit HTML Source.