🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: free.it.visual-basic
Article #3524

Re: cancellare riga

#3524
From: Anak
Date: Fri, 28 Jun 2002 10:37
75 lines
2888 bytes
Sono d'accordo con Roscio, puoi fare cos�:


delete$="stringa da cancellare"

open "source.txt" for input as #1
    open "target.txt" for output as #2
        do while not eof(1)
            line input #1,row$
            if delete$<>row$ then
                print #2,row$
            end if
        loop
    close #2
close #1
kill "source.txt"
name "target.txt" as "source.txt"

Oppure se non sai a priori il contenuto della riga da cancellare ma sai che
devi cancellare la quinta (ad es) modifichi in questo modo:

open "source.txt" for input as #1
    open "target.txt" for output as #2
        do while not eof(1)
            a=a+1
            line input #1,row$
            if a<>5 then
                print #2,row$
            end if
        loop
    close #2
close #1
kill "source.txt"
name "target.txt" as "source.txt"


A presto

            Anak
 anakthewolf@libero.it

"Roscio" <sergint@libero.it> ha scritto nel messaggio
news:99FS8.75897$j65.1803790@twister1.libero.it...
> "jekonet" <fbwros@tin.it> wrote in message
> news:M5CS8.8661$Jj7.252305@news1.tin.it...
> > ciao ragazzi,
> > come posso fare a cancellare una particolare riga in un file di testo?
> > Es.:
> > contenuto del file:
> > gino
> > pino
> > dino
> >
> > io devo avere nel file:
> > gino
> > dino
>
> I file di testo devono essere letti e riscritti completamente;
> non si pu� togliere una riga con un singolo comando.
>
> Quindi, hai due alternative:
>
> 1) Leggi tutte le righe in memoria e poi scrivi solo
>      quelle che ti interessano su un altro file (o sullo
>      stesso dopo averlo cancellato)
>
> 2) Leggi riga per riga e vai controllando se
>      la riga che hai letto deve essere scritta
>      nel file di destinazione o no
>
> --
> Er Roscio.
>
>
>
Technical Details
Message-ID: <K%WS8.12160$Jj7.331110@news1.tin.it>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!supernews.com!news.tele.dk!small.news.tele.dk!212.177.105.133!news.mailgate.org!nntp.infostrada.it!news-out.tin.it!news-in.tin.it!news1.tin.it.POSTED!not-for-mail
References: <M5CS8.8661$Jj7.252305@news1.tin.it> <99FS8.75897$j65.1803790@twister1.libero.it>

Show Full Headers
Complete Article Headers
X-Google-Language: ITALIAN,ASCII
X-Google-Thread: f94ee,160b8caf77452dc
X-Google-Attributes: gidf94ee,public
X-Google-ArrivalTime: 2002-06-28 03:38:52 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!supernews.com!news.tele.dk!small.news.tele.dk!212.177.105.133!news.mailgate.org!nntp.infostrada.it!news-out.tin.it!news-in.tin.it!news1.tin.it.POSTED!not-for-mail
From: "Anak" <Anak@excite.it>
Newsgroups: free.it.visual-basic
References: <M5CS8.8661$Jj7.252305@news1.tin.it> <99FS8.75897$j65.1803790@twister1.libero.it>
Subject: Re: cancellare riga
Lines: 77
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
Message-ID: <K%WS8.12160$Jj7.331110@news1.tin.it>
Date: Fri, 28 Jun 2002 10:37:30 GMT
NNTP-Posting-Host: 213.45.59.17
X-Complaints-To: newsmaster@tin.it
X-Trace: news1.tin.it 1025260650 213.45.59.17 (Fri, 28 Jun 2002 12:37:30 MET DST)
NNTP-Posting-Date: Fri, 28 Jun 2002 12:37:30 MET DST
Organization: TIN