I think first some baby steps, I have started the program below which I intend it to be command driven, so for instance if I type in a 'quit' command on the remote terminal, the program below will then end. In my other program, FBterm.bas, it was basically a char driven program, type in a char, and it gets displayed on the remote terminal.
So the first concept I am having difficulty with is comparing and responding to a string of characters which will be terminated with a CR. I know that in the C language they have a string compare command, which really simplified things, but it looks like in FB you have to capture the whole string, a char at a time, and then somehow compare it to the command string? Not sure as to how this would be done, and result in an expected manner. So, if somebody could give me a hint, the compare strings command perhaps, it would greatly appreciated. Or maybe there is a different way to do this then what I have shown below?
Thanks in advance
Code: Select all
'XBredun.bas dim as string Key,buffer Open Com "/dev/ttyUSB0:9600,n,8,1,cs0,ds0,cd0,rs" As #1 sleep 1000,1 if Err <> 0 then print "Error opening port"; sleep 2000,1 cls goto Cend End if print "Test program." print #1, " XBredun program" 'Main serial receive and respond routine Do Key = inkey$ if Key = chr$(27) then ' Local Esc key exit do end if While Loc(1) > 0 buffer = input$(loc(1),#1) 'print #1, buffer; ' debug, check if echo back if buffer = chr$(27) then ' Esc on remote terminal goto Cend end if if buffer = "quit" then goto Cend end if Wend Sleep 1,0 Loop Cend: print #1, "Stopping XBredun"; Close End