Author Topic: FOR/NEXT loop slightly upset by variable name  (Read 2028 times)

MrTAToad

  • Guest
With this example :

Code: (glbasic) [Select]
LOCAL DISINTEGRATOR%,l%

FOR l%=DISINTEGRATOR% TO DISINTEGRATOR%+1
NEXT

You get :

Quote
C:\Users\Nicholas\AppData\Local\Temp\glbasic\gpc_temp0.cpp: In function `int __GLBASIC__::__MainGameSub_()':
C:\Users\Nicholas\AppData\Local\Temp\glbasic\gpc_temp0.cpp:33: error: `DISINTEGRA' was not declared in this scope
C:\Users\Nicholas\AppData\Local\Temp\glbasic\gpc_temp0.cpp:33: error: `R' was not declared in this scope
C:\Users\Nicholas\AppData\Local\Temp\glbasic\gpc_temp0.cpp:33: error: expected `;' before "TO"
C:\Users\Nicholas\AppData\Local\Temp\glbasic\gpc_temp0.cpp:33: error: `TO' was not declared in this scope
C:\Users\Nicholas\AppData\Local\Temp\glbasic\gpc_temp0.cpp:33: error: expected `)' before "DISINTEGRATOR"
C:\Users\Nicholas\AppData\Local\Temp\glbasic\gpc_temp0.cpp:33: error: expected `;' before ')' token

Because "OR" is used.  However, this is only a problem in loops - without them, the program will work fine...

Offline erico

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 4397
    • View Profile
    • FUED
Re: FOR/NEXT loop slightly upset by variable name
« Reply #1 on: 2011-Jun-04 »
I really donĀ“t know, but a variable called DISINTEGRATOR%...
It must be something great! :P

Offline Qedo

  • Dr. Type
  • ****
  • Posts: 355
  • to program what I have do how should programming?
    • View Profile
Re: FOR/NEXT loop slightly upset by variable name
« Reply #2 on: 2011-Jun-04 »
I think the problem is TO and no OR.
Try with NOTO% or RETOMA%

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10817
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: FOR/NEXT loop slightly upset by variable name
« Reply #3 on: 2011-Jun-06 »
aw, man. Can't we just disallow all-caps variables? :P

MrTAToad

  • Guest
Re: FOR/NEXT loop slightly upset by variable name
« Reply #4 on: 2011-Jun-06 »
Oh no - they signify the importance of the variable :)

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10817
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: FOR/NEXT loop slightly upset by variable name
« Reply #5 on: 2011-Jun-06 »
DISSOLVER% ?  =D

I'll have a look.