PDA

View Full Version : BasiEgaXorz Problems



PCB_Master
12-29-2010, 03:07 PM
It's my first try with the Basic programming language, so expect the code to be sloppy. The code is a simple clock for the Genny, and it works fine, except it will not go from 59 minutes to 0, nor will it increase the hour. WHAT IS GOING ON?

Edit: For those who do not have BasiEgaXors, here is the code:


reigon=UnitType()
if reigon != 1 then goto PAL
print "Clock Demo - PCB_Master 2010"
sleep 120
cls
sleep 1
print "Please use the joypad to set the time."
sleep 60
time_H=0
time_M=00
time_TOD=0
cls
while 1
print "Please set the hour."
print ;time_H;
if joypad().0 then time_H=time_H+1

if joypad().1 then time_H=time_H-1

if joypad().6 then goto setMin

sleep 10
cls
wend

setMin
cls
sleep 30
while 1
print "Please set the minute."
print ;time_M;
if joypad().0 then time_M=time_M+1

if joypad().1 then time_M=time_M-1

if joypad().6 then goto setTOD

sleep 10
cls
wend

setTOD
cls
sleep 30
while 1
print "Please set the Time of Day."
if time_TOD == 0 then
print "AM"
else
print "PM"
endif

if joypad().0 then time_TOD=1

if joypad().1 then time_TOD=0

if joypad().6 then goto clock

sleep 10
cls
wend

clock
while 1
cls
if time_TOD == 0 then
print ;time_H; ":" ;time_M; " AM"
else
print ;time_H; ":" ;time_M; " PM"
endif
sleep 3600
time_M=time_M+1

if time_M == 60 then
time_H=time_H+1
time_M=0
endif

if time_H == 12 [and] time_M == 0 then
if time_TOD == 0 then
time_TOD=1
else
time_TOD=0
endif
endif

if time_H == 13 then time_H=1

wend

PAL
print "This software was designed to run on an US or EU Console. Sorry!"

endp
print " "
print "Program Halt."

Twimfy
12-29-2010, 08:03 PM
Hmmm, I've looked at this over and over and I can't see what's wrong.

My only suggestion would be to seperate this part:

if time_M == 60 then
time_H=time_H+1
time_M=0
endif

Into seperate endif sections, even though basic is read in sequence there's the possibility that time_M=0 is being set to zero before time_H is incremented.

Just a guess. It's been a long time since I used basic.

PCB_Master
12-29-2010, 09:28 PM
Hmmm, I've looked at this over and over and I can't see what's wrong.

My only suggestion would be to seperate this part:

if time_M == 60 then
time_H=time_H+1
time_M=0
endif

Into seperate endif sections, even though basic is read in sequence there's the possibility that time_M=0 is being set to zero before time_H is incremented.

Just a guess. It's been a long time since I used basic.

Thanks, but I just fixed the problem. For some reason, this - if time_M == 60 then - won't work but - if time_M > 59 - will. Go figure.

Twimfy
12-29-2010, 10:07 PM
Weird, I can't see what difference it would make. Oh well at least it's working!

Dreamcast
12-29-2010, 10:15 PM
The problem is the C-style double equal (==) for comparison. In BASIC, a single equal sign if used for assignment and comparison.

So, it would be: if time_M = 60 then ...

PCB_Master
12-29-2010, 11:10 PM
The problem is the C-style double equal (==) for comparison. In BASIC, a single equal sign if used for assignment and comparison.

So, it would be: if time_M = 60 then ...

So there is a difference between time_m=60 (setting the variable) and time_m = 60 (checking if time_M equals 60)?

Dreamcast
12-30-2010, 12:06 AM
Yes, correct. If the expression follows any of the conditionals (if, while, etc) then the interpreter / compiler sees it as comparative.