APP  SpacedFiles
IN   -
OUT  SpcFiles
Type Module

DEFINE MODULE
 Name    SpacedFiles
 Help    Spaced filenames
 Version 1.00
 Author  Justin Fletcher
 Commands
  Name   SpacedFiles
  Help   ...
    The SpacedFiles module allows you to create files with spaces in their
    names and to have them automatically formatted into Alt-Spaces.
 End Commands
 PostFilter
  Name   Spaced Filenames
  Task   -
  Code   filtercode
  Accept Message
  Accept MessageRec
 End Filter
END MODULE

PRE
# REM OFF
# COND INLINE
# COND underline Do you want to change underlines to spaces
END PRE

.eventtype
   EQUD   0

.filtercode
   STMFD  (sp)!,{r1-r2,link}
   CMP    r0,#17
   CMPNE  r0,#18
   BEQ    isourevent
   LDMFD  (sp)!,{r1-r2,pc}

.isourevent
;   SWI    &104
   REM    "Filter %r0"
   STR    r0,eventtype
   LDR    r2,[r1,#16]
   CMP    r2,#1
   BEQ    isDataSave
.exitevent
   LDR    r0,eventtype
   LDMFD  (sp)!,{r1-r2,pc}

.isDataSave
; check the filename
   ADD    r2,r1,#44       ; filename
   REM    "Check icon, pointer = %&2"
._iDS_loop
   LDRB   r0,[r2]         ; read byte of filename
   ADD    r2,r2,#1
# COND OF underline
   CMP    r0,#ASC("_")    ; is it a _ ?
   MOVEQ  r0,#160         ; change to space
# COND END
   CMP    r0,#32          ; is it space
   MOVEQ  r0,#160         ; if so, use a hard-space
   STRB   r0,[r2,#-1]     ; store back
   BGE    _iDS_loop
   LDR    r0,eventtype
   LDMFD  (sp)!,{r1-r2,pc}

   EQUS   "Check out Final Conflict's albumn Quest - it's really "
   EQUS   "excellent prog-rock. Also, try Grey Lady Down The Crime, "
   EQUS   "or Jadis More That Meets The Eye."
   EQUB   0

#POST
#RUN <CODE>
# END
