Programma di esempio SENDLPT.PRT
; SENDLPT
;
; Programma per Proteus
;
; (C) 2003 Simone Zanella Productions
;
; Invia un file sulla porta parallela (invio diretto, senza passare per driver di Windows™).

#!proteus -z

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

; Parametri di default: LPT1
LptPort = "LPT1"

H2 = FOPEN(ARGV(5), 1)
IF EQ(H2, -1)
  IF GE(ARGC, 5)
    CONSOLELN "File " ARGV(5) " NON trovato."    
  FI
  CONSOLELN ""
  CONSOLELN "Sintassi: " ARGV(1) " " ARGV(2) " nomefile [/Pporta]"
  CONSOLELN ""  
  CONSOLELN "Scopo: invia il file specificato sulla porta parallela richiesta."
  CONSOLELN ""
  CONSOLELN "Default: LPT1"
  CONSOLELN ""
  CONSOLELN "/Pporta             porta = 1, 2, 3, .."
  CONSOLELN ""
  ABORT 0
FI

FOR X = 6 TO ARGC
  ElaboraParametri(ARGV(X))
NEXT
ConvalidaParametri()

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

IF EQ(H, -1)
  CONSOLELN "Impossibile aprire " 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, "Porta parallela: " LptPort)
DISPWRITE(1, 2, "Caricamento in corso di: " 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, "Errore nell'invio.")
    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, "Fatto.")

ABORT 0


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

; Procedura per il disegno di una barra di progresso

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 ConvalidaParametri()

; Convalida i parametri 

RETURN


FUNCTION ElaboraParametri(s)

; Legge i parametri per la porta

s = RESTFROM(s, 2)
SWITCH LEFT(s, 1) STRIEQ
ON "P"
  ; Seleziona la porta
  IF OR(LT(RESTFROM(s, 2), 1), GT(RESTFROM(s, 2), 20))
    CONSOLELN "Porta errata: /" s
    ABORT 1
  FI
  _LptPort = "LPT" RESTFROM(s, 2)

OTHER
  CONSOLELN "Parametro non riconosciuto: /" s
  ABORT 1
OFF
RETURN
Indice esempi Prossimo esempio Esempio precedente Indice per argomenti Indice analitico
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