Jump to content



Photo
- - - - -

Unknown mistake


  • Please log in to reply
5 replies to this topic

#1 Just_A_Noob_Here

Just_A_Noob_Here

    Newbie

  • Members
  • Pip
  • 16 posts

  • Calculators:
    FX-7400 GII, FX-570 ES

Posted 21 May 2020 - 07:31 PM

Hi, I've recently made a program that randomly gives you a number (from 0 to 9) on three variables, and random letters (from A to E)

But unfortunately it is broken, calculator doesn't seem to show the error. What's weird is that sometimes (rarely) it will work but mostly not.

Here take a look:

Lbl 1
RanInt#(0,9) → A
RanInt#(0,9) → B
RanInt#(0,9) → C
RanInt#(1,5) → X
RanInt#(1,5) → Y
RanInt#(1,5) → Z
If X=1
Then Locate 2,3,"A"
Else If X=2
Then Locate 2,3,"B"
Else If X=3
Then Locate 2,3,"C"
Else If X=4
Then Locate 2,3,"D"
Else If X=5
Then Locate 2,3,"E"
IfEnd
If Y=1
Then Locate 5,3,"A"
Else If Y=2
Then Locate 5,3,"B"
Else If Y=3
Then Locate 5,3,"C"
Else If Y=4
Then Locate 5,3,"D"
Else If Y=5
Then Locate 5,3,"E"
IfEnd
If Z=1
Then Locate 8,3,"A"
Else If Z=2
Then Locate 8,3,"B"
Else If Z=3
Then Locate 8,3,"C"
Else If Z=4
Then Locate 8,3,"D"
Else If Z=5
Then Locate 8,3,"E"
IfEnd
Locate 1,3,A
Locate 4,3,B
Locate 7,3,C

"Change(1)"?→Q
If Q=1
Then Goto 1


Output looks:

Change(1)?
1A 2B 3C

Output broken:

D E

or

C


I know I have done mistake here, but I can't find it.

Could you help me please ?

Regards

Nooblette

#2 pan.gejt

pan.gejt

    Casio Freak

  • Members
  • PipPipPipPip
  • 264 posts
  • Gender:Male
  • Location:CZ

  • Calculators:
    .

Posted 22 May 2020 - 03:53 PM

You can try this code, the changes are marked as bold. I moved the RanInt#(0,9) → A,RanInt#(0,9) → B, RanInt#(0,9) → C practically till the end

 

ClrText

Lbl 1
RanInt#(1,5) → X
RanInt#(1,5) → Y
RanInt#(1,5) → Z
If X=1
Then Locate 2,3,"A"
Else If X=2
Then Locate 2,3,"B"
Else If X=3
Then Locate 2,3,"C"
Else If X=4
Then Locate 2,3,"D"
Else If X=5
Then Locate 2,3,"E"
IfEnd
If Y=1
Then Locate 5,3,"A"
Else If Y=2
Then Locate 5,3,"B"
Else If Y=3
Then Locate 5,3,"C"
Else If Y=4
Then Locate 5,3,"D"
Else If Y=5
Then Locate 5,3,"E"
IfEnd
If Z=1
Then Locate 8,3,"A"
Else If Z=2
Then Locate 8,3,"B"
Else If Z=3
Then Locate 8,3,"C"
Else If Z=4
Then Locate 8,3,"D"
Else If Z=5
Then Locate 8,3,"E"
IfEnd

RanInt#(0,9) → A
RanInt#(0,9) → B
RanInt#(0,9) → C

Locate 1,3,A
Locate 4,3,B
Locate 7,3,C
"Change(1)"?→Q

ClrText
If Q=1
Then Goto 1

Else "END"

IfEnd

------------------------------------

I slightly modified your program, I used 3 subroutines for better clarity and works as expected on fx-7400GII. You can copy the line or the all code to save time. The program name is "bold". After typing the RANINTX code you can copy all the code and paste it in RANINTY and RANINTZ program. If you don't see results, add output command (triangle) at the end of the Locate command.

 

RANINT

ClrText

Lbl 1

Prog "RANINTX"

Prog "RANINTY"

Prog "RANINTZ"

RanInt#(0,9) → A

RanInt#(0,9) → B
RanInt#(0,9) → C

Locate 1,3,A
Locate 4,3,B
Locate 7,3,C

"Change(1)"?→Q

ClrText
If Q=1
Then Goto 1

Else "END"

IfEnd

 

RANINTX:

RanInt#(1,5) → X

If X=1

Then Locate 2,3,"A"
Else If X=2
Then Locate 2,3,"B"
Else If X=3
Then Locate 2,3,"C"
Else If X=4
Then Locate 2,3,"D"
Else If X=5
Then Locate 2,3,"E"
IfEnd

 

RANINTY:

RanInt#(1,5) → Y

If Y=1

Then Locate 5,3,"A"
Else If Y=2
Then Locate 5,3,"B"
Else If Y=3
Then Locate 5,3,"C"
Else If Y=4
Then Locate 5,3,"D"
Else If Y=5
Then Locate 5,3,"E"
IfEnd

 

RANINTZ:

RanInt#(1,5) → Z

If Z=1

Then Locate 8,3,"A"
Else If Z=2
Then Locate 8,3,"B"
Else If Z=3
Then Locate 8,3,"C"
Else If Z=4
Then Locate 8,3,"D"
Else If Z=5
Then Locate 8,3,"E"
IfEnd


Edited by pan.gejt, 22 May 2020 - 03:58 PM.


#3 Hlib2

Hlib2

    Casio Freak

  • Members
  • PipPipPipPip
  • 142 posts
  • Gender:Male
  • Location:Ukraine
  • Interests:industrial electronics,
    graphing calculators

  • Calculators:
    fx-9860GII-2
    graph-100+
    fx-991DE_X
    ti-89_Titanium
    ti-voyage200
    ti-84+SE

Posted 22 May 2020 - 06:38 PM

Hi, I`ve recently made a program that randomly gives you a number (from 0 to 9) on three variables, and random letters (from A to E)
But unfortunately it is broken, calculator doesn`t seem to show the error. What`s weird is that sometimes (rarely) it will work but mostly not.
Here take a look:
Lbl 1
RanInt#(0,9) → A
........
........
I know I have done mistake here, but I can`t find it.
Could you help me please ?
Regards
Nooblette

You should slightly correct the program, and then it will work.
Lbl 1
CltText:" ":" ":" " //add this
RanInt#(0,9)➝A
........
........
If X=1
........
........
Then Locate 2,3,"E"
IfEnd:IfEnd:IfEnd:IfEnd:IfEnd // five IfEnd
If Y=1
........
........
Then Locate 5,3,"E"
IfEnd:IfEnd:IfEnd:IfEnd:IfEnd // five IfEnd
If Z=1
........
........
Then Locate 8,3,"E"
IfEnd:IfEnd:IfEnd:IfEnd:IfEnd // five IfEnd
........
........
If Q=1
Then Goto 1
IfEnd //add this
Here is a more compact version of your task that performs the same thing
"ABCDE"➝Str 1
Lbl 1:
CltText:" ":" ":" "
For 2➝K To 8 Step 3
RanInt#(1,5)➝R
Locate K,3,StrMid(Str 1,R,1)
Locate K-1,3,RanInt#(0,9)
Next
"Change(1)"?➝Q
If Q=1
Then Goto 1
IfEnd
But without Goto it would be even shorter:
"ABCDE"➝Str 1
Do
CltText:" ":" ":" "
For 2➝K To 8 Step 3
RanInt#(1,5)➝R
Locate K,3,StrMid(Str 1,R,1)
Locate K-1,3,RanInt#(0,9)
Next
"Change(1)"?➝Q
LpWhile Q=1

Edited by Hlib2, 22 May 2020 - 07:06 PM.

  • pan.gejt likes this

#4 Just_A_Noob_Here

Just_A_Noob_Here

    Newbie

  • Members
  • Pip
  • 16 posts

  • Calculators:
    FX-7400 GII, FX-570 ES

Posted 22 May 2020 - 08:18 PM

@Pan.gejt

Oh my! Thank you Pan.gejt!

The second version with separated X;Y;Z programs did the magic!

Next time i'll separate my programs if I'm gonna do big/long programs!

: D !

Thx
Nooblette.

And of course I didn't forget about you @Hlib2!
Your help is appreciated as well!

: D
But right now I dont have my calculator, I only tried pan.gejt version.
I will try your version as well.

:)

#5 pan.gejt

pan.gejt

    Casio Freak

  • Members
  • PipPipPipPip
  • 264 posts
  • Gender:Male
  • Location:CZ

  • Calculators:
    .

Posted 25 May 2020 - 01:55 PM

@Hlib2: great job with strings :-)



#6 Hlib2

Hlib2

    Casio Freak

  • Members
  • PipPipPipPip
  • 142 posts
  • Gender:Male
  • Location:Ukraine
  • Interests:industrial electronics,
    graphing calculators

  • Calculators:
    fx-9860GII-2
    graph-100+
    fx-991DE_X
    ti-89_Titanium
    ti-voyage200
    ti-84+SE

Posted 26 May 2020 - 08:01 PM

You flatter me. This is a very simple task that even a 12-year-old student can master. Someone who programs well on calculators is no more than a mediocre user of all sorts of toys. The real programmer is Sentaro-Krtyski.


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users