MyTerminal prog
Look at the color statement.
color foreground,background
I don't think you'll have much luck finding a DOS driver to support a USB/RS232 interface. Serial port cards are fairly cheap. That would probably be a better route to go.
Good luck on your program. I'll be on vacation for the next week and look forward to seeing your progress when I get back.
color foreground,background
I don't think you'll have much luck finding a DOS driver to support a USB/RS232 interface. Serial port cards are fairly cheap. That would probably be a better route to go.
Good luck on your program. I'll be on vacation for the next week and look forward to seeing your progress when I get back.
I think I figured out why DOS-C was rebooting, it did not like the abrupt ' end ' statements in the F10 code segment, and other places where I used it. So far it works in both systems, EDR-DOS, and DOS-C. I added some color, and trapped the F1, and F2 keys for errors when used incorrectly.
If anybody is using this, in order to change the values for the F1, and F2 keys, you just keep pressing the key. The F4 key takes in non-ASCII chars, i.e., byte values, as opposed to string values. I needed this so I could send some values to my Roomba/Create robots; now I will have to try this out with my robots.
Still a lot more to do with this program, thinking about how to incorporate a mouse with this. I think that the program should check for a mouse, and then do the functionality of the F keys, and be able to respond to the F keys also. This might take me a while to accomplish.
Thanks
[/quote]
If anybody is using this, in order to change the values for the F1, and F2 keys, you just keep pressing the key. The F4 key takes in non-ASCII chars, i.e., byte values, as opposed to string values. I needed this so I could send some values to my Roomba/Create robots; now I will have to try this out with my robots.
Still a lot more to do with this program, thinking about how to incorporate a mouse with this. I think that the program should check for a mouse, and then do the functionality of the F keys, and be able to respond to the F keys also. This might take me a while to accomplish.
Thanks
Code: Select all
' FBterm.bas
' FBterm.exe
' Started on December 6, 2008
' December 12, 2008 Ver .06
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Grabs the exiting values of the command prompt window
'1 = cursor on, and 0 = cursor off
locate ,,1 'This locates the cursor at 0,0 position
dim as integer oldcolor = color
dim as integer oldwidth = width
cls
'New code goes here
dim as string Key,buffer 'Define for a string value
dim Corig as Uinteger 'Grab original color
dim numtosend as string 'Terminal area
dim numtosend2 as Ubyte 'Terminal area
dim as integer pos1,pos2,p,b 'Terminal area
'F key bar
dim as string port(1 to 4) = {"COM1:","COM2:","COM3:","COM4:"}
dim as string baud(1 to 10) = {"110","300","1200","2400","4800","9600","19200","38400","57600","115200"}
locate 1,1
p=1
b=1
Corig = color() 'Grab the color
begin:
locate 1,1
color (7,9) '7=white,9=light blue
view print 1 to hiword(Width)
print "FBterm "
print "F1 - ";baud(b),"F2 - ";port(p),"F3 - Connect",,"F10 - Quit "
do
Key = Inkey$
if Key = chr$(255) & chr$(68) then 'F10 Quit the program
close #1
view print 1 to hiword(Width)
cls
goto cend
end if
if Key = chr$(255) & chr$(59) then 'F1 Baud selection
b += 1
if b = 11 then b =1 'Cycle through up to one past the baud count
locate 2,6
print " ";
locate 2,6
print baud(b);
end if
if Key = chr$(255) & chr$(60) then 'F2 Port selection
p += 1
if p = 5 then p = 1 'Cycle through up to one past the port count
locate 2,20
print port(p);
end if
if Key = chr$(255) & chr$(61) then 'F3 Connection
exit do
end if
sleep 1
loop
locate 2,1
print "Baud";
locate 2,15
print "Port";
locate 2,34
print "Disconnect";
locate 3,1
print "Press F4 to send a number"
view print 4 to Hiword(Width) 'Terminal screen starts at line 4
color (loword(Corig),hiword(Corig)) 'Restore the color
'Open the Com port
'open com "COM1:9600,n,8,1,cs0,ds0,cd0,rs" as #1
open com port(p) & baud(b) & ",n,8,1,cs0,ds0,cd0,rs" as #1
'Check if port was opened
if Err <> 0 then
print "Error opening",port(p);
sleep
goto cend
end if
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'This is the main do ...loop
do
key = inkey$
'Check for the key to quit the program
if Key = chr$(255) & chr$(68) then 'chr$(27) the esc Key
exit do
end if
if Key = chr$(255) & chr$(61) then 'F3 to disconnect
close #1
view print 1 to hiword(Width)
locate 1,3
print " "
cls 'Clear the terminal screen after a disconnect
goto begin
end if
'Check for F1 - Error check
if Key = chr$(255) & chr$(59) then
print "ERROR - Do a DISCONNECT first!"
Key = chr$(8)
end if
'Check for F2 - Error check
if Key = chr$(255) & chr$(60) then
print "ERROR - Do a DISCONNECT first!"
Key = chr$(8)
end if
'Check for F4 - send a number sequence
if Key = chr$(255) + chr$(62) then 'the F4 key
input "Enter a number to send (0 - 255) space delimited"; numtosend
pos1 = instr(numtosend, " ")
if pos1 = 0 and len(numtosend) > 0 then
print #1, chr$(val(numtosend));
print chr$(val(numtosend));
else
numtosend2 = val(left$(numtosend,pos1))
print #1, chr$(numtosend2);
print chr$(numtosend2);
do while pos1 >0
pos2 = pos1
pos1 = instr(pos1+1, numtosend, " ")
numtosend2 = val(mid$(numtosend,pos2+1,pos1-pos2))
print #1, chr$(numtosend2);
print chr$(numtosend2);
loop
end if
end if
'Send the keypress
if Key <> "" then
if Key = chr$(13) then 'Check if CR has been pressed
print #1, chr$(13) 'Send the CR and do a CR
print chr$(10); 'Do a linefeed
end if
print #1,Key; 'This sends a char, print with ; = no new line
print Key; 'Echo the keypress
end if
'Receive and display the char
while Loc(1) > 0
buffer = input$(Loc(1),#1) 'This receives a char
print buffer;
wend
sleep 1,0
loop
'End of main do ... loop
cend:
view print 1 to hiword(Width)
cls
' Restore the command prompt window to the old settings
width oldwidth and &hFFFF, oldwidth shr 16
color oldcolor and &hFFFF, oldcolor shr 16
view print 1 to oldwidth shr 16
' cls
Not sure what you mean by DOS-C, the precursor to FreeDOS?? Why would you use that instead of more-mature FreeDOS? (Get some FreeDOS stuff from my page.)
Also, Eric Auer wrote a tiny DOS terminal program in NASM which may be helpful to you. Otherwise, I got nothing else to say. :-)
http://www.ibiblio.org/pub/micro/pc-stu ... /terminal/
Also, Eric Auer wrote a tiny DOS terminal program in NASM which may be helpful to you. Otherwise, I got nothing else to say. :-)
http://www.ibiblio.org/pub/micro/pc-stu ... /terminal/
Yes, the original DOS-C! I plan on using DOS-C as a loader for 32-bit programs. My terminal program is a way of learning FB, and to see if it will run into any problems with DOS-C. As for freeDOS, I do not want to work with the extra bloat, and PC, that it has acquired, KISS is a good guideline. I like the original intent of DOS-C! And I want to control my IP.
My next big project will be to port DOS-C to openWATCOM C, I used to have Borland 3.1 somewhere, but cannot find it.
My next FB project will be a command program, to look like an IDE, maybe, that will run my terminal program, an editor, ..., etc. This way I do not have to deal with the limitations of the available memory managers. At this point working in ring 0 is just fine, things just might change along the way though.
Thanks
My next big project will be to port DOS-C to openWATCOM C, I used to have Borland 3.1 somewhere, but cannot find it.
My next FB project will be a command program, to look like an IDE, maybe, that will run my terminal program, an editor, ..., etc. This way I do not have to deal with the limitations of the available memory managers. At this point working in ring 0 is just fine, things just might change along the way though.
Thanks
Well, I tried out my terminal program with one of my robots, I was very pleased with the outcome. Thanks phishguy, for the code, and guidance so far.
Since I have one of my robots set up with Bluetooth, I guess I will need to have a windows version of my terminal program, so I can access one of the Bluetooth ports on my windows setup. I will have to delay the addition of a mouse to the program for the time being.
Does anybody have any ideas as to what I would need to do to my terminal program in order to have it run in a window as oppoosed to having it run in the full screen? I have not tried to compile the program with the windows version of fbc, but I do not anticipate any problems.
Thanks
Since I have one of my robots set up with Bluetooth, I guess I will need to have a windows version of my terminal program, so I can access one of the Bluetooth ports on my windows setup. I will have to delay the addition of a mouse to the program for the time being.
Does anybody have any ideas as to what I would need to do to my terminal program in order to have it run in a window as oppoosed to having it run in the full screen? I have not tried to compile the program with the windows version of fbc, but I do not anticipate any problems.
Thanks
I compiled my program with the windows version of FBC, and to my surprise it opens up in a DOS box window, plus the program works. I tested it out with the robots, and the Bluetooth, that also worked.
Now, I guess it's back to the mouse thing. I am thinking that it should work something like the Edit program in the DOS box. What I would like to do is to be able to move the cursor over to the F1 key title, and be able to click the left button to cycle through the values, which would also work for F2, F3, F4, and F10 titles. With this concept the program should be able to look, and act the same way in the DOS setup also.
I think this is going to get a little complicated, so I will start another thread to deal with the ideas, and coding which will discuss mouse control.
Has anybody tested my terminal program? Does it work on somebody elses computer? Feedback would be nice.
Thanks
Now, I guess it's back to the mouse thing. I am thinking that it should work something like the Edit program in the DOS box. What I would like to do is to be able to move the cursor over to the F1 key title, and be able to click the left button to cycle through the values, which would also work for F2, F3, F4, and F10 titles. With this concept the program should be able to look, and act the same way in the DOS setup also.
I think this is going to get a little complicated, so I will start another thread to deal with the ideas, and coding which will discuss mouse control.
Has anybody tested my terminal program? Does it work on somebody elses computer? Feedback would be nice.
Thanks
Here is my latest attempt at having a mouse, and keyboard input available. In the program, the red tabs are mouse active, the big problem is that in the terminal area, the text cursor is no longer there. So, you really do not know where you are at when you start the program.
I guess I need some experts to show me how I can get the text cursor in the terminal screen area to show. I do not have to many comments, so it might be a little difficult to follow. Does this need a rewrite to get what I want?
Thanks
I guess I need some experts to show me how I can get the text cursor in the terminal screen area to show. I do not have to many comments, so it might be a little difficult to follow. Does this need a rewrite to get what I want?
Thanks
Code: Select all
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Test4.bas
'
' Grabs the exiting values of the command prompt window
locate ,,0
dim as integer oldcolor = color
dim as integer oldwidth = width
'Your new code goes here
screen 12 'Selects the screen resolution
dim Corig as Uinteger
dim as integer pos1,pos2,b,p
dim as string Key,buffer
dim numtosend as string
dim numtosend2 as Ubyte
dim as string baud(0 to 9) = {"110","300","1200","2400","4800","9600","19200","38400","57600","115200"}
dim as string port(0 to 3) = {"COM1:","COM2:","COM3:","COM4:"}
Corig = color()
'Variables for the mouse info '''''''''''''''''''''
dim x as integer, y as integer, buttons as integer
dim res as integer
'''''''''''''''''''''''''''''''''''''''''''''''''''
'Subroutines, Functions, and etc ''''''''''''''''''
sub PrtColText(byval x as integer, byval y as integer,byval colour1 as integer, byval colour2 as integer ,byref text as string)
locate x,y
color colour1,colour2
print text
end sub
sub OrigColor(byval loval as Uinteger,byval hival as Uinteger)
color loval,hival
end sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
begin:
locate 1,1
view print 1 to hiword(width)
'PrtColText(locate y,locate x,color foreground, color background, " text "
' y x f b
PrtColText(1,1,7,9,"RBterm")
PrtColText(1,7,7,9," ")
PrtColText(2,1,0,4,"F1")
PrtColText(2,3,7,9," - ")
PrtColText(2,6,7,9," ")
PrtColText(2,12,0,4,"F2")
PrtColText(2,14,7,9," - ")
PrtColText(2,17,7,9," ")
PrtColText(2,23,0,4,"F3")
PrtColText(2,25,7,9," - ")
PrtColText(2,27,7,9," ")
PrtColText(2,37,0,4,"F10")
PrtColText(2,40,7,9," - Quit")
PrtColText(2,47,7,9," ")
locate 2,6
print baud(b);
locate 2,17
print port(p);
locate 2,27
print "Connect";
OrigColor(loword(Corig),hiword(Corig))
do
'Mouse cursor location code ''''''''''''''''''''
res = getmouse (x, y, ,buttons)
' locate 29,1
' if res <> 0 then
' print "Mouse not available or not on window"
' else
' print using "Mouse position: ###:### ";x;y;
' print " "
' end if
'''''''''''''''''''''''''''''''''''''''''''''''''
'loop while inkey = ""
Key = Inkey$
'''''''''''''''''''' F10 ''''''''''''''''''''''''''''''''''''
if key = chr$(255) & chr$(68) then 'F10 Quit the program
close #1
view print 1 to hiword(width)
cls
goto cend
end if
if x > 288 and x < 312 and y > 15 and y < 30 and buttons and 1 then 'Mouse
close #1
view print 1 to hiword(width)
cls
sleep 5,1
goto cend
end if
'''''''''''''''''''''''' F3 ''''''''''''''''''''''''''''''''''''
if Key = chr$(255) & chr$(61) then 'F3 Connection
exit do
end if
if x > 176 and x < 191 and y > 15 and y < 30 and buttons and 1 then 'Mouse
sleep 255,1
exit do
end if
'''''''''''''''''''''''' F1 ''''''''''''''''''''''''''''''''''''
if Key = chr$(255) & chr$(59) then 'F1 Baud selection
b += 1
if b = 10 then b = 0
locate 2,6
color 7,9
print " "
locate 2,6
print baud(b);
end if
if x > 0 and x < 16 and y > 15 and y < 30 and buttons and 1 then 'Mouse
b += 1
if b = 10 then b = 0
locate 2,6
color 7,9
print " "
locate 2,6
print baud(b);
sleep 250,1
end if
''''''''''''''''''''''''' F2 ''''''''''''''''''''''''''''''''''''
if Key = chr$(255) & chr$(60) then 'F2 Port selection
p += 1
if p = 4 then p = 0
locate 2,17
color 7,9
print " "
locate 2,17
print port(p);
end if
if x > 87 and x < 104 and y > 15 and y < 30 and buttons and 1 then 'Mouse
p += 1
if p = 4 then p = 0
locate 2,17
color 7,9
print " "
locate 2,17
print port(p);
sleep 250,1
end if
sleep 1
loop
PrtColText(2,1,7,9,"Baud")
PrtColText(2,12,7,9,"Port")
PrtColText(2,27,7,9,"Disconnect")
'PrtColText(3,1,0,4,"F4")
'PrtColText(3,3,7,9," - send a number")
PrtColText(2,60,0,4,"F4")
PrtColText(2,62,7,9," - send a number")
view print 3 to hiword(width)
OrigColor(loword(Corig),hiword(Corig))
'locate 1,3,1
locate 1,3,0
open com port(p) & baud(b) & ",n,8,1,cs0,ds0,cd0,rs" as #1
if Err <> 0 then
print "Error opening",port(p);
sleep 2000,1
cls
goto begin
end if
'This is the Main do ... loop
do
'Mouse cursor location code ''''''''''''''''''''
res = getmouse (x, y, ,buttons)
' locate 29,1
' if res <> 0 then
' print "Mouse not available or not on window"
' else
' print using "Mouse position: ###:### ";x;y;
' if buttons and 1 then print "L";
' if buttons and 2 then print "R";
' if buttons and 4 then print "M";
' print " "
' end if
'''''''''''''''''''''''''''''''''''''''''''''''''
Key = inkey$
if Key = chr$(255) & chr$(68) then 'F10 Quit
exit do
end if
if x > 288 and x < 312 and y > 15 and y < 30 and buttons and 1 then 'Mouse
close #1
view print 1 to hiword(width)
cls
sleep 5,1
goto cend
end if
'''''''''''''''''''''''''''''''''''''''''''''''''''''
if Key = chr$(255) & chr$(61) then 'F3 Disconnect
close #1
view print 1 to hiword(width)
PrtColText(2,60,7,9," ")
OrigColor(loword(Corig),hiword(Corig))
cls
goto begin
end if
if x > 176 and x < 191 and y > 15 and y < 30 and buttons and 1 then 'Mouse
close #1
view print 1 to hiword(width)
PrtColText(2,60,7,9," ")
OrigColor(loword(Corig),hiword(Corig))
sleep 240,1
cls
goto begin
end if
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
if Key = chr$(255) & chr$(59) then
print "ERROR - Do a DISCONNECT first!"
Key = chr$(8)
end if
if Key = chr$(255) & chr$(60) then
print "ERROR - Do a DISCONNECT first!"
Key = chr$(8)
end if
if x > 470 and x < 488 and y > 15 and y < 30 and buttons and 1 then
goto F4code
end if
if Key = chr$(255) & chr$(62) then 'F4 key
F4code:
input "Enter a number to send (0 - 255) space delimited";numtosend
pos1 = instr(numtosend, " ")
if pos1 = 0 and len(numtosend) > 0 then
print #1, chr$(val(numtosend));
print chr$(val(numtosend));
else
numtosend2 = val(left$(numtosend,pos1))
print #1, chr$(numtosend2);
print chr$(numtosend2);
do while pos1 > 0
pos2 = pos1
pos1 = instr(pos1+1, numtosend, " ")
numtosend2 = val(mid$(numtosend,pos2+1,pos1-pos2))
print #1, chr$(numtosend2);
print chr$(numtosend2);
loop
end if
end if
if Key <> "" then
if Key = chr$(13) then
print #1, chr$(13)
print chr$(10);
end if
print #1,Key;
print Key;
end if
while loc(1) > 0
buffer = input$(loc(1),#1)
print buffer;
wend
loop
'End of Main do ... loop
'end
' sleep 'Wait for a keypress
cend:
view print 1 to hiword(width)
cls
' Restore the command prompt window to the old settings
width oldwidth and &hFFFF, oldwidth shr 16
color oldcolor and &hFFFF, oldcolor shr 16
view print 1 to oldwidth shr 16
' cls
It looks good so far. The cursor issue is a bit more difficult. Why can't you just stick to console mode since you aren't using any graphics? You would just need to change your mouse coordinate numbers to correlate to rows and columns instead of graphics coordinates.
Something like this:
Something like this:
Code: Select all
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Test4.bas
'
' Grabs the exiting values of the command prompt window
Locate ,,0
Dim As Integer oldcolor = Color
Dim As Integer oldwidth = Width
'Your new code goes here
'Screen 12 'Selects the screen resolution
Dim Corig As Uinteger
Dim As Integer pos1,pos2,b,p
Dim As String Key,buffer
Dim numtosend As String
Dim numtosend2 As Ubyte
Dim As String baud(0 To 9) = {"110","300","1200","2400","4800","9600","19200","38400","57600","115200"}
Dim As String port(0 To 3) = {"COM1:","COM2:","COM3:","COM4:"}
Corig = Color()
'Variables for the mouse info '''''''''''''''''''''
Dim x As Integer, y As Integer, buttons As Integer
Dim res As Integer
'''''''''''''''''''''''''''''''''''''''''''''''''''
'Subroutines, Functions, and etc ''''''''''''''''''
Sub PrtColText(Byval x As Integer, Byval y As Integer,Byval colour1 As Integer, Byval colour2 As Integer ,Byref text As String)
Locate x,y
Color colour1,colour2
Print text
End Sub
Sub OrigColor(Byval loval As Uinteger,Byval hival As Uinteger)
Color loval,hival
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
begin:
Locate 1,1
View Print 1 To hiword(Width)
'PrtColText(locate y,locate x,color foreground, color background, " text "
' y x f b
PrtColText(1,1,7,9,"RBterm")
PrtColText(1,7,7,9," ")
PrtColText(2,1,0,12,"F1")
PrtColText(2,3,7,9," - ")
PrtColText(2,6,7,9," ")
PrtColText(2,12,0,12,"F2")
PrtColText(2,14,7,9," - ")
PrtColText(2,17,7,9," ")
PrtColText(2,23,0,12,"F3")
PrtColText(2,25,7,9," - ")
PrtColText(2,27,7,9," ")
PrtColText(2,37,0,12,"F10")
PrtColText(2,40,7,9," - Quit")
PrtColText(2,47,7,9," ")
Locate 2,6
Print baud(b);
Locate 2,17
Print port(p);
Locate 2,27
Print "Connect";
OrigColor(loword(Corig),hiword(Corig))
Do
'Mouse cursor location code ''''''''''''''''''''
res = getmouse (x, y, ,buttons)
' locate 29,1
' if res <> 0 then
' print "Mouse not available or not on window"
' else
' print using "Mouse position: ###:### ";x;y;
' print " "
' end if
'''''''''''''''''''''''''''''''''''''''''''''''''
'loop while inkey = ""
Key = Inkey$
'''''''''''''''''''' F10 ''''''''''''''''''''''''''''''''''''
If Key = Chr$(255) & Chr$(68) Then 'F10 Quit the program
Close #1
View Print 1 To hiword(Width)
Cls
Goto cend
End If
If x > 35 And x < 39 And y = 1 And buttons And 1 Then 'Mouse
Close #1
View Print 1 To hiword(Width)
Cls
Sleep 5,1
Goto cend
End If
'''''''''''''''''''''''' F3 ''''''''''''''''''''''''''''''''''''
If Key = Chr$(255) & Chr$(61) Then 'F3 Connection
Exit Do
End If
If x > 21 And x < 25 And y = 1 And buttons And 1 Then 'Mouse
Sleep 255,1
Exit Do
End If
'''''''''''''''''''''''' F1 ''''''''''''''''''''''''''''''''''''
If Key = Chr$(255) & Chr$(59) Then 'F1 Baud selection
b += 1
If b = 10 Then b = 0
Locate 2,6
Color 7,9
Print " "
Locate 2,6
Print baud(b);
End If
If x < 2 And y = 1 And buttons And 1 Then 'Mouse
b += 1
If b = 10 Then b = 0
Locate 2,6
Color 7,9
Print " "
Locate 2,6
Print baud(b);
Sleep 250,1
End If
''''''''''''''''''''''''' F2 ''''''''''''''''''''''''''''''''''''
If Key = Chr$(255) & Chr$(60) Then 'F2 Port selection
p += 1
If p = 4 Then p = 0
Locate 2,17
Color 7,9
Print " "
Locate 2,17
Print port(p);
End If
If x > 10 And x < 13 And y = 1 And buttons And 1 Then 'Mouse
p += 1
If p = 4 Then p = 0
Locate 2,17
Color 7,9
Print " "
Locate 2,17
Print port(p);
Sleep 250,1
End If
Sleep 1
Loop
PrtColText(2,1,7,9,"Baud")
PrtColText(2,12,7,9,"Port")
PrtColText(2,27,7,9,"Disconnect")
'PrtColText(3,1,0,4,"F4")
'PrtColText(3,3,7,9," - send a number")
PrtColText(2,60,0,12,"F4")
PrtColText(2,62,7,9," - send a number")
View Print 3 To hiword(Width)
OrigColor(loword(Corig),hiword(Corig))
'locate 1,3,1
Locate 1,3,0
Open Com port(p) & baud(b) & ",n,8,1,cs0,ds0,cd0,rs" As #1
If Err <> 0 Then
Print "Error opening",port(p);
Sleep 2000,1
Cls
Goto begin
End If
'This is the Main do ... loop
Do
'Mouse cursor location code ''''''''''''''''''''
res = getmouse (x, y, ,buttons)
' locate 29,1
' if res <> 0 then
' print "Mouse not available or not on window"
' else
' print using "Mouse position: ###:### ";x;y;
' if buttons and 1 then print "L";
' if buttons and 2 then print "R";
' if buttons and 4 then print "M";
' print " "
' end if
'''''''''''''''''''''''''''''''''''''''''''''''''
Key = Inkey$
If Key = Chr$(255) & Chr$(68) Then 'F10 Quit
Exit Do
End If
If x > 58 And x < 61 And y = 1 And buttons And 1 Then 'Mouse
Close #1
View Print 1 To hiword(Width)
Cls
Sleep 5,1
Goto cend
End If
'''''''''''''''''''''''''''''''''''''''''''''''''''''
If Key = Chr$(255) & Chr$(61) Then 'F3 Disconnect
Close #1
View Print 1 To hiword(Width)
PrtColText(2,60,7,9," ")
OrigColor(loword(Corig),hiword(Corig))
Cls
Goto begin
End If
If x > 176 And x < 191 And y > 15 And y < 30 And buttons And 1 Then 'Mouse
Close #1
View Print 1 To hiword(Width)
PrtColText(2,60,7,9," ")
OrigColor(loword(Corig),hiword(Corig))
Sleep 240,1
Cls
Goto begin
End If
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
If Key = Chr$(255) & Chr$(59) Then
Print "ERROR - Do a DISCONNECT first!"
Key = Chr$(8)
End If
If Key = Chr$(255) & Chr$(60) Then
Print "ERROR - Do a DISCONNECT first!"
Key = Chr$(8)
End If
If x > 470 And x < 488 And y > 15 And y < 30 And buttons And 1 Then
Goto F4code
End If
If Key = Chr$(255) & Chr$(62) Then 'F4 key
F4code:
Input "Enter a number to send (0 - 255) space delimited";numtosend
pos1 = Instr(numtosend, " ")
If pos1 = 0 And Len(numtosend) > 0 Then
Print #1, Chr$(Val(numtosend));
Print Chr$(Val(numtosend));
Else
numtosend2 = Val(Left$(numtosend,pos1))
Print #1, Chr$(numtosend2);
Print Chr$(numtosend2);
Do While pos1 > 0
pos2 = pos1
pos1 = Instr(pos1+1, numtosend, " ")
numtosend2 = Val(Mid$(numtosend,pos2+1,pos1-pos2))
Print #1, Chr$(numtosend2);
Print Chr$(numtosend2);
Loop
End If
End If
If Key <> "" Then
If Key = Chr$(13) Then
Print #1, Chr$(13)
Print Chr$(10);
End If
Print #1,Key;
Print Key;
End If
While Loc(1) > 0
buffer = Input$(Loc(1),#1)
Print buffer;
Wend
Loop
'End of Main do ... loop
'end
' sleep 'Wait for a keypress
cend:
View Print 1 To hiword(Width)
Cls
' Restore the command prompt window to the old settings
Width oldwidth And &hFFFF, oldwidth Shr 16
Color oldcolor And &hFFFF, oldcolor Shr 16
View Print 1 To oldwidth Shr 16
' cls
The strategy that you suggest, works great when you compile with the windows version of FBC. The problem is with the DOS version, the mouse cursor only shows up when you compile the program in graphics mode. I thought that was a little peculiar, but I may be missing something in the DOS version of FB. So, the only way I can get the mouse cursor to appear, in the DOS version, is by adding a 'screen' command. I looked in the docs, and did not see any commands that would make the mouse cursor appear. I am using ctmouse.exe as the mouse driver on the DOS system, maybe there is a problem with the driver, when it is in a non-graphics mode.
I would like to keep the program as consistent as possible between the two systems. The only way that I see, at the moment, to accomplish that, is to keep both in graphics mode. But, then I have to deal with the text cursor problem in the terminal area.
I have been working on trying to find a solution for the text cursor problem, and it does not look very promising at this time. I guess what I may have to do is keep the DOS version in a less-mouse condition. I guess I need some suggestions, right about now.
Thanks
I would like to keep the program as consistent as possible between the two systems. The only way that I see, at the moment, to accomplish that, is to keep both in graphics mode. But, then I have to deal with the text cursor problem in the terminal area.
I have been working on trying to find a solution for the text cursor problem, and it does not look very promising at this time. I guess what I may have to do is keep the DOS version in a less-mouse condition. I guess I need some suggestions, right about now.
Thanks
OK, I didn't know that DOS doesn't have the mouse cursor available in console mode. Try this for a blinking cursor.
Code: Select all
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Test4.bas
'
' Grabs the exiting values of the command prompt window
Locate ,,0
Dim As Integer oldcolor = Color
Dim As Integer oldwidth = Width
'Your new code goes here
Screen 12 'Selects the screen resolution
Dim Corig As Uinteger
Dim As Integer pos1,pos2,b,p,column,row,flag
Dim As String Key,buffer
Dim numtosend As String
Dim numtosend2 As Ubyte
dim t as single
Dim As String baud(0 To 9) = {"110","300","1200","2400","4800","9600","19200","38400","57600","115200"}
Dim As String port(0 To 3) = {"COM1:","COM2:","COM3:","COM4:"}
Corig = Color()
'Variables for the mouse info '''''''''''''''''''''
Dim x As Integer, y As Integer, buttons As Integer
Dim res As Integer
'''''''''''''''''''''''''''''''''''''''''''''''''''
'Subroutines, Functions, and etc ''''''''''''''''''
Sub PrtColText(Byval x As Integer, Byval y As Integer,Byval colour1 As Integer, Byval colour2 As Integer ,Byref text As String)
Locate x,y
Color colour1,colour2
Print text
End Sub
Sub OrigColor(Byval loval As Uinteger,Byval hival As Uinteger)
Color loval,hival
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
begin:
Locate 1,1
View Print 1 To hiword(Width)
'PrtColText(locate y,locate x,color foreground, color background, " text "
' y x f b
PrtColText(1,1,7,9,"RBterm")
PrtColText(1,7,7,9," ")
PrtColText(2,1,0,4,"F1")
PrtColText(2,3,7,9," - ")
PrtColText(2,6,7,9," ")
PrtColText(2,12,0,4,"F2")
PrtColText(2,14,7,9," - ")
PrtColText(2,17,7,9," ")
PrtColText(2,23,0,4,"F3")
PrtColText(2,25,7,9," - ")
PrtColText(2,27,7,9," ")
PrtColText(2,37,0,4,"F10")
PrtColText(2,40,7,9," - Quit")
PrtColText(2,47,7,9," ")
Locate 2,6
Print baud(b);
Locate 2,17
Print port(p);
Locate 2,27
Print "Connect";
OrigColor(loword(Corig),hiword(Corig))
Do
'Mouse cursor location code ''''''''''''''''''''
res = getmouse (x, y, ,buttons)
' locate 29,1
' if res <> 0 then
' print "Mouse not available or not on window"
' else
' print using "Mouse position: ###:### ";x;y;
' print " "
' end if
'''''''''''''''''''''''''''''''''''''''''''''''''
'loop while inkey = ""
Key = Inkey$
'''''''''''''''''''' F10 ''''''''''''''''''''''''''''''''''''
If Key = Chr$(255) & Chr$(68) Then 'F10 Quit the program
Close #1
View Print 1 To hiword(Width)
Cls
Goto cend
End If
If x > 288 And x < 312 And y > 15 And y < 30 And buttons And 1 Then 'Mouse
Close #1
View Print 1 To hiword(Width)
Cls
Sleep 5,1
Goto cend
End If
'''''''''''''''''''''''' F3 ''''''''''''''''''''''''''''''''''''
If Key = Chr$(255) & Chr$(61) Then 'F3 Connection
Exit Do
End If
If x > 176 And x < 191 And y > 15 And y < 30 And buttons And 1 Then 'Mouse
Sleep 255,1
Exit Do
End If
'''''''''''''''''''''''' F1 ''''''''''''''''''''''''''''''''''''
If Key = Chr$(255) & Chr$(59) Then 'F1 Baud selection
b += 1
If b = 10 Then b = 0
Locate 2,6
Color 7,9
Print " "
Locate 2,6
Print baud(b);
End If
If x > 0 And x < 16 And y > 15 And y < 30 And buttons And 1 Then 'Mouse
b += 1
If b = 10 Then b = 0
Locate 2,6
Color 7,9
Print " "
Locate 2,6
Print baud(b);
Sleep 250,1
End If
''''''''''''''''''''''''' F2 ''''''''''''''''''''''''''''''''''''
If Key = Chr$(255) & Chr$(60) Then 'F2 Port selection
p += 1
If p = 4 Then p = 0
Locate 2,17
Color 7,9
Print " "
Locate 2,17
Print port(p);
End If
If x > 87 And x < 104 And y > 15 And y < 30 And buttons And 1 Then 'Mouse
p += 1
If p = 4 Then p = 0
Locate 2,17
Color 7,9
Print " "
Locate 2,17
Print port(p);
Sleep 250,1
End If
Sleep 1
Loop
PrtColText(2,1,7,9,"Baud")
PrtColText(2,12,7,9,"Port")
PrtColText(2,27,7,9,"Disconnect")
'PrtColText(3,1,0,4,"F4")
'PrtColText(3,3,7,9," - send a number")
PrtColText(2,60,0,4,"F4")
PrtColText(2,62,7,9," - send a number")
View Print 3 To hiword(Width)
OrigColor(loword(Corig),hiword(Corig))
'locate 1,3,1
Locate 1,3,0
Open Com port(p) & baud(b) & ",n,8,1,cs0,ds0,cd0,rs" As #1
If Err <> 0 Then
Print "Error opening",port(p);
Sleep 2000,1
Cls
Goto begin
End If
'This is the Main do ... loop
t = timer
Do
'Mouse cursor location code ''''''''''''''''''''
res = getmouse (x, y, ,buttons)
' locate 29,1
' if res <> 0 then
' print "Mouse not available or not on window"
' else
' print using "Mouse position: ###:### ";x;y;
' if buttons and 1 then print "L";
' if buttons and 2 then print "R";
' if buttons and 4 then print "M";
' print " "
' end if
'''''''''''''''''''''''''''''''''''''''''''''''''
Key = Inkey$
column = pos
row = csrlin
if timer - t > .5 then
flag = not(flag)
if flag then
print "_";
else
print " ";
end if
locate row,column
t = timer
end if
If Key = Chr$(255) & Chr$(68) Then 'F10 Quit
Exit Do
End If
If x > 288 And x < 312 And y > 15 And y < 30 And buttons And 1 Then 'Mouse
Close #1
View Print 1 To hiword(Width)
Cls
Sleep 5,1
Goto cend
End If
'''''''''''''''''''''''''''''''''''''''''''''''''''''
If Key = Chr$(255) & Chr$(61) Then 'F3 Disconnect
Close #1
View Print 1 To hiword(Width)
PrtColText(2,60,7,9," ")
OrigColor(loword(Corig),hiword(Corig))
Cls
Goto begin
End If
If x > 176 And x < 191 And y > 15 And y < 30 And buttons And 1 Then 'Mouse
Close #1
View Print 1 To hiword(Width)
PrtColText(2,60,7,9," ")
OrigColor(loword(Corig),hiword(Corig))
Sleep 240,1
Cls
Goto begin
End If
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
If Key = Chr$(255) & Chr$(59) Then
Print "ERROR - Do a DISCONNECT first!"
Key = Chr$(8)
End If
If Key = Chr$(255) & Chr$(60) Then
Print "ERROR - Do a DISCONNECT first!"
Key = Chr$(8)
End If
If x > 470 And x < 488 And y > 15 And y < 30 And buttons And 1 Then
Goto F4code
End If
If Key = Chr$(255) & Chr$(62) Then 'F4 key
F4code:
Input "Enter a number to send (0 - 255) space delimited";numtosend
pos1 = Instr(numtosend, " ")
If pos1 = 0 And Len(numtosend) > 0 Then
Print #1, Chr$(Val(numtosend));
Print Chr$(Val(numtosend));
Else
numtosend2 = Val(Left$(numtosend,pos1))
Print #1, Chr$(numtosend2);
Print Chr$(numtosend2);
Do While pos1 > 0
pos2 = pos1
pos1 = Instr(pos1+1, numtosend, " ")
numtosend2 = Val(Mid$(numtosend,pos2+1,pos1-pos2))
Print #1, Chr$(numtosend2);
Print Chr$(numtosend2);
Loop
End If
End If
If Key <> "" Then
locate row,column
print " ";
locate row,column
If Key = Chr$(13) Then
Print #1, Chr$(13);
Print Chr$(10);
else
Print #1,Key;
Print Key;
end if
End If
While Loc(1) > 0
buffer = Input$(Loc(1),#1)
Print buffer;
Wend
Loop
'End of Main do ... loop
'end
' sleep 'Wait for a keypress
cend:
View Print 1 To hiword(Width)
Cls
' Restore the command prompt window to the old settings
Width oldwidth And &hFFFF, oldwidth Shr 16
Color oldcolor And &hFFFF, oldcolor Shr 16
View Print 1 To oldwidth Shr 16
' cls
I just tried your new code, for the windows version it works just fine. The windows version of this program is looking pretty good.
The problem is in the DOS version, for some reason, your code is getting tied into the mouse movement. In other words, the only time you see the text cursor is when you move the mouse around. It's strange that there would be that much of a difference between the way the same piece of code works in the windows compile, and in a DOS compile.
I'm stumped, I thought maybe your piece of code was using the 'x', and 'y' variables, but that is not the case. Maybe the developers should look into why this is reacting in such a manner between the two compiles. More investigation ...
Thanks
The problem is in the DOS version, for some reason, your code is getting tied into the mouse movement. In other words, the only time you see the text cursor is when you move the mouse around. It's strange that there would be that much of a difference between the way the same piece of code works in the windows compile, and in a DOS compile.
I'm stumped, I thought maybe your piece of code was using the 'x', and 'y' variables, but that is not the case. Maybe the developers should look into why this is reacting in such a manner between the two compiles. More investigation ...
Thanks
I have a win xp sp3 system, when I run the DOS version, it opens up a full screen dosbox, and the text cursor does not appear, even when you move the cursor around. So, it is even worse on the win xp dosbox. I think it is definitely some problem with the DOS compile, I hope a developer is reading this thread, this might be a bug.
I think now I have to think about what other simple feature to add to the FBterm program. Since I will be using this with the Roomba/Create, maybe being able to upload something like a script file, to the robots. Once you have a sequence of commands figured out, that can be loaded to file, and then the file can be uploaded to the robot. Sounds easier said then done.
Now, I think, I will have to clean up the code, and add some comments, so other people can follow it.
Thanks
I think now I have to think about what other simple feature to add to the FBterm program. Since I will be using this with the Roomba/Create, maybe being able to upload something like a script file, to the robots. Once you have a sequence of commands figured out, that can be loaded to file, and then the file can be uploaded to the robot. Sounds easier said then done.
Now, I think, I will have to clean up the code, and add some comments, so other people can follow it.
Thanks
I finally tried it with DOSBOX and saw a fast blinking cursor sometimes and no cursor at other times. To me it looks like an issue with the timer statement under DOS. I could be wrong though. I changed the code to a non-blinking cursor and it works fine.
Code: Select all
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Test4.bas
'
' Grabs the exiting values of the command prompt window
Locate ,,0
Dim As Integer oldcolor = Color
Dim As Integer oldwidth = Width
'Your new code goes here
Screen 12 'Selects the screen resolution
Dim Corig As Uinteger
Dim As Integer pos1,pos2,b,p,column,row,flag
Dim As String Key,buffer
Dim numtosend As String
Dim numtosend2 As Ubyte
dim t as single
Dim As String baud(0 To 9) = {"110","300","1200","2400","4800","9600","19200","38400","57600","115200"}
Dim As String port(0 To 3) = {"COM1:","COM2:","COM3:","COM4:"}
Corig = Color()
'Variables for the mouse info '''''''''''''''''''''
Dim x As Integer, y As Integer, buttons As Integer
Dim res As Integer
'''''''''''''''''''''''''''''''''''''''''''''''''''
'Subroutines, Functions, and etc ''''''''''''''''''
Sub PrtColText(Byval x As Integer, Byval y As Integer,Byval colour1 As Integer, Byval colour2 As Integer ,Byref text As String)
Locate x,y
Color colour1,colour2
Print text
End Sub
Sub OrigColor(Byval loval As Uinteger,Byval hival As Uinteger)
Color loval,hival
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
begin:
Locate 1,1
View Print 1 To hiword(Width)
'PrtColText(locate y,locate x,color foreground, color background, " text "
' y x f b
PrtColText(1,1,7,9,"RBterm")
PrtColText(1,7,7,9," ")
PrtColText(2,1,0,4,"F1")
PrtColText(2,3,7,9," - ")
PrtColText(2,6,7,9," ")
PrtColText(2,12,0,4,"F2")
PrtColText(2,14,7,9," - ")
PrtColText(2,17,7,9," ")
PrtColText(2,23,0,4,"F3")
PrtColText(2,25,7,9," - ")
PrtColText(2,27,7,9," ")
PrtColText(2,37,0,4,"F10")
PrtColText(2,40,7,9," - Quit")
PrtColText(2,47,7,9," ")
Locate 2,6
Print baud(b);
Locate 2,17
Print port(p);
Locate 2,27
Print "Connect";
OrigColor(loword(Corig),hiword(Corig))
Do
'Mouse cursor location code ''''''''''''''''''''
res = getmouse (x, y, ,buttons)
' locate 29,1
' if res <> 0 then
' print "Mouse not available or not on window"
' else
' print using "Mouse position: ###:### ";x;y;
' print " "
' end if
'''''''''''''''''''''''''''''''''''''''''''''''''
'loop while inkey = ""
Key = Inkey$
'''''''''''''''''''' F10 ''''''''''''''''''''''''''''''''''''
If Key = Chr$(255) & Chr$(68) Then 'F10 Quit the program
Close #1
View Print 1 To hiword(Width)
Cls
Goto cend
End If
If x > 288 And x < 312 And y > 15 And y < 30 And buttons And 1 Then 'Mouse
Close #1
View Print 1 To hiword(Width)
Cls
Sleep 5,1
Goto cend
End If
'''''''''''''''''''''''' F3 ''''''''''''''''''''''''''''''''''''
If Key = Chr$(255) & Chr$(61) Then 'F3 Connection
Exit Do
End If
If x > 176 And x < 191 And y > 15 And y < 30 And buttons And 1 Then 'Mouse
Sleep 255,1
Exit Do
End If
'''''''''''''''''''''''' F1 ''''''''''''''''''''''''''''''''''''
If Key = Chr$(255) & Chr$(59) Then 'F1 Baud selection
b += 1
If b = 10 Then b = 0
Locate 2,6
Color 7,9
Print " "
Locate 2,6
Print baud(b);
End If
If x > 0 And x < 16 And y > 15 And y < 30 And buttons And 1 Then 'Mouse
b += 1
If b = 10 Then b = 0
Locate 2,6
Color 7,9
Print " "
Locate 2,6
Print baud(b);
Sleep 250,1
End If
''''''''''''''''''''''''' F2 ''''''''''''''''''''''''''''''''''''
If Key = Chr$(255) & Chr$(60) Then 'F2 Port selection
p += 1
If p = 4 Then p = 0
Locate 2,17
Color 7,9
Print " "
Locate 2,17
Print port(p);
End If
If x > 87 And x < 104 And y > 15 And y < 30 And buttons And 1 Then 'Mouse
p += 1
If p = 4 Then p = 0
Locate 2,17
Color 7,9
Print " "
Locate 2,17
Print port(p);
Sleep 250,1
End If
Sleep 1
Loop
PrtColText(2,1,7,9,"Baud")
PrtColText(2,12,7,9,"Port")
PrtColText(2,27,7,9,"Disconnect")
'PrtColText(3,1,0,4,"F4")
'PrtColText(3,3,7,9," - send a number")
PrtColText(2,60,0,4,"F4")
PrtColText(2,62,7,9," - send a number")
View Print 3 To hiword(Width)
OrigColor(loword(Corig),hiword(Corig))
'locate 1,3,1
Locate 1,3,0
Open Com port(p) & baud(b) & ",n,8,1,cs0,ds0,cd0,rs" As #1
If Err <> 0 Then
Print "Error opening",port(p);
Sleep 2000,1
Cls
Goto begin
End If
'This is the Main do ... loop
t = timer
Do
'Mouse cursor location code ''''''''''''''''''''
res = getmouse (x, y, ,buttons)
' locate 29,1
' if res <> 0 then
' print "Mouse not available or not on window"
' else
' print using "Mouse position: ###:### ";x;y;
' if buttons and 1 then print "L";
' if buttons and 2 then print "R";
' if buttons and 4 then print "M";
' print " "
' end if
'''''''''''''''''''''''''''''''''''''''''''''''''
Key = Inkey$
column = pos
row = csrlin
print "_";
locate row,column
If Key = Chr$(255) & Chr$(68) Then 'F10 Quit
Exit Do
End If
If x > 288 And x < 312 And y > 15 And y < 30 And buttons And 1 Then 'Mouse
Close #1
View Print 1 To hiword(Width)
Cls
Sleep 5,1
Goto cend
End If
'''''''''''''''''''''''''''''''''''''''''''''''''''''
If Key = Chr$(255) & Chr$(61) Then 'F3 Disconnect
Close #1
View Print 1 To hiword(Width)
PrtColText(2,60,7,9," ")
OrigColor(loword(Corig),hiword(Corig))
Cls
Goto begin
End If
If x > 176 And x < 191 And y > 15 And y < 30 And buttons And 1 Then 'Mouse
Close #1
View Print 1 To hiword(Width)
PrtColText(2,60,7,9," ")
OrigColor(loword(Corig),hiword(Corig))
Sleep 240,1
Cls
Goto begin
End If
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
If Key = Chr$(255) & Chr$(59) Then
Print "ERROR - Do a DISCONNECT first!"
Key = Chr$(8)
End If
If Key = Chr$(255) & Chr$(60) Then
Print "ERROR - Do a DISCONNECT first!"
Key = Chr$(8)
End If
If x > 470 And x < 488 And y > 15 And y < 30 And buttons And 1 Then
Goto F4code
End If
If Key = Chr$(255) & Chr$(62) Then 'F4 key
F4code:
Input "Enter a number to send (0 - 255) space delimited";numtosend
pos1 = Instr(numtosend, " ")
If pos1 = 0 And Len(numtosend) > 0 Then
Print #1, Chr$(Val(numtosend));
Print Chr$(Val(numtosend));
Else
numtosend2 = Val(Left$(numtosend,pos1))
Print #1, Chr$(numtosend2);
Print Chr$(numtosend2);
Do While pos1 > 0
pos2 = pos1
pos1 = Instr(pos1+1, numtosend, " ")
numtosend2 = Val(Mid$(numtosend,pos2+1,pos1-pos2))
Print #1, Chr$(numtosend2);
Print Chr$(numtosend2);
Loop
End If
End If
If Key <> "" Then
locate row,column
print " ";
locate row,column
If Key = Chr$(13) Then
Print #1, Chr$(13);
Print Chr$(10);
else
Print #1,Key;
Print Key;
end if
End If
While Loc(1) > 0
buffer = Input$(Loc(1),#1)
Print buffer;
Wend
sleep 1
Loop
'End of Main do ... loop
'end
' sleep 'Wait for a keypress
cend:
View Print 1 To hiword(Width)
Cls
' Restore the command prompt window to the old settings
Width oldwidth And &hFFFF, oldwidth Shr 16
Color oldcolor And &hFFFF, oldcolor Shr 16
View Print 1 To oldwidth Shr 16
' cls