home *** CD-ROM | disk | FTP | other *** search
/ APDL Public Domain 1 / APDL_PD1A.iso / fileutils / split_join / join / join_form next >
Encoding:
Text File  |  1995-10-01  |  3.0 KB  |  134 lines

  1. ;This file is freeware copyright (c) MUFTI
  2. ;written with TLA 
  3. ;formula is preprocessor and M4 is the preprocessor of the preprocessor 8-)
  4.  B start
  5. ; formulaconfiguration:
  6. ; formulatempregistersave  FALSE
  7. ; formulastackregistersave FALSE 
  8. ; formulastacklength       100.
  9. ;M4-commands
  10. ;define(filenamelength,255)
  11. ;define(commandlinelength,255) 
  12. ;define(argvindex,R8)
  13. ;define(commandlineindex,R9) 
  14.  
  15.  
  16.  
  17.  
  18. ; program related data
  19.  ;CHAR filename[filenamelength+1]
  20.  .ALIGN
  21.  ;CHAR outfile[filenamelength+1]
  22.  .ALIGN
  23.  ;CHAR command[256] 
  24.  .ALIGN
  25.  ;CHAR commandline[commandlinelength+1]
  26.  .ALIGN
  27.  ;INT infilehandle
  28.  ;INT outfilehandle
  29.  
  30. ;DECLARE INT  bput2(INT filehandle,CHAR character)
  31.  
  32.  .MACRO bput2
  33.   LDR  R0,[stackregister,`#'%3]
  34.   LDR  R1,[stackregister,`#'%2]
  35.   SWI  OS_BPut
  36.  .ENDM  
  37.  
  38.  ;INCLUDE <formula$dir>.function_h
  39.  
  40. ; task-related data
  41. task .WORD 4B534154
  42. descr .STRING "join"
  43.       .ALIGN
  44. descrptr .WORD descr
  45.  ;INT taskdata[64]
  46. taskdataptr .WORD taskdata
  47.  
  48. start
  49.  ;LET system("wimpslot -min 8K -max 8K")
  50.  MOV R0,`#'200.
  51.  LDR R1,task
  52.  LDR R2,descrptr
  53.  SWI Wimp_Initialise
  54.  ;SAVE R5
  55.  MOV R5,R1
  56.  
  57.  ;LET getargv(commandline)
  58.  ;LET commandlineindex=0
  59.  ;LET argvindex=0
  60.  
  61.  ;WHILE (commandline[commandlineindex]!=0)
  62.  
  63. ; skip spaces
  64.     ;WHILE ((commandline[commandlineindex]!=0) && (commandline[commandlineindex]==32))
  65.        ;LET commandlineindex=commandlineindex+1
  66.     ;ENDWHILE
  67.  
  68. ; copy argument
  69.     ;LET R3=0
  70.     ;WHILE ((commandline[commandlineindex]!=0) && (commandline[commandlineindex]!=32))
  71.        ;LET filename[R3]=commandline[commandlineindex]
  72.        ;LET R3=R3+1
  73.        ;LET commandlineindex=commandlineindex+1
  74.     ;ENDWHILE
  75.     ;LET filename[R3]=0
  76.     ;FREE R3
  77.  
  78.     ;IF (argvindex==1)
  79.        ;LET outfilehandle=open(filename)
  80.        ;LET close(outfilehandle)
  81.        ;LET strcpy(command,"DELETE ")
  82.        ;LET strcat(command,filename)
  83.        ;LET system(command);
  84.        ;LET outfilehandle=open(filename)
  85.     ;ENDIF
  86.     
  87.     ;IF ((argvindex>1) && (filename[0]!=0))
  88.        ;LET infilehandle=open(filename)
  89.        ;LET R4=0
  90.        ;WHILE (eof(infilehandle)==0)
  91.           ;LET bput2(outfilehandle,bget(infilehandle));
  92.           ;IF (R4==10)
  93.              MOV R0,`#'0
  94.              LDR R1,taskdataptr
  95.              SWI Wimp_Poll
  96.              ;SAVE R0
  97.              ;IF ( (R0==18) && ((taskdata[4]==0) || (taskdata[4]==8)) ) 
  98.                 ;LET close(infilehandle)
  99.                 B closedown
  100.              ;ENDIF
  101.              ;LET R4=0
  102.              ;FREE R0
  103.           ;ENDIF
  104.           ;LET R4=R4+1
  105.  
  106.        ;ENDWHILE
  107.        ;FREE R4          
  108.        ;LET close(infilehandle)
  109.     ;ENDIF
  110.     
  111.     ;LET argvindex=argvindex+1
  112.  
  113.  ;ENDWHILE
  114. closedown
  115.  
  116.  MOV R0,R5
  117.  LDR R1,task  
  118.  SWI Wimp_CloseDown
  119.  
  120.  ;IF (argvindex<=1)  
  121.     ;LET writestr("syntax: join outputfile inputfile1 inputfile2 ... inputfileN")
  122.     cr
  123.     ;LET writestr("joins N inputfiles into outputfile")
  124.     cr
  125.     ;LET writestr("cooperative wimp-\"multitasking\", if started by a obeyfile")
  126.     cr
  127.     ;LET writestr("This file is Freeware Copyright (c) MUFTI")
  128.     cr
  129.  ;ENDIF
  130.  
  131.  ;LET close(outfilehandle)
  132.  SWI OS_Exit
  133.  .END
  134.