home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD1.iso / GFX / Converter / AD2.55-C.DMS / in.adf / FREDScripts.lha / FREDFunctions / GetNumExtension < prev    next >
Encoding:
Text File  |  1994-01-31  |  976 b   |  52 lines

  1. /*
  2. ** GetNumExtension
  3. **
  4. ** $VER: GetNumExtension 1.1.0 (5.11.93)
  5. **
  6. ** This function separates the number from a FRED-created filename.
  7. **
  8. ** Copyright © 1992-1993 ASDG, Incorporated
  9. ** All Rights Reserved
  10. */
  11.  
  12.  
  13. GetNumExtension:
  14.     PARSE ARG name
  15.  
  16.     offset = 1
  17.     continue = 0
  18.     havenumber = 0
  19.     numletters = 0
  20.     DO WHILE (continue = 0)
  21.         IF ((pos = INDEX( name, '.' )) ~= 0) THEN
  22.             DELSTR( name, pos, 1 )
  23.         ELSE
  24.             continue = 1
  25.     END
  26.  
  27.     continue = 0
  28.     DO WHILE (continue = 0)
  29.         test = LEFT( name, LENGTH( name ) - ( offset - 1 ))
  30.         IF (DATATYPE( RIGHT( test, 1 )) = 'NUM' ) THEN DO
  31.             offset = offset + 1
  32.             havenumber = 1
  33.         END
  34.         ELSE DO
  35.             IF (havenumber = 1) THEN DO
  36.                 IF (numletters = 0) THEN
  37.                     ext = RIGHT( name, offset - 1 )
  38.                 ELSE DO
  39.                     test = LEFT( name, LENGTH( name ) - numletters )
  40.                     ext = RIGHT( test, ( offset - numletters - 1 ))
  41.                 END
  42.                 continue = 1
  43.             END
  44.             ELSE DO
  45.                 offset = offset + 1
  46.                 numletters = numletters + 1
  47.             END
  48.         END
  49.     END
  50.  
  51.     RETURN ext
  52.