forums

TNT Basic Forums > Programming Q&A
Input code bug
< Last Thread     Next Thread >
Author
Thread        Post A Reply

08-29-2003 16:38

Posted by:
mark_667

Location:
England

Click Here to Email mark_667   Find more posts by mark_667

Hi,
while canibalising AsondSoft's 'Input' code for my own game I needed to make a few alterations, for example, making the text appear in a different place on screen, I also deleted a lot of the code to display the cursor, this seemed to work, but now TNT gives me the errors:

2 compile error(s) detected
Compile time error #1
Line# : 1077
Error : Illegal procedure call.
Code : end proc ( input ) 'Returns the value
^^^^^^^^
Compile time error #2
Line# : 1077
Error : Expected an 'End Proc' statement.
Code : end proc ( input ) 'Returns the value
^
I can't see anything wrong with the procedure itself, if anyone thinks they can help, the full relevant code is include below:

graphics mode 640,480
Text Font "courier"
load images 129
Password()

Procedure Password()
set pen colour white
text size 14
draw text 10,76, "WARNING: If you input the wrong code this game will self-destruct!"
fade up
Draw text 10,96,"PLEASE ENTER CODE BELOW:"
new button 4,100,200,12,12,12,129
draw frame
getInput()

if button click = 4 ' Check code
string input 'need to re-declare it here, otherwise it's not recognised
if input="MR02"

Current_Map=129
Load map Current_Map
draw map section 0,0 to 19,19,0 to 0,0
ProgressBar()
CollisionDetection() 'Ignore for now
MakeOpponents()
else
beep 3
TitleScreen()
end if
end if

end proc

Procedure getInput()

string result=result string
string keymap[128]
String input
String temp=""
int time,timeto
int Current_pos=0
int n,i

open canvas 2,640,480
open viewport 2,0,0 to 640,480
canvas 2

input=""
' set the keymap
keymap[0]="a"
keymap[1]="s"
keymap[2]="d"
keymap[3]="f"
keymap[4]="h"
keymap[5]="g"
keymap[6]="z"
keymap[7]="x"
keymap[8]="c"
keymap[9]="v"
keymap[10]="/"
keymap[11]="b"
keymap[12]="q"
keymap[13]="w"
keymap[14]="e"
keymap[15]="r"
keymap[16]="y"
keymap[17]="t"
keymap[18]="1"
keymap[19]="2"
keymap[20]="3"
keymap[21]="4"
keymap[22]="6"
keymap[23]="5"
keymap[24]="="
keymap[25]="9"
keymap[26]="7"
keymap[27]="-"
keymap[28]="8"
keymap[29]="0"
keymap[30]="]"
keymap[31]="o"
keymap[32]="u"
keymap[33]="["
keymap[34]="i"
keymap[35]="p"
keymap[36]=" "
keymap[37]="l"
keymap[38]="j"
keymap[39]="'"
keymap[40]="k"
keymap[41]=";"
keymap[42]=" "
keymap[43]=","
keymap[44]=" "
keymap[45]="n"
keymap[46]="m"
keymap[47]="."
keymap[48]=" "
keymap[49]=" "
keymap[50]="~"

canvas 2
while not pressed(36)

for n=0 to 50 step 1
if pressed(n)
if not pressed(56) then input=input+keymap[n]
if pressed(56) then input=input+upper case(keymap[n]) 'What to do if caps lock is pressed

for i=0 to string length (input)
temp=temp+get char(input,i)
if Current_pos=i
if not pressed(56) then temp=temp+keymap[n]
if pressed(56) then temp=temp+upper case(keymap[n])
end if
next i
input=temp
Current_pos=Current_pos+1 'Make the curser move after a key is typed
if Current_pos>string length(input) then Current_pos=Current_pos-1

if pressed(51) 'Delete a character
input=remove char(input,Current_pos)
Current_pos=Current_pos-1
if Current_pos<0 then Current_pos=Current_pos-1
end if

draw text 10,106,input
delay 100
draw frame

end proc ( input ) 'Returns the value

08-29-2003 18:14

Posted by:
eekaydee

Location:
CA, USA

Click Here to Email eekaydee   Find more posts by eekaydee

When the compiler errors contradict themselves, like first saying that "end proc" is illegal and then saying that "end proc" is expected, it's usually something like a missing quote or end if or something like that.

In your case:
line#103: while not pressed(36)
is missing a "wend" to close the loop,

line#105:for n=0 to 50 step 1
is missing a "next" to close the loop,

and you are missing an "end if", which I think is for
line#106:if pressed(n)

08-30-2003 20:10

Posted by:
mark_667

Location:
England

Click Here to Email mark_667   Find more posts by mark_667

thanks for the info, I did originally put a 'wend' in, but this in itself was highlighted as an error, thanks for the tip on the other twoo things though :-)

08-31-2003 13:01

Posted by:
mark_667

Location:
England

Click Here to Email mark_667   Find more posts by mark_667

Most sorry - disregard my last post; the alterations you suggested got rid of all the errors, but the text still does not appear for some reason? The code is the same as above, except for:

canvas 2
while not pressed(36)

for n=0 to 50 step 1
if pressed(n)
if not pressed(56) then input=input+keymap[n]
if pressed(56) then input=input+upper case(keymap[n]) 'What to do if caps lock is pressed

for i=0 to string length (input)
temp=temp+get char(input,i)
if Current_pos=i
if not pressed(56) then temp=temp+keymap[n]
if pressed(56) then temp=temp+upper case(keymap[n])
end if
next i
input=temp
Current_pos=Current_pos+1 'Make the curser move after a key is typed
if Current_pos>string length(input) then Current_pos=Current_pos-1

if pressed(51) 'Delete a character
input=remove char(input,Current_pos)
Current_pos=Current_pos-1
if Current_pos<0 then Current_pos=Current_pos-1
end if
end if
next n
wend

draw text 10,106,input
delay 100
draw frame

end proc ( input ) 'Returns the value

08-31-2003 14:08

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

Do you see the window? Is the text color similar to the background? Is that the only code ( I'm sure you ddn,t delete the keymaps but I have to verify all possibilities ) ?

08-31-2003 14:10

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

Oh, never mind last post. Draw text, draw frame goes in the while loop ( otherwise the text is drawn when the user has finished his input! )

09-03-2003 13:10

Posted by:
mark_667

Location:
England

Click Here to Email mark_667   Find more posts by mark_667

Solved!

Thanks to Matthew especially for giving me a few pointers about the cursers, it's now fully fixed. :-)

All times are GMT        Post A Reply

Forum Jump:
< Last Thread     Next Thread >

< Contact Us - TNT Basic >

Powered by: vBulletin Lite Version 1.0.1 Lite
Copyright © Jelsoft Enterprises Limited 2000.