我知道BASIC是一种被弃用的语言,但玩起来很有趣。我在Windows上使用FreeBASIC,而我正在尝试重新编译我最初为Apple编写的旧程序[。
一条不再有效的指令是HOME
,它恰好是HOME
光标。我发现this关于在VB.NET中获取/设置光标位置,但是因为我使用BASIC,我认为它不起作用。
因此,我的问题是......如何在BASIC中获取/设置光标位置?
答案 0 :(得分:1)
您可以使用LOCATE
设置光标位置:
CLS
LOCATE 3, 30
PRINT "Hello World"
GETKEY
END
答案 1 :(得分:0)
考虑到您的程序在文本环境中运行25行x 80列(CGA文本模式640x200) FreeBASIC的语法
dim as integer column = 0, row = 0 'Set the variable for store the position
dim as string char = "" ' Set a variable for store the pressed key
cls ' Clear the screen
row = csrlin ' read the actual cursor row and store inside the var row
column = pos ' read the actual cursor column and store inside the var column
do until ( char = chr(27) ) ' make a loop until you press ESC key
char = inkey ' store the pressed key in char variable
if not(char = "") Then ' When you press a key and char store the pressed key then start this routine
if not(char = chr(27)) then ' if pressed a key and not are the ESC or Enter or backspace key
if char = chr(13) then ' when press enter
row = row + 1 ' add a new line if enter are pressed
if row > 23 then row = 23 ' put the stop at row 23
column = 0 ' Put the column at beginning
end if
if char = chr(8) then ' when press backspace
locate row, column
print " "
column = column - 2 ' remove a value from column
if column < 0 then column = 0 ' column cant be lower than 0
end if
if column > 79 then column = 79 ' stop the cursor at 79 column
locate row, column ' move the cursor where
print char ' print the key pressed
column = column + 1 ' add a value to the initial value
end if
locate 24,60 : Print "Row:(" & str(Row) & ") Column:(" & Str(Column) & ")" ' this show where the next cha appair
End if
loop
请原谅我,如果我纠正您的观点,但是BASIC像其他编程语言,VB.NET和FreeBASIC一样得到了发展,您可以在其中开发对象,库并利用以其他语言(如C和C ++)编写的库。相同的FreeBASIC是C的端口,就像他一样具有相同的潜力,实际上可以在Linux和Windows上为图形和文本环境开发应用程序,您可以实现库以使用MySQL和Oracle等数据库, FreeBASIC管理多个线程以同时运行多个进程。