Hi all,
Please help:
I have some BASIC code from a program on a Casio FX-850P calculator that I would like to convert into C++ and make into a Windows application using Visual Studio - any suggestions?
Fx-850P Basic Code
Started by
CasioRich
, Oct 08 2012 10:00 AM
8 replies to this topic
#1
Posted 08 October 2012 - 10:00 AM
#2
Posted 08 October 2012 - 01:46 PM
Hello CasioRich and welcome to UCF! You should introduce yourself.
Well, I think you would have to manually port it. It probably would not be too difficult. Would you like to share your program so we can see?
Well, I think you would have to manually port it. It probably would not be too difficult. Would you like to share your program so we can see?
#3
Posted 09 October 2012 - 11:59 AM
Hi flyingfisch,
I will introduce myself properly at the link you posted when I get a bit time but I'm under pressure from work to get stuff done atm.
I could port it, the code isn't too complex - it basically calculates a brace betweeen two struts in the engineering/fabrication we do.
Here is the code I took out of the calculator:
I will introduce myself properly at the link you posted when I get a bit time but I'm under pressure from work to get stuff done atm.
I could port it, the code isn't too complex - it basically calculates a brace betweeen two struts in the engineering/fabrication we do.
Here is the code I took out of the calculator:
1 'HFG BRACING CALCS 2 CLS:CLEAR 10 DIM C(2),I(2),O(2),W(2),LA(2),LB(2),LC(2),PLUS(2),SJ(2),JH(2),REV$(2),01(2),BRI(2),TRAV(2) *****NOTE ZEROS OR ONES??? 20 ANGLE 0:SET N 100 PRINT "Brace or Stub";CHR$(13); 110 A$=INKEY$ 120 IF A$="B" OR A$="b" THEN EDS=2:T$"BRACE":GOTO 1000 130 IF A$-"S" OR A$="s" THEN EDS=1:I(2)=90:T$="STUB":GOTO 1000 140 GOTO 110 1000 '**********INPUTS************** 1010 PRINT T$;:INPUT " DIA ";BD:IF BD <=0 THEN BEEP:GOTO 1010 1020 INPUT "WALL THICKNESS";WT:BRI=(BD/2)-WT 1030 IF WT<0 OR WT>BD/2 THEN BEEP:GOTO 1020 1050 FOR N=1 TO EDS 1060 PRINT "END";N;CAN DIA";CHR$(13);"EXE=STR CUT";:INPUT C(N):IF N=1 AND C(1)<0 THEN BEEP:GOTO 1060 1064 IF N=2 AND C(2) <0 THEN C(2)=C(1):I(2)=I(1) <img src='/dot/public/style_emoticons/<#EMO_DIR#>/ohmy.png' class='bbc_emoticon' alt=':o' />(2)=O(1):W(2)=W(1):BRI(2)=BRI(1):SYM=1:LA(2)=LA(1):LB(2)=LB(1):LC(2)1=LC(1):O1(2)=O1(1):GOTO 1110 1079 CLS 1080 PRINT "END ";N;"WELD PREP Y or N";CHR$(13); 1081 A$=INKEY$ 1082 IF A$="Y" OR A$="y" THEN W(N)=1:BRI(N)=BRI:GOTO 1090 1083 IF A$="N" OR A$="n" THEN W(N)=0:BRI(N)=BRI+WT:GOTO 1090 1084 GOTO 1081 1090 CLS:PRINT "END ";N;" INCLUDED ANGLE ";:INPUT I(N):IF I(N)<=0 OR I(N) >90 THEN BEEP:GOTO 1090 1092 IF I(N)<=37.5 AND W(N)=1 THEN PRITN "REV PREP";CHR$(13); 1093 IF C(N)=0 THEN 1097 1094 PRINT "END ";N;" OFFSET";:INPUT O(N) 1095 IF O(N)<0 THEN BEEP:GOTO 1094 1096 IF BRI(N)+O(N)>C(N)/2 THEN BEEP:GOTO 1094 1097 O1(N)=(C(N)/2)-SQR(((C(N)/2)^2)-(O(N)^2)) 1100 C(N)=C(N)/2:LA(N)=C(N)/SIN(I(N)):IF I(N)<90 THEN LB(N)=BRI/TAN(I(N)) 1102 IF I(N) <> 90 THEN LC(N)=WT/TAN(I(N)) 1110 NEXT N 1111 FOR N=1 TO EDS 1115 GOSUB 3400 1116 NEXT N 1119 CLS 1120 INPUT "INTERS";CTRS 1130 IF CTRS<LA(1)+LA(2)+LB(1)+LB(2)+LC(1)+LC(2)+PLUS(1)+PLUS(2) THEN BEEP:PRINT "NOT ENOUGH";CHR$(13):;GOTO 1120 3000 '************CALCULATIONS******* 3001 SJ(1)=LA(1)-LB(1)-O1(1)/SIN(I(1)):SJ(2)=LA(2)-LB(2)-O1(2)/SIN(I(2)) 3002 JH(1)=LB(1)*2+O1/SIN(I(1)):IF I(1)<=37.5 AND W(1)=1 THEN JH(1)=JH(1)+LC(1) 3003 JH(2)=LB(2)*2+O1(2)/SIN(I(2)):IF I(2)<=37.5 AND W(2)=1 THEN JH(2)=JH(2)+LC(2) 3005 SJ(1)=INT(SJ(1)+.5):SJ(2)=INT (SJ(2)+.5):JH(1)=INT(JH(1)+.5):JH(2)=INT(JH(2)+.5) 3010 JESCO=CTRS-SJ(1)-SJ(2) 3020 HGG=JESCO-JH(1)-JH(2) 3022 IF I(1)<=37.5 AND W(1)=1 THEN REV$(1)="REV PREP" 3024 IF I(2)<=37.5 AND EDS=2 AND W(2)=1 THEN REV$(2)="REV PREP" 3030 LGTH=CTRS-LA(1)-LA(2)+LB(1)+LB(2)+INT(.5+PLUS(1))+INT(PLUS(2)+.5) 3040 WGHT=(((HGG+LGTH)/2*PI*(BD-WT))*7.85*WT*.000001 3050 SA=((HGG+LGTH)/2)*PI*BD*.000001 3075 LGTH=INT(LGTH+.5):WGHT=INT(WGHT+.5):SA=ROUND(SA,-3):TRAV(1)=INT(TRAV(1)+.5):TRAV(2)=INT(TRAV(2)+.5) 3300 GOTO 9000 3390 '*******CALCS INC IN LGTH 3400 ROT=1:COUNT=1 3405 IF SYM=1 AND N2= THEN PLUS(2)=PLUS(1):TRAV(2)=TRAV(2)=TRAV(1):GOTO 3670 3410 IF I(N)=90 THEN TRAV(N)=C(N)-SQR(C(N)^2-(O(N)+BR(N)^2):PLUS(N)=TRAV(N):GOTO 3670 3420 IF C(N)=0 AND W(N)=0 THEN PLUS(N)=LC(N):GOTO 3670 3430 IF C(N)=0 AND W(N)=1 THEN GOTO 3670 3500 A1=(BRI(N)*SIN(ROT))+0(N) 3505 CLS:PRINT "CALCULATING END";N;ROT;CHR$(8);CHR$(223); 3510 B1=SQR((C(N)^2)-(A1^2)) 3520 C1=C(N)-B1 3530 D1=(BRI(N)-BRI(N)*COS(ROT))/TAN(I(N)) 3540 E1=C1/SIN(I(N)) 3550 F1=E1-D1 3560 IF F1>PLUS(N) THEN ROT=ROT+5:PLUS(N)=F1:COUNT=2:GOTO 3500 3570 IF COUNT=1 THEN RETURN 3580 ROT=ROT-4 3600 A1=(BRI(N)*SIN(ROT))+0(N) 3605 CLS:PRINT "CALCULATING END";N;ROT;CHR$(8);CHR$(223); 3610 B1=SQR(C(N)^A1^2) 3620 C1=C(N)-B1 3630 D1=(BRI(N)-(BRI(N)*COS(ROT)))/TAN(I(N)) 3640 E1=C1/SIN(I(N)) 3650 F1-E1-D1 3660 IF F1>PLUS(N) THEN ROT=ROT+1:PLUS(N)=F1:GOTO 3600 3670 RETURN 9000 '********************OUTPUTS************ 9010 CLS 9020 PRINT "BRACE LENGTH =";LGTH;CHR$(13);"BRACE WEIGHT =";WGHT;"kg" 9030 PRINT "SURF. AREA-";SA:CLS 9040 PRINT "O/ST POINTS (JESCO)=";JESCO;CHR$(13); 9050 PRINT "INI LENGTH (HGG)=";HGG 9060 PRINT "SOP TO JES 1=";SJ(1):CHR$(13); 9070 IF I(1)<90 THEN PRINT "JES TO HGG 1=";JH(1);REV$(1) 9075 IF I(1)=90 THEN RPINT "TRAVEL=";TRAV(1) 9080 IF EDS=2 THEN PRINT "SOP TO JES 2=";SJ(2);CHR$(13); 9090 IF EDS=2 AND I(2)<90 THEN PRINT "JES TO HGG 2=";JH(2);REV$(2) 9100 IF I(2)=90 AND EDS=2 THEN PRINT "TRAVEL=";TRAV(2) 9500 END
#4
Posted 09 October 2012 - 02:31 PM
Do you want the computer version to have a GUI or is it just a command line program?
If you want a GUI, it may be a good idea to do it from scratch and use this program sort of as an outline for the math part...
If you want a GUI, it may be a good idea to do it from scratch and use this program sort of as an outline for the math part...
#5
Posted 09 October 2012 - 02:41 PM
Really it would be best with a GUI.
I could just create it using that as a template but I'm not really a good coder yet.
I could just create it using that as a template but I'm not really a good coder yet.
#6
Posted 10 October 2012 - 02:11 AM
Ah, OK.
I think the easiest way would be just to port the code that does the calculations, and use the template to take care of user input, etc.
I think the easiest way would be just to port the code that does the calculations, and use the template to take care of user input, etc.
#7
Posted 02 November 2012 - 11:23 AM
Now I review your code, it doesn't have special code that could make it unportable.
PRINT
would be cout
, INPUT
is cin
, INKEY
could be cin.get
, and fortunately goto
is still there in C++. But anyway if you can get the algorithm and implement it yourself you'll have a cleaner program.
#8
Posted 02 November 2012 - 02:09 PM
You could go through your code and try to figure out how to do it without
goto
. Its almost always possible to do it with loops.
#9
Posted 07 November 2012 - 12:21 PM
It's possible; going through the code for converting it is another story. The following is an example from my textbook which really challenged me, see what about you?
int row = 0, col; A: col = 0; if (col < n) goto B; goto A; B: if (row < n) goto C; goto E; C: if (mat[row][col] == item) goto D; col++; if (col < n) goto B; row++; goto A; D: cout << "Item found\n"; goto F; E: cout << "Item not found\n"; F:
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users