home *** CD-ROM | disk | FTP | other *** search
/ Old Hackers Atari User Group Newsletter / Old_Hackers_Atari_User_Group_Newsletter_OHMA94B.atr / fbasicpy.txt < prev    next >
Text File  |  2023-02-26  |  3KB  |  1 lines

  1.                 <><><>¢ Source unknown-Printed by OL' HACKERS¢¢      First,   we   are  NOT   talking¢ DUPLICATE  FILE here..this is a clone¢ of Option C in the DUP.SYS  menu,  so¢ disk  swaps aren't supported. I wrote¢ it specifically for loading  external¢ files to D8 (and back.) But thanks to¢ the wonders Of CIO it  does  all  the¢ other stuff too.¢ WHAT WE GOT HERE?¢      First,  there's The String. LIST¢ lines 20-40 out for later use in your¢ Basic  programs.  NEVER,   EVER   try¢ running  string based ML outside of a¢ program!¢ However, THIS program POKES the ML to¢ Page  Six, so you can experiment. Not¢ incidentally, this  also  means  that¢ you  have a Resident Utility that you¢ can use in  Immediate  Mode.  If  you¢ have  151  spare,   protected   bytes¢ somewhere  else,  change  the 1536 in¢ line 90 to wherever you'd like the ML¢ to  live.  Press a key at the prompt,¢ and you'll see the Test Module listed¢ on  the  screen.  (Once  the  code is¢ POKEd, you can LIST 100,160 to  disk,¢ NEW,  then  ENTER  it  back  in as an¢ independent program.) Use the  cursor¢ keys  to  edit  the  Basic  lines for¢ different filenames,  channels,  etc.¢ Then  scoot  the  cursor  down to the¢ 'GOTO 120', and hit RETURN to run the¢ routine.  Once you've done this a few¢ times, you should have a pretty  good¢ idea of what you can do with your New¢ Utility. PLEASE-WriteProtect tabs are¢ NEVER a bad idea for valuable files.¢ SO HOW'S IT WORK?¢      The  first  thing you need to do¢ is OPEN the  channels  that  will  be¢ used  for READ and WRITE. You DO have¢ to do this  from  Basic.  (Sorry,  no¢ miracles  in  Small  Routines.)   ANY¢ available channel (1 to 7) is OK. The¢ READ will probably be something  dull¢ like: OPEN #1,4,0,"D:FILE"¢       Things    get   slightly   more¢ interesting with the  WRITE  options.¢ For instance-OPEN #2,8,0,"D8:NEWFILE"¢ will do a simple copy-Want to APPEND?¢ Try:  OPEN  #2,9,0,"D:OLDFILE"  which¢ will tack the READ file to the end of¢ OLDFILE. And then there's the dumps:¢ OPEN #2,8,0,"P:" for typing a file on¢ the printer, and-OPEN #2,8,0,"E:" for¢ a dump to the screen. Right handy for¢ DOC files. (If you're fussy like  me,¢ POKEs to  709  and  710 will zap that¢ tired GR.0 blue.) Again, you can  use¢ any  available  I/O channel  for  the¢ OPENs.¢ Once  the files are set, call the USR¢ routine. 3 parameters  are  required.¢ (Ugh!)  First,  the  channel  numbers¢ that  have  been  OPENed for READ and¢ WRITE,   respectively.  Then  FRE(0).¢ Why? Free Memory is the file  buffer,¢ and  the  routine  needs to know just¢ how much RAM it  has  to  work  with.¢ Don't  worry  about  running   short.¢ It'll  work  in  chunks if it has to.¢ The format is:  X=USR(ADR(COPY$),READ¢ CHANNEL, WRITE CHANNEL, FRE(0)).¢ ERROR CHECKING?¢      Okay,  check  the value returned¢ to the USR function.  1  is  the  All¢ Clear,  indicating a successful Copy.¢ 255 indicates that the  wrong  number¢ of  parameters  were  passed.  In the¢ event of a regular I/O error (say 162¢ for  a  Full  Disk  or 133 'cause you¢ tried to WRITE to #79),  the  regular¢ number  will  be  returned. Errors of¢ course, terminate the routine. In ALL¢ cases, BOTH channels that were OPENed¢ will be  CLOSEd  before  the  program¢ returns  to  Basic, so you'll need to¢ OPEN them again if needed.¢               *= end =* ¢