Im trying to create a net connection chat room, im using the dark basic book as help becuase they have a chapter on this.
But i keep having this problem where it says command out of place...and i dont see what is out of place
If Answer = 1
Print "Creating Net Session. Please Wait..."
Sync
Sleep 200
Set Net Connection TcpipNumber, " "
Create Net Game "Sample Net Session", MyName$, 16, 1
Endif
the command they say is out of place is the 'endif' command.
Ive read all the book on network connections, and this chat room is an example, ive copyed the example so it helps me learn the commands
sync on
sync rate 30
`keep track of who said what
DIM chattext$(32)
DIM PlayerName$(1)
DIM NumberOfPlayers(1)
Dim LastNumberOfPlayers(1)
`find connection
tcpipnumber = FindTVPIPConnectionNumber()
Print "Network Chat Client"
Print
sync
`Get names
Input "Please Enter Your Name: ", MyName$
PlayersName$(1) = MyName$
Sync
Sync
IF MyName$ = ""
Print "You Need To Enter A Name"
Wait key
end
endif
`find out who the hist abd clients are
Print "(1) I'm The Host"
Print "(2) I'm The Client"
sync
sync
A$ = ""
Answer = 0
`get host or client
While answer = o
A$ = inkeys$()
If A$ = "1" Then Answer = 1
If A$ = "2" Then Answer = 2
Endwhile
`do this if host....
If Answer = 1
Print "Creating Net Session. Please Wait..."
Sync
Sleep 200
Set Net Connection TcpipNumber, " "
Create Net Game "Sample Net Session", MyName$, 16, 1
Endif
`do this if client.....
If Answer = 2
input "Please Enter The Hosts IP Adress: ",AdressDate$
Print "Connecting To Nest Session. Please Wait..."
Sync
Set Net Connection TcpipNumber, AddressData$
Perform Checklist For Net Sessions
Numberofgames =Checklist Quantity()
if numberofgames = 0
print "No Sessions Found At That Address"
Sync
wait key
End
endif
join Net Game 1, myname$
print "Connecting To Session"
sync
Endif
`do the chat client
Chatclient()
end
`this function will determine which NET CONNECTION number is TCP/IP
FUNCTION FindTCPIPConnectionNumber()
Flag = 0
cls
PERFORM CHECKLIST FOR NET CONNECTIONS
For x = 1 TO CHECKLIST QUANTITY()
service$ = Checklist string$(x)
If LEFT$(Service$,15)="Internet TCP/IP"
Flag = X
Next x
EndFunction Flag
`This function does all the chat client
FUNCTION ChatClient()
`Clears the chat text from array
ClearChatText()
`Dusplays the players in the room
PERFORM CHECKLIST FOR NET PLAYERS
NumberOfPlayers(1) = Checklist quantity()
For x = 1 To NumberOfPlayers(1)
AddUserMessage(Checklist String$(x))
next x
`send a comming message
C$ = PlayersName$(1)+" has joined."
Send Net Message String 0,C$
`display the chat text
DisplayChatText()
`set the entry buffers
A$ = ""
B$ = ""
C$ = ""
Clear Entry Buffer
`capture text and process it accordingly
While EScapekey()=0
CheckIncommingmessages()
A$ = INKEYS()
If ASC(A$) = 8
C$ = C$ + ENTRY$()
C$ = LEFT$(C$)-1)
CLEAR ENTRY BUFFER
CLS
Displaychattext()
EndifB£ = C$ + ENtry$()
Test 10,460,B$
If RETURNKEY90=1 AND B$ <> ""
Sleep 250
`send remote message
D$ = PlayersName$(1)+!: "+B$
SEND NET MESSAGE STRIMG 0,D$
`Display local message
ADDSTRINGTOCHAT(D$)
D$ = ""
B$ = ""
C$ = ""
Clear entry buffer
`Display new chat window
DisplayChatText()
endif
sync
endwhile
endfunction
`scans the incomming message for strings and displays them
FUNCTION CheckIncommingMessages()
GET NET MESSAGE
IF NET MESSAGE EXISTS()=0 THEN EXITFUNCTION
WHILE NET MESSAGE EXISTS()<>0
MsgType = NET MESSAGE TYPE()
IF MsgType = 3
MSG$ = NET MESSAGE STRING$()
AddStringToChat(Msg$)
DisplayChatText()
Endif
Get NET MESSAGE
ENDWHILE
ENDFUNCTION
`message to display if a user has joined
Function AddUserMessage(Name$)
NewString$ = Name$+" Is here."
AddStringToChat(NewString£)
Endfunction
` adds a stirng to the chattext$ array
function AddStringToChat(a$)
For x = 1 to 32
IF ChatTest£(x) = ""
ChatText(x) = A$
ExitFunction
Endif
Next x
For x = 32 to 2
y = x - 1
ChatText$(y) = ChatText$(x)
Next x
ChatText(32) = A$
Endfunction
`clears the chattext$ variables
Function clearchattext()
for x = 1 to 32
ChatText$(x) = ""
next x
Endfunction
`displays the chat text
FUNCTION DisplayChatText()
CLS
Set Current Bitmap 0
Center TEXT 320,10,"Chat Client"
Next x
endfunction
I copyied it exactly but it still says its wrong
Your signature has been erased by a mod because the mods have nothing better to do and get bored very easy.