Programma di esempio REMVB.PRT
; REMVB
;
; Programma per Proteus
;
; (C) 2000-2003 Simone Zanella Productions
;
; Rimuove i commenti dai file Visual Basic specificati.
;
; Algoritmo:
; - rimuove tutte le linee che iniziano per ' e eventuali commenti a fine riga.

#!proteus -z

SourceDir = STRIPQUOTES(ARGV(5))
DestDir = STRIPQUOTES(ARGV(6))

IF OR(ISEMPTY(SourceDir), ISEMPTY(DestDir))
  CONSOLELN "Sintassi: " ARGV(1) " " ARGV(2) " [\"filespec\" \"destinazione\"]"
  CONSOLELN "Scopo: rimuove i commenti VB dai file specificati, creando i nuovi file in destinazione."
  CONSOLELN "Il parametro destinazione deve essere un nome di directory esistente."
  ABORT 0
FI

; Determina il separatore di directory sulla base del sistema operativo
!ifdef UNIX
  DirSep = "/"
!else
  DirSep = "\\"
!endif

; Isola la directory base e la specifica dei file
X = STRRSTR(SourceDir, DirSep)
IF X
  BaseDir = LEFT(SourceDir, X)
  Spec = RESTFROM(SourceDir, INC(X))
ELSE
  BaseDir = ""
  Spec = SourceDir
FI

; Costruisce un albero AVL dei file da processare
H = DIROPEN(SourceDir, 1)
F = IIF(NEQ(H, -1), 1, 0)
A = AVLNEW()
WHILE GT(F, 0)
  AVLSET(A, DIRLAST(H, 1), 0)
  F = DIRNEXT(H)
LOOP
DIRCLOSE(H)

; Trasforma l'albero in un vettore, per semplicità operativa
; Nessun ordinamento è richiesto, in quanto le chiavi sono già ordinate
VF = AVLKEYS(A)
AVLFREE(A)

IF STRNEQ(RIGHT(DestDir, 1), DirSep)
  DestDir = DestDir DirSep
FI

; Processa tutti i file
FOR X = 1 TO VECLEN(VF)
  IF AllowedExt(VECGET(VF, X))
    H = FOPEN(BaseDir IIF(ISNOTEMPTY(BaseDir), DirSep, "") \
              VECGET(VF, X), 1)

    IF EQ(H, -1)
      CONSOLELN "Errore: impossibile aprire " VECGET(VF, X)
      CONTINUE
    FI

    D = FOPEN(DestDir VECGET(VF, X), 28)

    IF EQ(D, -1)
      CONSOLELN "Errore: impossibile creare \"" DestDir VECGET(VF, X) "\""
    ELSE
      CONSOLELN "Conversione di " VECGET(VF, X)
      WHILE NOT(FEOF(H))
        L = FREADLN(H)
        IF STRNEQ(LEFT(LTRIM(L, " "), 1), "'")
          FWRITELN(D, ControllaLinea(L))
        FI
      LOOP
      FCLOSE(D)
    FI

    FCLOSE(H)
  ELSE

    CONSOLELN "Copia di " VECGET(VF, X)
    FCOPY(BaseDir IIF(ISNOTEMPTY(BaseDir), DirSep, "") \
          VECGET(VF, X), DestDir VECGET(VF, X))
  FI
NEXT

ABORT 0


FUNCTION ControllaLinea(l)

instr = 0
n = STRLEN(l)
FOR x = 1 TO n
  SWITCH SUBSTR(l, x, 1) STREQ
  ON "\""
    instr = IIF(instr, 0, 1)
  ON "'"
    IF NOT(instr)
      RETURN LEFT(l, DEC(x))
    FI
  OFF
NEXT
RETURN l


FUNCTION AllowedExt(s)

p = STRRSTR(s, ".")
ext = RESTFROM(s, INC(p))
IF OR(STRIEQ(ext, "FRM"), STRIEQ(ext, "BAS"))
  RETURN 1
FI
RETURN 0
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