Jump to content



Photo
- - - - -

"String Output" Syntax ERROR

syntax error syntax error BASIC CASIO CASIO BASIC string output

Best Answer (*) , 09 August 2017 - 05:21 AM

The part

"ERROR: Not in range.

you forgot the last ",

It has to be: "ERROR: Not in range."

Go to the full post


  • Please log in to reply
4 replies to this topic

#1 hoobigii

hoobigii

    Newbie

  • Members
  • Pip
  • 5 posts
  • Gender:Not Telling

Posted 09 August 2017 - 05:06 AM

Hello, all!

I just got my CASIO fx-9860GII SD and found out it was possible to program on it. (Yes, I've been living under a rock.)

I thought this was perfect for eliminating grunt work.

 

Anyway, I wrote this program which helps with factoring quadratic expressions.

The program brute forces through all the possible combination of E and F within an inputted range. It tries to find a combination that satisfies both E + F = B and E * F = D (where D is the product of A and C in the standard quadratic expression).

 

The problem is I keep getting a syntax error, and the cursor is at the end of the code right before the quotation mark. I skimmed through Ch. 8 of the manual, but the only thing I found is that the debugger doesn't always put the cursor in the correct place. I read the code a couple of times; I couldn't figure out what is wrong.

I thought might have a mistake with the while loop or the if statements because I come from C++ where you just put brackets, but I checked the syntax in the manual and it seemed correct.

 

(I also tried removing ""END"" but the syntax error went in between the F and the little triangle thing.)

 

Here is the code:

Filename:QUADSPLT
"Ax^2+Bx+CãAx^2+Ex+Fx+C"Ù
""Ù
"Enter range to search for E and F"Ù
?ãRÙ
-RãEÙ
-RãFÙ
Ù
"Enter A"Ù
?ãAÙ
"EnterB"Ù
?ãBÙ
"Enter C"Ù
?ãCÙ
AÀCãDÙ
Ù
Ù
While (EÀFÈD) And (E+FÈB)Ù
If (E=R) And (F=R)Ù
Then Ù
"ERROR: Not in range.Ù
StopÙ
IfEndÙ
Ù
If E=RÙ
Then Ù
-RãEÙ
F+1ãFÙ
Else Ù
E+1ãEÙ
IfEndÙ
WhileEndÙ
Ù
"E="Ù
EØ
"F="Ù
FØ
"END"

The formatting doesn't work that well on the browser, so here is a download to the G1M file: https://www.dropbox....ADSPLT.G1M?dl=0



#2 (*)

(*)

    Casio Addict

  • Members
  • PipPipPip
  • 51 posts
  • Gender:Not Telling

Posted 09 August 2017 - 05:21 AM   Best Answer

The part

"ERROR: Not in range.

you forgot the last ",

It has to be: "ERROR: Not in range."



#3 hoobigii

hoobigii

    Newbie

  • Members
  • Pip
  • 5 posts
  • Gender:Not Telling

Posted 09 August 2017 - 05:54 AM

The part

"ERROR: Not in range.

you forgot the last ",

It has to be: "ERROR: Not in range."

Oh, I'm such an idiot. xD

I read the code like 20 times trying to figure out what is wrong.

Anyway, that fixes the syntax error, however, the results are not as expected (I don't think its the logic because I tried coding it in C++, and it works).

This is what I get when I input 10 for R, 2 for A, 5 for B ,3 for C:

E = -1

F = -6

 

I expected:

E = 3

F = 2

 

Should I start a new topic?

 

EDIT: Also do you know if there is a better way to program CASIO BASIC (like an actual IDE with a good debugger and colors :P)


Edited by hoobigii, 09 August 2017 - 05:59 AM.


#4 anon34

anon34

    Casio Freak

  • Members
  • PipPipPipPip
  • 268 posts

Posted 09 August 2017 - 07:27 AM

It is the logic. "While (E*F!=D) Or (E+F!=B)" should be what you want.

And why can't you just use the quadratic formula?

Edited by user202729, 09 August 2017 - 07:28 AM.


#5 hoobigii

hoobigii

    Newbie

  • Members
  • Pip
  • 5 posts
  • Gender:Not Telling

Posted 09 August 2017 - 08:50 AM

It is the logic. "While (E*F!=D) Or (E+F!=B)" should be what you want.

And why can't you just use the quadratic formula?

That works now, thanks. It makes sense now that you brought it up to my attention :P

I'm am not using the quadratic formula because I am trying to make math more fun and not just do the math on the calculator. I find the factoring part really satisfying; however, find the two numbers whose product is a*c and sum up to b is really boring.

 

 

EDIT: Never mind. I'm an idiot; I typed in an or. Why didn't I notice that?!  :banghead:

 

Now I find it weird that my "prototype" works:

#include <iostream>

int main()
{
    std::cout << "Ax^2+Bx+C->Ax^2+Ex+Fx+C\n\n";
    std::cout << "Enter range:";
    int R;
    std::cin >> R;
    int E;
    int F;
    E = -R;
    F = -R;
    
    std::cout << "Enter A:";
    int A;
    std::cin >> A;
    std::cout << "Enter B:";
    int B;
    std::cin >> B;
    std::cout << "Enter C:";
    int C;
    std::cin >> C;
    int D;
    D = A * C;
    
    while ((E*F!=D) || (E+F!=B))
    {
        if (E == R)
        {
            E = -R;
            F++;
        }
        if ((E == R) || (F == R))
        {
            std::cout << "ERROR: Not in range.";
            return -1;
        }
        E++;
    }
    std::cout << "E=" << E << "\n";
    std::cout << "F=" << F << "\n";
    return 0;
}

Edited by hoobigii, 09 August 2017 - 08:56 AM.




Also tagged with one or more of these keywords: syntax error, syntax, error, BASIC, CASIO, CASIO BASIC, string, output

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users