looping a program
#1
Posted 02 March 2003 - 05:42 AM
===== direct======
"bearing 1"?(arrow)Z(input command)
"distance 1"?(arrow)Y(input command)
"latit":YCosZ(output command)
"dipat":YSinZ(output command)
ok this is actually to calculate a missing line for a polygon using the trigonometry method. latit is the y-axis while dipat is the x-axis.
i just insert all the line of the polygon in bearing and distance to calculate the missing line.
so how do i loop the program so it would show:
bearing 1?
145 00 00
distance 1?
25.000
latit
-20.47880
dipat 14.33941
bearing 2?
distance 2?
.
.
.
.
bearing n?
distance n?
stop until i press execute without inserting any value.
after that i need to use all this latit and dipat value to where all the latit values are added together and the dipat values added together.
the values added would be used to calculate the missing line and would shows the missing line bearing and distance with the formula below.
bearing of missing line:
tan-1 (dipat/latit)
distance of missing line:
......
thats all... i hope it aint confusing... cos all help are appreciated... just need to know how to loop and stop the loop.
one more thing where can i find the source code for MCL??
#2
Posted 02 March 2003 - 09:40 AM
do what you want
while end
#3
Posted 02 March 2003 - 02:22 PM
what does it mean by getkey=/=thebuttonyouwant?
#4
Posted 02 March 2003 - 03:13 PM
simple loop examples:
This will output a simple counter, and loop while no key is pressed:
While Getkey WhileEnd 1->A While Not Getkey Locate 1,1,A Isz A WhileEnd
This will do the same as the above, but loop until EXE is pressed, and halt when CTRL is pressed:
While Getkey WhileEnd 1->A While Getkey<>31 Locate 1,1,A Isz A While Getkey=68 WhileEnd WhileEnd
The "While Getkey:WhileEnd" in the begining is for the program to wait until you released the key pushed to start the program, keeping it from exiting momenteraly
#5
Posted 02 March 2003 - 03:49 PM
===========================================
1->A (this is just a counter)
Lbl 1
ClrText
"bearing"
Locate 9,1,A
? -> Z (input command, the "->" is the arrow key)
Z = 0 => goto 2 (the "=>" is the arrow found in the Jump submenu)
"distance"
Locate 10,4,A
? -> Y (input command)
"latit":YCosZ (output command)
"dipat":YSinZ (output command)
A + 1 -> A (increase counter)
goto 1
Lbl 2
(rest of code if wanted)
============================================
Then to exit all you would have to do is put in zero for bearing.
#6
Posted 03 March 2003 - 04:38 AM
http://www.geocities...53/tutorial.txt
#7
Posted 04 March 2003 - 05:01 AM
Lbl 1
ClrText
"bearing"
Locate 9,1,A
? -> Z (input command, the "->" is the arrow key)
Z = 0 => goto 2 (the "=>" is the arrow found in the Jump submenu)
"distance"
Locate 10,4,A
? -> Y (input command)
"latit":YCosZ (output command)
"dipat":YSinZ (output command)
A + 1 -> A (increase counter)
goto 1
Lbl 2
hie guys! the source code by casto production is just what i needed.! but we still need to improve it and yet my program is half way thru... man this language is difficult!
1) can we change the variable A to integer? cos i've set the decimal place to 3, so i wouldn't want it to look like 'bearing 1.000'.... heheheh looks funny rite...
2)to stop the loop or restart the loop lets say:
bearing 6
?
0
then it would go back to =>
bearing 1
?
rite? but 0(zero) is not applicable cos bearing do exist in 0, so is it possible to write a source code to leave it blank to stop the execution and goto another label?
3) example of the program
bearing 1
?
145degree 0min 0sec
distance 1
?
25.000
latit 22.097
dipat 11.694
bearing 2
?
210degree 0min 0sec
distance 2
?
30.000
latit -26.516
dipat 14.032
bearing 3
?
285degree 0min 0sec
distance 3
?
31.000
latit -19.634
dipat 23.990
distance 4
?
leave blank and exe again to perform goto other label
other label would need to use the values of latit and dipat calculated. the source code above did not set latit and dipat to any variables so can we use it back for further calculation?
after distance 4 left balnk and exited, it would perform calculation like latit1+latit2+latit3='L' , dipat1+dipat2+dipat3='D'
i just need to know this, sorry if my post seems so long
i ain't spamming though hehehe
how do we use the getkey? can we use the getkey set a key like getkey=A and press the alpha button A, the perform a calculation? how ? the above would be the main program to calculate missing line's bearing and distance, and the getkey function is to calculate area value and others.
thanx!
#8
Posted 04 March 2003 - 09:19 AM
say you want "latit" in list1, and "dipat" in list2, you simply add to your loop:
YcosZ->List1[A]
YSinZ->List2[A]
If you use this on a cfx model, you'll need to set the list dimensions first, which will also be your maximum number of inputs.
On the afx, inserting a number to list element (1+current_dimension_of_list), will simply add 1 element to the list, so there's no need to set the dimensions up front
All lists are limited to 255 elements
to print out an integer, you can use the Int prefix, however, if you'll need to change the display mode to normal first, to avoid trailing zeros
as for the getkey,
it returns the current state of the keyboard. that is, it does not hold a buffer of any kind, but simply return the currently pressed button, if any (multiple presses are not supported)
there is an overview of the different button values in your manual.
anyway, it's formated like this:
AB, (where AB is a number in the format B + 10A)
A marks the column, going from 3 on the EXE button, to 7 on the 0 button.
B marks the row, going from 1 at the 0 button, to 9 at the F-keys
Direction pad is a new collumn, that is A = 2
to use getkey, you either check the keypress there and then, or you assign it to a variable first, and then do your check routines on it
hope some of it helped
if you find programming Basic difficult.. try looking at some source code, or at least read your manual... <_<
#9
Posted 04 March 2003 - 12:12 PM
zero you may do the folowing
ran#->V;Insert this Line!!! 1->A (this is just a counter) Lbl 1 ClrText "bearing" Locate 9,1,A ? -> Z (input command, the "->" is the arrow key) Z = V => goto 2 (the "=>" is the arrow found in the Jump submenu) "distance" Locate 10,4,A ? -> Y (input command) "latit":YCosZ (output command) "dipat":YSinZ (output command) A + 1 -> A (increase counter) goto 1 Lbl 2
This simply sets a random number like 0,5352414 to V and if you want
to exit the loop you simply enter V. It's very unlike that anyone will ever
use a number that is the same as the random number! Then you'll
have to compare Z with V.
The program restarts after you exited it because you typed EXE!
type any other key (123456/cos/tan etc) and you'll be in run menu.
Thats only in CFX-9850 series calculators.
The AFX / Graph100 series return to PRGM menu.
#10
Posted 04 March 2003 - 03:02 PM
btw how do u guys code this thing? i mean put it in the white box... heheh
ran#->V;Insert this Line!!!
1->A (this is just a counter)
Lbl 1
ClrText
"bearing"
Locate 9,1,A
? -> Z (input command, the "->" is the arrow key)
Z = V => goto 2 (the "=>" is the arrow found in the Jump submenu)
"distance"
Locate 10,4,A
? -> Y (input command)
"latit":YCosZ (output command)
"dipat":YSinZ (output command)
A + 1 -> A (increase counter)
goto 1
Lbl 2
ok i didnt add ran#->V, cos i think it might confuse the user with its random number, it it gave me an idea to just put EXIT if users want to exit or should i say restart?
ok bitwhise, i've tried ur idea too, and..... syntax error.... hehe well u mean i need to declare the list? how?
YcosZ->List1[A]
YSinZ->List2[A]
tried putting it in various places in the loop in the end shows syn error.
same as integer , i put it in front of the variable A but it doesn't show any effect. i need a 3 decimals place for my calculations but i want the A variable as an integer... demanding huh?
getkey:
AB, (where AB is a number in the format B + 10A)
A marks the column, going from 3 on the EXE button, to 7 on the 0 button.
B marks the row, going from 1 at the 0 button, to 9 at the F-keys
Direction pad is a new collumn, that is A = 2
hmmm all i can do is scratch my head bald hehehe....
finally, i'm using a cfx-9850 series if ur wondering, and i've read the manual book, i find it hard to understand cos it doesn't have much examples though, so the best way to learn is to ask.... in my opinion.
where can i see examples of source codes?
#11
Posted 04 March 2003 - 05:16 PM
I'll try to give it to you in smaller portions:
using lists:
-declare
-index variable
-read
-write
'declaring: N->Dim ListX 'where N is the number of elements you want, and X is the List number (1 - 6 on the cfx) 'indexing: C->I 'where C is a constant number / variable/ expression to which element you want your index variable (I) to start pointing to, and I is any variable on the calc 'read and store: ListX[I]->A 'where X is the list number, I is the index (either a variable, constant or expression), and A is the variable in which you want to store the read information. 'read without store: ListX[i]_ 'or Locate A, B, ListX[I] 'or Text A, B, ListX[i] 'where A and B are coordinates, X is the list no, and I is the index 'Locate ouputs in text mode, and Text outputs in graph mode '_ is the small triangel, you'll find it under the prog menu 'write: A->ListX[I] 'where A is any variable/expression/constant, X is the list no, I is the index (var/expre/const) 'and remember -> is not MINUS_SIGN + ARROW, it's the asignment arrow on the calc
Formating output:
just an example
1->A Norm 1 Locate 1,1,A 'outputs "1" Fix 3 Locate 1,2,A 'outputs "1.000" 1.23456->A Norm 1 Locate 1,3,A 'outputs "1.23456" Locate 1,4,Int A 'outputs "1" Fix 3 Locate 1,5,A 'outputs "1.235" Locate 1,6,Int A 'outputs "1.000"
Getkey:
just another example, to help with my previous explenation (you should have map of the keys in your manual, after which looking at, you should see the pattern...)
'wait for user to release the exe button While Getkey WhileEnd 'wait for user to input key Do Getkey->K LoopWhile Not K Locate 1,1,"You pushed" If K=31 Then Locate 12,1,"EXE" Else If K=79=>Locate 12,1,"F1" Else Locate 12,1,"NA" IfEnd:IfEnd Locate 1,2,"Stroke Row:" Locate 1,3,"Stroke Col:" Locate 13,2,K-10Int(K/10) Locate 13,3,Int(K/10)
Last:
Where you can see example source code:
www.google.com
search:
casio calculator
casio basic
casio calculator games
casio calculator programs
cfx9850
#12
Posted 11 March 2003 - 01:16 PM
1->A Lbl 1 ClrText "bearing" locate 9,1,A ?->Z Z=K=>Goto 2 "Distance" locate 10,4,A ?->Y "latit":YcosZ->L "dipat":YsinZ->D A+1->A Goto 1 Lbl 2 "Missing Distance" SquareRoot(L2+D2) "missing bearing" (Inverse)tan-1(D/L)
thats my program so far.... the main prob now is that ill insert (see example below) a few bearing and distance values and i'll need to use all the latit and dipat calculated to calculate the value of the missing bearing and distance. so far my programs doesn't save all the latit and dipat value calculated to be used later... how?
bearing 1
?
145degree 0min 0sec
distance 1
?
25.000
latit 22.097
dipat 11.694
bearing 2
?
210degree 0min 0sec
distance 2
?
30.000
latit -26.516
dipat 14.032
bearing 3
?
285degree 0min 0sec
distance 3
?
31.000
latit -19.634
dipat 23.990
formula:::
missing distance:
SquareRoot[Root((22.097+(-26.516)+(-19.634))+
Root(11.694+14.032+23.990)]
answer:::
55.229
well thats all i need... sorry if i trouble u guys but i myself cant think of solving my problems really giving me a headache... thanx guys!
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users