Jump to content


Photo

Cannot Compare Arguments


  • Please log in to reply
4 replies to this topic

#1 pancak4s

pancak4s

    GMC Member

  • New Member
  • 80 posts
  • Version:GM8

Posted 07 August 2012 - 11:02 PM

So I have my highscore set in the create event to 0 if the text file doesn't exist... but if it does, I make the highscore equal to the first line in the text file in teh create event. But when I ask if global. points >= highscore in the step event.... it gives the 'cannot compare arguments' error. I also tried it in keyboard press space event... same error.


Why..?
  • 0

#2 PetzI

PetzI

    GMC Member

  • GMC Member
  • 1025 posts
  • Version:GM8.1

Posted 07 August 2012 - 11:22 PM

Code. You need to post the code you're using, people here can't guess what the problem is from a vague description.
  • 0

#3 thegame

thegame

    Flying Penguin

  • GMC Member
  • 1404 posts
  • Version:GM:Studio

Posted 07 August 2012 - 11:33 PM

Generally the 'Cannot compare arguments' error is caused by 2 different types of values being compared, i.e. number compared to string.

An easy way to fix it is to put string(value1) == string(value2) if you are comparing something that may have letters, or real(value1) == real(value2) if you are sure it will only have numbers.
  • 1

#4 PetzI

PetzI

    GMC Member

  • GMC Member
  • 1025 posts
  • Version:GM8.1

Posted 07 August 2012 - 11:47 PM

Generally the 'Cannot compare arguments' error is caused by 2 different types of values being compared, i.e. number compared to string.

An easy way to fix it is to put string(value1) == string(value2) if you are comparing something that may have letters, or real(value1) == real(value2) if you are sure it will only have numbers.


Man, you just made me feel kind of stupid for not realizing that... The problem is that text files save everything as strings, so you have to apply the real() function to the value you're reading from the file.
  • 0

#5 pancak4s

pancak4s

    GMC Member

  • New Member
  • 80 posts
  • Version:GM8

Posted 08 August 2012 - 01:17 AM


Generally the 'Cannot compare arguments' error is caused by 2 different types of values being compared, i.e. number compared to string.

An easy way to fix it is to put string(value1) == string(value2) if you are comparing something that may have letters, or real(value1) == real(value2) if you are sure it will only have numbers.


Man, you just made me feel kind of stupid for not realizing that... The problem is that text files save everything as strings, so you have to apply the real() function to the value you're reading from the file.


I was just about to say that my description was well enough since I added string() and it worked. Thanks thegame! (I +1'd :) )
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users