New chat program. need sopme advice 
	 
	
		| Author | 
		Message | 
	 
		 
		GrimGreg
 
 
 
    
		 | 
		
		
			
				  Posted: Tue Feb 20, 2007 3:48 pm    Post subject: New chat program. need sopme advice  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				I was at school, fooling around with that basic chat program, and came up with some new features.
 
 
1. Multiple PORTS for different users.
 
 
2. Displays name before messages.
 
 
I would love to be able to have multiple people in the same room, but i dont know how to do that.
 
 
please help, i would love to be able to do that with this program.
 
 
heres the code i have so far....
 
 
 
[CODE]
 
 
 
 
 
var stream : int := 0 % Used for sending data 
 
var msgBack : string % The message that gets sent back and forth 
 
var address : string % IP address for each computer 
 
var message : string  % Message that you send 
 
var status : int % Status host/client 
 
var name : string % Name to be displayed in chat
 
var room : int
 
const PORT := 5555 % Port to connect through 
 
put "What is your name?"
 
get name
 
cls
 
process Room1
 
const PORT := 5555
 
end Room1
 
 
process Room2
 
const PORT := 5556
 
end Room2
 
 
process Room3
 
const PORT := 5557
 
end Room3
 
 
process Room4
 
const PORT := 5558
 
end Room4
 
 
process Room5
 
const PORT := 5559
 
end Room5
 
 
process Room6
 
const PORT := 5560
 
end Room6
 
 
process Room7
 
const PORT := 5561
 
end Room7
 
 
process Room8
 
const PORT := 5562
 
end Room8
 
 
process Room9
 
const PORT := 5563
 
end Room9
 
 
process Room10
 
const PORT := 5564
 
end Room10
 
 
put "What chatroom did you want to join?"
 
put "  "
 
put "1. Room one"
 
put " "
 
put "2. Room two"
 
put " "
 
put "3. Room three"
 
put " "
 
put "4. Room four"
 
put " "
 
put "5. Room five"
 
put " "
 
put "6. Room six"
 
put " "
 
put "7. Room seven"
 
put " "
 
put "8. Room eight"
 
put " "
 
put "9. Room nine"
 
put " "
 
put "10. Room ten"
 
get room
 
cls
 
if room = 1 then
 
fork Room1
 
elsif room = 2 then
 
fork Room2
 
elsif room = 3 then
 
fork Room3
 
elsif room = 4 then
 
fork Room4
 
elsif room = 5 then
 
fork Room5
 
elsif room = 6 then
 
fork Room6
 
elsif room = 7 then
 
fork Room7
 
elsif room = 8 then
 
fork Room8
 
elsif room = 9 then
 
fork Room9
 
elsif room = 10 then
 
fork Room10
 
else put "Sorry please just enter a numerical value for the room you want to host/join"
 
end if
 
 
 
cls
 
put "What would you like to do?" 
 
put "1:Host" 
 
put "2:Join" 
 
 
 
 
get status 
 
 
if status = 1 then 
 
    stream := Net.WaitForConnection (PORT, address) % Wait for a user to connect 
 
else 
 
    put "What is the IP of the computer you want to connect to?" 
 
    get address 
 
    stream := Net.OpenConnection (address, PORT) % Connect to the IP inputted 
 
end if 
 
cls 
 
put "Connected to ", address, name 
 
 
loop 
 
    if hasch then % If key pressed 
 
    get message : *  % store all input in var message when enter is pressed 
 
       put : stream, name..
 
       put " : "..
 
     put : stream, message  % Send the message over the stream 
 
    end if 
 
    if Net.LineAvailable (stream) then % If a line of text has been sent 
 
        get : stream, msgBack : * % grab the line of text 
 
        put msgBack % print it to the screen 
 
    end if 
 
end loop
 
 
 
 
 
 
[CODE]
 
 
 
just to add to it....heres my revised code so far...i think i have done it to include 3 people, but im not sure if it works yet..ill test it tomorrow probably
 
 
 
[CODE]
 
 
 
 
 
var stream : int := 0 % Used for sending data
 
var msgBack : string % The message that gets sent back and forth
 
var msgBack3rd : string % 3rd person!
 
var address : string % IP address for each computer
 
var message : string  % Message that you send
 
var status : int % Status host/client
 
var name : string % Name to be displayed in chat
 
var room : int
 
const PORT := 5555 % Port to connect through
 
put "What is your name?"
 
get name
 
cls
 
process Room1
 
    const PORT := 5555
 
end Room1
 
 
process Room2
 
    const PORT := 5556
 
end Room2
 
 
process Room3
 
    const PORT := 5557
 
end Room3
 
 
process Room4
 
    const PORT := 5558
 
end Room4
 
 
process Room5
 
    const PORT := 5559
 
end Room5
 
 
process Room6
 
    const PORT := 5560
 
end Room6
 
 
process Room7
 
    const PORT := 5561
 
end Room7
 
 
process Room8
 
    const PORT := 5562
 
end Room8
 
 
process Room9
 
    const PORT := 5563
 
end Room9
 
 
process Room10
 
    const PORT := 5564
 
end Room10
 
 
put "What chatroom did you want to join?"
 
put "  "
 
put "1. Room one"
 
put " "
 
put "2. Room two"
 
put " "
 
put "3. Room three"
 
put " "
 
put "4. Room four"
 
put " "
 
put "5. Room five"
 
put " "
 
put "6. Room six"
 
put " "
 
put "7. Room seven"
 
put " "
 
put "8. Room eight"
 
put " "
 
put "9. Room nine"
 
put " "
 
put "10. Room ten"
 
get room
 
cls
 
if room = 1 then
 
    fork Room1
 
elsif room = 2 then
 
    fork Room2
 
elsif room = 3 then
 
    fork Room3
 
elsif room = 4 then
 
    fork Room4
 
elsif room = 5 then
 
    fork Room5
 
elsif room = 6 then
 
    fork Room6
 
elsif room = 7 then
 
    fork Room7
 
elsif room = 8 then
 
    fork Room8
 
elsif room = 9 then
 
    fork Room9
 
elsif room = 10 then
 
    fork Room10
 
else
 
    put "Sorry please just enter a numerical value for the room you want to host/join"
 
end if
 
 
 
cls
 
 
 
put "What would you like to do?"
 
put "1:Host"
 
put "2:Join"
 
 
 
 
get status
 
 
if status = 1 then
 
    stream := Net.WaitForConnection (PORT, address) % Wait for a user to connect
 
else
 
    put "What is the IP of the computer you want to connect to?"
 
    get address
 
    stream := Net.OpenConnection (address, PORT) % Connect to the IP inputted
 
end if
 
cls
 
put "Connected to ", address
 
put " - "
 
get : stream, name
 
 
loop
 
    if hasch then % If key pressed
 
        get message : * % store all input in var message when enter is pressed
 
        if message = "clearscreen" then
 
            cls
 
            put : stream, name ..
 
            put : stream, " : " ..
 
            put : stream, message % Send the message over the stream
 
        end if
 
    end if
 
    if Net.LineAvailable (stream) then % If a line of text has been sent
 
        get : stream, msgBack : * % grab the line of text
 
        if msgBack = "clearscreen" then
 
            cls
 
        end if
 
        put msgBack % print it to the screen
 
    end if
 
    if Net.LineAvailable (stream) then    % If a line of text has been sent
 
        get : stream, msgBack3rd : * % grab the line of text
 
        if msgBack3rd = "clearscreen" then
 
            cls
 
        end if
 
        put msgBack3rd % print it to the screen
 
    end if
 
end loop
 
 
 
 
 
[CODE] | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
		 
		Sponsor Sponsor 
		 
  
		 | 
		
 | 
	 
	 
		  | 
	 
				 
		rollerdude
 
  
 
    
		 | 
		
		
			
				  Posted: Thu Feb 22, 2007 2:43 pm    Post subject: Re: New chat program. need sopme advice  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				| same advice i gave the other guy...  under examples... look at the netchat program | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		 | 
	 
 
	
	
	 
	
	 |