Hi Im trying to emulate a console within a form, are there any good tutorials anyone knows about that show how to accomplish this?, basically it will allow you to type commands and terminate them etc.
Sorry, but I don't really understand what you want to do.
Do you have a more concrete example ?
Or even a beginning of code ?
What do you want to do with the 'commands' ?
How many 'commands' do you imagine.
An easy way could be a TextBox where you can enter a command line and a button to execute the command.
But without more precise information it is difficult to give good advices.
Sorry, but I don't really understand what you want to do.
Do you have a more concrete example ?
Or even a beginning of code ?
What do you want to do with the 'commands' ?
How many 'commands' do you imagine.
An easy way could be a TextBox where you can enter a command line and a button to execute the command.
But without more precise information it is difficult to give good advices.
In regards to your question I talking about displaying a stream of data in a textbox from say a telnet connection, but my first hurdle is how to enter commands into the same text box while seeing a display output, the problem is do i store the text into an variable array to show each terminal sentence etc per index of the array:-
Dim TextOut(255) as string -each index stores each line or sentence terminal etc
or is it better to store the whole thing in a file and refer to a line by method etc.
Im having problems referencing how each line or sentence is stored so that i can interpret the commands etc.
That last example is along the same lines but the problem is the method for storing this data or referencing it.
If I type say "OPEN C 23.34.33.2"
the output might be:- "CON 23.34.33.2: Error" or "CON 23.34.33.2: SUCCESS" or "Connecting to server"
this will show on the next line, but how would I prevent User Input data from being mixed up with Output data etc. Does this make sense?
BTw the commands are simple handshakes DO,WONT,WILL,DONT
The server is a mud, this is part of the code i have been working through, sorry if this is newbie style.
i connect to it using:-
B4X:
client.New1
server.New1(23)
client.Connect("IP",23)
stream.New1(client.GetStream,False)
Msgbox("Connected!")
QuitMe=False
Do
ReceiveDisp
UserInput
Until QuitMe=True
'Msgbox(StrLength(s))
client.Close
End Sub
Sub ReceiveDisp()
Do
data = stream.readbyte 'Reads each byte until a linefeed is seen
If data=10 Then txtOut.Text = txtOut.Text & CRLF
txtOut.Text = txtOut.Text & Chr(data)
txtOut.SelectionStart = StrLength(txtOut.Text)-2
txtOut.ScrollToCaret
Loop Until client.DataAvailable=False
End Sub
Sub UserInput()
Dim d
d=stream.Writebyte(Asc(cmd))
if cmd="q" then QuitMe=True
End Sub
Sub txtReceive_KeyPress (key)
If key=Chr(13) Then
Cmd=StrAt(txtOut.Text,StrLength(txtOut.Text)-2)
endif
End If
End Sub
What I mean in the UserInput sub, I want to send data to the server Mud, but im unsure how you send data to the server.
You don't need a server, the MUD thingy is a server.
To send data use WriteByte or WriteBytes on the stream. You probably can't use WriteString as that sends size information prepended to the string that your MUD server probably won't understand. You can convert strings to a byte array using the StringToBytes method of the stream.
Ive managed to stream text from a mud server sucessfully into console textbox of a fashion, on the pc though this is quite fluid but on the pocket pc it is very very slow, almost like 1 letter every 0.5 sec is streaming.
My question is do you think by streaming to a file would help in this scenario or is there a speed limitation on multiline text boxes?