Example SENDLPT.PRT
; SENDLPT
;
; Program for Proteus
;
; (C) 2003-2004 Simone Zanella Productions
;
; Send a file to parallel port (direct write, does not use Windows™ drivers).

#!proteus -z

!include "win32.prt"
!include "console.prt"

; Default parameters: LPT1
LptPort = "LPT1"

H2 = FOPEN(ARGV(5), 1)
IF EQ(H2, -1)
  IF GE(ARGC, 5)
    CONSOLELN "File " ARGV(5) " NOT found."    
  FI
  CONSOLELN ""
  CONSOLELN "Syntax: " ARGV(1) " " ARGV(2) " filename [/Pport]"
  CONSOLELN ""  
  CONSOLELN "Purpose: send specified file to the requested parallel port."
  CONSOLELN ""
  CONSOLELN "Default: LPT1"
  CONSOLELN ""
  CONSOLELN "/Pport             port = 1, 2, 3, .."
  CONSOLELN ""
  ABORT 0
FI

FOR X = 6 TO ARGC
  SetParameters(ARGV(X))
NEXT
CheckParameters()

H = W32CREATEFILE(LptPort, W32_GENERIC_WRITE, 0, \
                  W32_OPEN_EXISTING, 0)

IF EQ(H, -1)
  CONSOLELN "Could not open " LptPort "."
  ABORT 2
FI

DISPSET(DISP_BLINK, DISP_BLINK_OFF)
DISPSET(DISP_FOREG, YELLOW)
DISPSET(DISP_BACKG, BLUE)
DISPSET(DISP_UNSFG, YELLOW)
DISPSET(DISP_SELBG, GREEN)

DISPSET(DISP_JUST, DISP_JUST_NONE)
DISPSET(DISP_JLEN, 0)
DISPSET(DISP_SHADOW, DISP_SHADOW_RIGHT)
DISPSET(DISP_SOUND, 0)

DISPSET(DISP_JLEN, 17)

DISPCLS()
DISPWRITE(1, 1, "Parallel port: " LptPort)
DISPWRITE(1, 2, "Sending: " ARGV(5))

Total = FSIZE(H2)
Prev = -1
Prev = ProgressBar(0, Total, 5, 1, Prev, 50, 3)

WHILE NOT(FEOF(H2))
  N = FSEEK(H2, 0, 1)
  L = FREAD(H2, 1024)
  IF EQ(W32WRITEFILE(H, L), -1)
    DISPWRITE(1, 8, "Error sending file.")
    W32CLOSEHANDLE(H)
    FCLOSE(H2)
    ABORT 0
  FI
  Prev = ProgressBar(N, Total, 5, 1, Prev, 50, 3)  
LOOP
Prev = ProgressBar(Total, Total, 5, 1, Prev, 50, 3)

W32CLOSEHANDLE(H)
FCLOSE(H2)
DISPWRITE(1, 8, "Done.")

ABORT 0


FUNCTION ProgressBar(value, total, starty, startx, prev, len, altezza)

; Write a progress bar

IF EQ(prev, -1)
  FOR y1 = starty TO DEC(ADD(starty, altezza))
    FOR x = startx TO DEC(ADD(startx, len))
      DISPWRITE(x, y1, CHR(0xB0))
    NEXT
  NEXT
  x = startx
ELSE
  x = prev
FI
end = ADD(startx, IIF(total, FDIV(MUL(len, value), total), len))

FOR y1 = starty TO DEC(ADD(starty, altezza))
  FOR x1 = x TO DEC(end)
    DISPWRITE(x1, y1, CHR(0xDB))
  NEXT
NEXT
RETURN end


FUNCTION CheckParameters()

; Check parameters

RETURN


FUNCTION SetParameters(s)

; Set port parameters

s = RESTFROM(s, 2)
SWITCH LEFT(s, 1) STRIEQ
ON "P"
  ; Select port
  IF OR(LT(RESTFROM(s, 2), 1), GT(RESTFROM(s, 2), 20))
    CONSOLELN "Wrong port: /" s
    ABORT 1
  FI
  _LptPort = "LPT" RESTFROM(s, 2)

OTHER
  CONSOLELN "Unknown parameter: /" s
  ABORT 1
OFF
RETURN
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