| Home CBM ASCII-X BASIC Disk Commands Enter RUN mode Program Format Secret Variables Variable Format Expressions Keywords (divide) (equal) (less) (minus) (more) (multiply) (plus) (power) Abs And Append Asc Atn Auto Backup Bank Begin Bend Bload Boot Box Bsave Bump Catalog Char Chr Circle Close Clr Cmd Collect Collision Color Concat Cont Copy Cos Data Dclear Dclose Dec Def Delete Dim Directory Dispose Dload Do Dopen Draw Ds Ds string Dsave Dverify El Else End Envelope Er Err Exit Exp Fast Fetch Filter Fn For Fre Get Get num Getkey Go Gosub Goto Graphic Gshape Header Help Hex If Input Input num Instr Int Joy Key Left Len Let List Load Locate Log Loop Mid Monitor Movspr New Next Not Off On Open Or Paint Peek Pen Pi Play Pointer Poke Pos Pot Print num Pudef Quit Rclr Rdot Read Record Rem Rename Renumber Restore Resume Return Rgr Right Rlum Rnd Rreg Rspcolor Rsppos Rsprite Run Rwindow Save Scale Scnclr Scratch Sgn Sin Sleep Slow Sound Spc Sprcolor Sprdef Sprite Sprsav Sqr Sshape St Stash Step Stop Str Swap Sys Tab Tan Tempo Then Ti Ti string To Trap Troff Tron Until Using Usr Val Verify Vol Wait While Width Window Xor Syntax Tokens C128 D64plus Disk Escape Codes Hardware PCxface PETSCII Pet2asc Futurama IBM PC-AT Contact Games Glossary Hall of fame Hall of shame Miscellaneous Privacy policy Programming Twisty puzzles |
Multiple items in the data stream of the file must be seperated with one of the following characters: a comma (,), a colon (:), a carriage return (ASCII 13), or a null (ASCII 0). Because of this, a string which is to contain a comma or colon must be surrounded by double-quotes ("). There is no way to input a literal double-quote, a carriage return, or a null. Because of these issues, it is common to use GET# instead of INPUT#, although GET# is much slower. Although Commodore BASIC allows strings to be up to 255 characters in length, a string read using INPUT# may not be longer than system's input buffer (this varies by computer model). So if the system has an 80-character input buffer, then any "file" data which runs for more than 80 characters without a comma, colon, or carriage return will generate the not-quite-accurate error of STRING TOO LONG. These are more good reasons to avoid INPUT#. The "file" (or other input device) must have data available, or INPUT# may wait (possibly forever) until there is data. With some devices, an undefined value may be read immediately when data is not available. INPUT# may only be used as a statement in a program. Outside of a program it will generate ILLEGAL DIRECT error. Example:
The example is using the keyboard as the input "file". This is not typical, but it makes the example more concise. Otherwise a file would have to be created and then opened... and this would require knowledge of your hardware and media. Every CBM computer has a keyboard and they all work pretty much the same (good enough for the example).
© H2Obsession, 2014 |