Example MIME64.PRT
; MIME64
;
; Program for Proteus
;
; (C) 1998-2004 Simone Zanella Productions
;
; This program write to output an encoded Mime Base 64 version
; of the first file specified.

IF ISEMPTY(ARGV(5))
  CONSOLELN "Syntax: " ARGV(1) " " ARGV(2) \
            " .. destination [filename]"
  CONSOLELN ""            
  CONSOLELN "Purpose: write to destination an encoded Mime Base 64 version " \
            "of filename"
  ABORT 0
FI
H = FOPEN(ARGV(5), 1)
IF EQ(H, -1)
  CONSOLELN "File \"" ARGV(5) "\" not found."
  ABORT 1
FI
PRINTLN "Content-Type: text/plain; charset=US-ASCII; name=\"" \
        QualifyName(ARGV(5)) "\""
PRINTLN "Content-transfer-encoding: base64"
PRINTLN ""
OutputLen = 60
InputLen = 45
B64Par = VECCREATE(0, 0, 0)
Status = 0
LastEOF = 1
WHILE NOT(FEOF(H))
  S = FREAD(H, InputLen)
  ; Save EOF value passed to MIME64
  LastEOF = LT(STRLEN(S), InputLen)
  MIME64(@S, @Status, B64Par, LastEOF)
  SWITCH Status
    ON 0
      ; No additional character
      PRINTLN S
    OTHER
      ; Split the line into two lines only if longer than OutputLen
      IF GT(STRLEN(S), OutputLen)
        D = SUB(STRLEN(S), OutputLen)
        C = RIGHT(S, D)
        S = LEFT(S, SUB(STRLEN(S), D))
        PRINTLN S
        PRINTLN C
      ELSE
        PRINTLN S
      FI
  OFF
LOOP
; Take care of remaining bytes from B64Par (in case last line was not complete)
IF NOT(LastEOF)
  S = ""
  MIME64(@S, @Status, B64Par, 1)
  PRINTLN S
FI
FCLOSE(H)
ABORT 0


FUNCTION QualifyName(s)

!ifdef UNIX
  p = STRRSTR(s, "/")
!else
  p = STRRSTR(s, "\\")
!endif
IF p
  s = RESTFROM(s, INC(p))
FI
RETURN s
Samples index Next example Previous example Contents Index
Midnight Lake iPhone Case Black Women Shoes Black Flat Shoes Leather Flats Black Patent Ballerinas Black Ballet Shoes Casual Shoes Black Shoes Women Balle Record Player Cufflinks Best iPhone XR Clear Cases iPhone XS/XS Max Leather Cases Sale Best iPhone 8/8 Plus Silicone Cases iPhone 7/7 Plus Cases & Screen Protector New Cases For iPhone 6/6 Plus iPhone 8 Case Sale iPhone Xr Case Online iPhone 7 Case UK Online iPhone X Case UK Sale iPhone X Case Deals iPhone Xs Case New Case For iPhone Xr UK Online Case For iPhone 8 UK Outlet Fashion Silver Cufflinks For Men Best Mens Cufflinks Outlet Online The Gold Cufflinks Shop Online Cheap Shirt Cufflinks On Sale Nice Wedding Cufflinks UK Online Top Black Cufflinks UK Online Mens Cufflinks Online Silver Cufflinks For Men Men Cufflinks UK Sale Gold Cufflinks UK Online Gold Cufflinks UK Silver Cufflinks UK Shirt Cufflinks Discount Online Mens Cufflinks Deals & Sales Girls Shoes For Dance Fashion Ballet Dance Shoes Best Ballet Flats Shoes UK Online Cheap Ballet Pointe Shoes UK Online Best Ballet Shoes Outlet Best Dance Shoes Sale Cheap Ballet Flats Sale UK Best Pointe Shoes Online UK Ballet Dance Shoes UK Shoes For Dance UK Best Ballet Slippers Shop Best Yoga Shoes Hotsell