Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / RETURNKEY() / SCANCODE() Troubles

Author
Message
Jay Bee
18
Years of Service
User Offline
Joined: 15th Jul 2006
Location: Ashford, Kent, England
Posted: 18th Jul 2006 05:03
I am just getting to grips with tempest, and I\'m making a simple chat client. For some reason this seems to work fine whenever I remove scancode() or returnkey(), they seem to crash it, its really weird the display mode even changes when I haven\'t told it too. ARGH!


size = 26
Print \"1 - Host Chat Client:\"
Input \"2 - Join Chat Client: \", choice
if (choice > 2) OR (choice < 1) then END
if choice = 1 then GOSUB _host
if choice = 2 then GOSUB _join
OURID = TGetThisID() `Stores the ID of the user
dim CHATLOG(size,1) AS STRING `This holds the strings sent my other players, so that the messages may \"move up the screen\" msn messenger stylie (or like pretty much any other chat program). The dimension (x,0) holds the name of the user who sent the message. And dimension (x,1) holds the message itself.
index = 0 `this indicates the slot that the chatlogs have got to thus far
x = 0 `cursor x
y = 590 `cursor y

do
CLS
newmessage = TGetMessage()
if newmessage
from = TGetSender()
chatstring$ = TGetString()
`dump message data into chatlog
CHATLOG(index,0) = TGetPlayername(from)
CHATLOG(index,1) = chatstring$
inc index `increment index
if index = size then index = 0 `if the end of the array is reached, go back to the start
endif
y = y - 20 `sets y so that the line below prints above where the user enters their message
set CURSOR x,y
`print aforementioned line
PRINT \"- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \"
y = y - 15 `move cursor up
set CURSOR x,y
if index <> 0
for i = index to 0 STEP -1
`if there is a string in the current slot of the log
if (CHATLOG(i,0)<> \"\") and (CHATLOG(i,1)<> \"\")
`set the cursor up and print in the format name: message
set CURSOR x,y
PRINT CHATLOG(i,0);\": \";
PRINT CHATLOG(i,1)
`move cursor y up for next string
y = y - 20
endif
next i
endif
x = 0
y = 590
set cursor x,y
`this was originally intended to add to a string as keys where pressed, and printing the string so far where the user is entering their message, giving the illusion of an INPUT TEXT,VARIABLE command, only the system doesn\'t need to pause in order for this to happen. Then when the return key is pressed, this message is sent out to all the other users, and dumped into the chat log, and the string storage variable is cleared (though not all of this code is here, as I never got that far)
`outstring$ = outstring$ + INKEY$()
PRINT SCANCODE()
`if RETURNKEY()
` TPutString outstring$
` CHATLOG(index,0) = TGetPlayername(OURID)
` CHATLOG(index,1) = outstring$
` inc index
` if index = size then index = 0
` TSendAll
`Endif
TSync
SYNC
loop



_host:
input \"Enter Max Users: \", MAXPLAYERS
input \"Enter Name: \", nick$
input \"Enter IP: \", ip$
result = THost(ip$, MAXPLAYERS, nick$)
host = 1
`If hosting failed then report to user and quit
if not result
print \"Failed to host game\"
wait key
end
endif
RETURN

_join:
host = 0
input \"Enter Name: \", nick$
input \"Enter IP: \", ip$
result = TJoin(ip$, nick$)

`If hosting failed then report to user and quit
if not result
print \"Failed to join game\"
wait key
end
endif
RETURN

<img src="http://www.freewebs.com/equilibrium-movie/crazyanimationshiit7yq.gif">
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 18th Jul 2006 16:52
Dont double post.


Projects: Online CTF Game | Newcommer's Guide to FPS's
Jay Bee
18
Years of Service
User Offline
Joined: 15th Jul 2006
Location: Ashford, Kent, England
Posted: 18th Jul 2006 20:30
Dude, I didn't get a reply on this forum, so I assumed it was too advanced for this board, don't get shirty bout it...

Your signature has been erased by a mod - 404kb is a little large, don't you think?
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 19th Jul 2006 23:52
That is very odd. Sorry I've got no idea.

My Functions: Mine
Post yours: Post
Jay Bee
18
Years of Service
User Offline
Joined: 15th Jul 2006
Location: Ashford, Kent, England
Posted: 20th Jul 2006 00:07
dont worry it got sorted in the end

Your signature has been erased by a mod - 404kb is a little large, don't you think? Nope not really, but heh, ur the boss

Login to post a reply

Server time is: 2024-11-26 16:40:02
Your offset time is: 2024-11-26 16:40:02