|
Post by mpranger on Sept 5, 2021 9:29:59 GMT -5
What does the (1) mean? What if it was (2)?
getkey$ = input$(1)
Thanks
|
|
|
Post by tenochtitlanuk on Sept 5, 2021 10:10:28 GMT -5
It does exactly the same as input$(1) if you are inputting from the keyboard. If inputting from a FILE you get its contents two characters at a time rather than one. See Help file and try its example with 1 and 2- you'll see no difference.
'read and display a file one character at a time 'accept characters and display them until Enter is pressed text$ = "" while c$ <> chr$(13) c$ = input$(1) print c$; if c$ <> chr$(13) then text$ = text$ + c$ wend print "You typed:"; text$ end
Now use a text editor to write a file "testMe.txt" containing say "Hello World". Make sure it has a multiple of two characters in it. Save it in the folder you saved the LB code in.
Change the LB code to
open "testMe.txt" for input as #fileIn text$ = "" c$ = ""
while c$ <>"!" c$ = input$( #fileIn, 2) print c$; " "; text$ = text$ +c$ wend
print "You typed:"; text$ close #fileIn
end
and run this version. You'll see two characters grabbed at a time.
Most common use is to grab ALL the characters in a file at once with..
allCode$ =input$( #fileIn, lof( #fIn))
|
|