 |
AutoHotkey Community Wir helfen uns gegenseitig aus der Patsche
|
| Vorheriges Thema anzeigen :: Nächstes Thema anzeigen |
| Autor |
Nachricht |
IsNull Gast
|
Verfasst am: So Nov 19, 2006 9:21 pm Titel: Datei in Benutzung, kann nicht gelöscht werden! |
|
|
Bin grad am coden von was grösserem(Auto Downloader), aber diese Sub macht mich noch krank.
Problem ist, das löschen eines Files welches ich zuvor ausgelesen hab.
| Code: |
GetNewUrl:
;This Sub takes the next Url in the given DeepnesSection
NewUrl =
NewText =
LEOF = True
;_______________________________________________________________________________
loop, read, %DMTemp%\%ActiveRootSection%.txt
{
;Link gefunden
LEOF = False
NewUrl = %A_LoopReadLine%
NewUrlDeepnes = %ActiveRootSection%
;________________Nun den genommenen link aus dem File löschen.__________________
TextToDel = %A_LoopReadLine%
FileRead, ReadedText, %DMTemp%\%ActiveRootSection%.txt
msgbox %DMTemp%\%ActiveRootSection%.txt
filedelete, %DMTemp%\%ActiveRootSection%.txt
if Errorlevel = 1
{
;!!!!!!!!!!!Hier fällt er immer rein, weil er das file nicht löschen kann.!!!!!!!!
msgbox there was a Problem to delete:`n%DMTemp%\%ActiveRootSection%.txt
return
}
StringReplace, NewText, ReadedText, %TextToDel% ,, All
Loop
{
StringReplace, NewText2, NewText, `r`n`r`n, `r`n, UseErrorLevel
if ErrorLevel = 0 ; No more replacements needed.
break
}
fileappend, %NewText2%,%DMTemp%\%ActiveRootSection%.txt
;_______________________________________________________________________________
break
}
if LEOF = True
{
;Set Next Stage
filedelete, %DMTemp%\%ActiveRootSection%.txt
a = 0
loop, %DMTemp%\*
{
a += 1
}
if a = 0
{
Finished = True
return
}
ActiveRootSection += 1 ;Takes the RootSection one Stage higher
}
return
|
Als es so nicht ging, hab ich ihn mit ner Msgbox vor dem löschen gestoppt, um das File per Hand zu löschen. Aber da scheint das Problem zu sein:
Er liefert die Meldung dass diese Datei in benutzung ist und nicht gelöscht werden kann.
Hat das was mit dem "fileread,..." Befehl zu tun, mit dem ich die Datei vorher auslese?
Hoffe ihr versteht mein Problem...
Greetz
IsNull |
|
| Nach oben |
|
 |
denick
Anmeldedatum: 15.09.2006 Beiträge: 1230 Wohnort: Berlin
|
Verfasst am: Mo Nov 20, 2006 6:24 am Titel: |
|
|
Moin,
soweit ich es verstehe hast Du ein Verzeichnis %DMTemp% mit 0 - n Dateien "n.txt" mit 1 - n Sätzen, die alle eine Aktion auslösen sollen.
Dein Löschen scheitert daran, dass Du zu diesem Zeitpunkt innerhalb einer File-Reading Loop bist. Auch AHK wird während einer solchen Aktion die Datei offen halten.
Ich weiß nicht, wie der restliche Code aussieht, für diese Bearbeitung würde ich mir aber folgende grundsätzliche Struktur vorstellen:
| Code: | Loop, %DMTemp%\* .txt
{
loop, read, %A_LoopFileFullPath%
{
NewUrl = %A_LoopReadLine%
;...
;Hier einen Gosub, Funktionsaufruf oder den passenden Code einfügen
;...
}
FileDelete, %A_LoopFileFullPath%
} |
Wenn das Ganze anders läuft, bräuchte ich eine weitere Beschreibung. _________________ Hilfe zur Hilfe
(de)nick |
|
| Nach oben |
|
 |
IsNull Gast
|
Verfasst am: Mo Nov 20, 2006 12:13 pm Titel: |
|
|
So einfach ist's dann auch wieder nicht.
Ich poste mal den ganzen code.
Was das Programm tun soll:
Es soll eine Basis Website auf bestimmte Files und weitere Links untersuchen. Dann lädt es die Files runter und sucht je nach Tiefe in den neu gefundenen Links wieder nach Files und Links. Das so lange, bis die gewünschte Tiefe erreicht ist.
Es funktioniert aber noch nicht wirklich.
Hier mal eine Features-Liste:
- Vom User spezifizierte Files runterladen --> funzt.
- Tiefe beachten --> funzt nicht wirklich ...wegen dem "nicht löschbaren text" und somit geht jetzt gar nichts mehr...
- Heruntergeladene Dateien "klug" abspeichern. (Wie viele Dateien in 1. Ordner usw...) --> funzt.
Hier mal der ganze Code: (ist ziemlich wirr komentiert englisch & deutsch gemischt, je nach Laune )
| Code: |
;==========================================================================]
;Programmname: Downloadmaster______________________________________________]
;Ver. 2.0__________________________________________________________________]
;Last Changes Date: 03.11.06_______________________________________________]
;Coded by: IsNull__________________________________________________________]
;____________________FREEWARE___&___OPENSOURCE_____________________________]
;==========================================================================]
;Sämtliche HardcodePfade========================================================
DefaultMDir = C:\Programme\DownloadMaster\Downloaded Files
RootDLFolder = C:\Programme\DownloadMaster\Bin\RootOptions.txt
Zähler = C:\Programme\DownloadMaster\Temp\Number.txt
DirCounter = C:\Programme\DownloadMaster\Temp\DirCounter.txt
PathToExtensions = C:\Programme\DownloadMaster\Bin\CMPExtensions.txt
PathToExtensions2 = C:\Programme\DownloadMaster\Bin\CMPSites.txt
LoadedTarget = C:\Programme\DownloadMaster\Temp\LoadedTarget.TXT
DestFile = C:\Programme\DownloadMaster\Temp\AllLinks.txt
WellFileURLs = C:\Programme\DownloadMaster\Temp\WellFileUrls.txt
WellSearchURLs = C:\Programme\DownloadMaster\Temp\WellSearchUrls.txt
MaxFilesPerFolderTXT = C:\Programme\DownloadMaster\Bin\MaxfilesPerFolder.txt
RootDeepnesTXT = C:\Programme\DownloadMaster\Bin\Rootdeepnes.txt
DMTemp = C:\Programme\DownloadMaster\Temp\INI
;===============================================================================
;Noch nicht implentierte Usereinstellungen:
DirPfrefix = ACS
NamePrefix = DLMA
;===============================================================================
;Initialisiert das Dateisystem von Downloadmaster:
;===============================================================================
FileCreateDir, C:\Programme\DownloadMaster\Bin
FileCreateDir, C:\Programme\DownloadMaster\Temp
FileRemoveDir, C:\Programme\DownloadMaster\Temp\INI ,1 ;löscht INI überbleibsel
FileCreateDir, C:\Programme\DownloadMaster\Temp\INI
;_______________________________________________________________________________
;Searchs the compareextensions - files from the User.
ifNotExist, %PathToExtensions%
{
fileappend,mpeg`navi`nwmv`n ,%PathToExtensions%
}
ifNotExist, %PathToExtensions2%
{
fileappend,html`n ,%PathToExtensions2%
}
;_______________________________________________________________________________
;Line1 = Main-Download-Folder
ifNotExist, %RootDLFolder%
{
fileappend,%DefaultMDir%,%RootDLFolder%
}
ifNotExist, %MaxFilesPerFolderTXT%
{
fileappend, 40`n, %MaxFilesPerFolderTXT%
}
ifNotExist, %RootDeepnesTXT%
{
fileappend, 0`n, %RootDeepnesTXT%
}
;===============================================================================
;
;
;========================================================================
;====Das Graphic User Interface (GUI):===================================
;========================================================================
Gui, Add, Tab,x+10 y+150 h400 w1000, Analyze|Downloadlist|Options|Start Download
Gui,Tab
Gui, +Resize ; Make the window resizable.
Gui, Color, black
Gui, Add, Picture, x0 y0 h150 w800, C:\Programme\SecurityVision\images\uper.jpg ;==============for all Tabs end===========================
Gui,Tab, 1
Gui, Add, Text, Cblue, Main Loader
Gui, Add, Text, cblue x50 y300, Target:
Gui, Add, Edit, cBlue vTarget x200 y300 w500
Gui, Add, Text, cblue x50 y350, Root Deepnes:
Gui, Add, Edit, cBlue vRDeep x200 y350 w30
Gui, Add, Button, cblue x270 y350, Save Deepnes
Gui, Add, Button, cBlue x50 y450 ,Analyze!
Gui,Tab, 2
Gui, Add, Text, Cblue, Lists of founded Sites and Files:
Gui, Add, Listbox, cBlue vListSites x50 y240 w400 h300
Gui, Add, Listbox, cBlue vListFiles x500 y240 w400 h300
Gui,Tab, 3
Gui, Add, Text, Cblue, Here can you modifi, what you like to download:
Gui, Add, Text, Cblue x50 y250, Main Download Destination:
Gui, Add, Button, Cblue x250 y250,Browse...
Gui, Add, Edit, Cblue x50 y300 w400 vMDownloadDestEdit
Gui, Add, Text, Cblue x50 y350 ,Max. Files per Folder:
Gui, Add, Edit, Cblue x50 y375 vMaxFilesPerFolder
Gui, Add, Text, Cblue x500 y220, The Extensions to Download:
Gui, Add, Listbox, cBlue vCMPExtLIST x500 y240 w400 h300
Gui, Add, Button, Cblue x450 y500, Add
Gui, Add, Button, Cblue x450 y450, Del
Gui, Add, Button, Cblue x420 y420, Refresh!
Gui, Add, Edit, Cblue x300 y500 w100 vToAdd
Gui,Tab, 4
Gui, Add, Text, Cblue, Start the download:
Gui, Add, Button, cblue, Load
Gui, Add, Edit, cBlue x100 y230 w400 h300 vDownloadLog
Gui, Show,,MasterLoad ++Coded by IsNull++
Gosub, refresh
return
;===============================================================================
;Main Code:
;===============================================================================
;===============================================================================
ButtonAdd:
GuiControlGet, ToAdd
FileAppend,%ToAdd%`n, %PathToExtensions%
GoSub, refresh
return
;===============================================================================
;===============================================================================
ButtonSaveDeepnes:
filedelete, %RootDeepnesTXT%
GuiControlGet, RDeep
fileappend, %RDeep% ,%RootDeepnesTXT%
GoSub, refresh
return
;===============================================================================
;===============================================================================
ButtonDel:
TempCMP = C:\CMPtemp.txt
GuiControlGet, CMPExtLIST
ItemToDelete = %CMPExtLIST%
loop, read, %PathToExtensions%
{
If ItemToDelete = %A_LoopReadLine%
{
msgbox itm to del %A_LoopReadLine%
}
Else
{
Fileappend, %A_LoopReadLine%`n, %TempCMP%
}
}
msgbox look into file
FileMove, %TempCMP%, %PathToExtensions% , 1 ;Overwrite existing CMP file.
Gosub, Refresh
filedelete, %TempCMP%
;run, %A_ScriptFullPath%
return
;===============================================================================
;===============================================================================
ButtonRefresh!:
Refresh:
GuiControl,, CMPExtLIST,|
GuiControl,, MDownloadDestEdit,
Loop, read, %PathToExtensions%
{
GuiControl,, CMPExtLIST, %CMPExtLIST%%A_LoopReadLine%
}
Loop, read, %RootDLFolder%
{
GuiControl,, MDownloadDestEdit,%A_LoopReadLine%
}
Loop, read, %MaxFilesPerFolderTXT%
{
GuiControl,, MaxFilesPerFolder,%A_LoopReadLine%
MaxFilesPerDir = %A_LoopReadLine%
}
Loop, read, %RootDeepnesTXT%
{
GuiControl,, RDeep,%A_LoopReadLine%
RootDeepnes = %A_LoopReadLine%
}
return
;===============================================================================
;===============================================================================
;===============================================================================
ButtonBrowse...:
FileSelectFolder, MainFolder, , 3, Select the Maindownload Destination:
if MainFolder =
MsgBox, You didn't select a folder.
else
{
filedelete, %RootDLFolder%
fileappend,%MainFolder%,%RootDLFolder%
GoSub, refresh
MsgBox, You selected folder "%MainFolder%".
}
return
;===============================================================================
ButtonAnalyze!:
;Starts the Process
;1. download the RootTargetsite
GuiControlGet, Target
TargetL = %Target%
if TargetL =
{
msgbox You must enter a Target!
return
}
Else
{
fileappend,%TargetL%, %DMTemp%\0.txt
ActiveRootSection = 0 ;Deepnes is on the begin zero.
Finished = False
GoSub Analyze
}
Msgbox Finished!!
return
;=====================================================================================
;======================================================================================
Analyze:
if Finished = True
{
return
}
;NewUrl aus GetNewUrl - Sub holen. Da wird auch die Deepnes der Url gesetzt. +1 für eine tiefere Url....
GoSub, GetNewUrl
;NewUrl = Neue Url
msgbox NewUrl: %NewUrl%
;NewUrlDeepnes = Deepnes der neuen Url
msgbox NewUrlDeepnes: %NewUrlDeepnes%
filedelete, %LoadedTarget%
URLDownloadToFile, %NewUrl%, %LoadedTarget%
if Errorlevel = 1
{
GoSub, Analyze
}
SourceFile = %LoadedTarget%
gosub, UrlsearchSub
SourceFile =
GoSub, CreateLists
;====================================================================================
UrlsearchSub:
if SourceFile =
return ; This will exit in this case.
IfExist, %DestFile%
{
FileDelete, %DestFile%
}
;_______________________________________________________________________________
; Folgender Code sucht nach sämtlichen URLs in einer Site. Das Grundgerüst wurde
; aus der Hilfedatei von HotkeyScript übernommen.
;_______________________________________________________________________________
LinkCount = 0
Loop, read, %SourceFile%, %DestFile%
{
URLSearchString = %A_LoopReadLine%
Gosub, URLSearch
}
MsgBox %LinkCount% links were found and written to "%DestFile%".
GoSub, CreateLists
return
URLSearch:
; It's done this particular way because some URLs have other URLs embedded inside them:
StringGetPos, URLStart1, URLSearchString, http://
StringGetPos, URLStart2, URLSearchString, ftp://
StringGetPos, URLStart3, URLSearchString, www.
; Find the left-most starting position:
URLStart = %URLStart1% ; Set starting default.
Loop
{
; It helps performance (at least in a script with many variables) to resolve
; "URLStart%A_Index%" only once:
ArrayElement := URLStart%A_Index%
if ArrayElement = ; End of the array has been reached.
break
if ArrayElement = -1 ; This element is disqualified.
continue
if URLStart = -1
URLStart = %ArrayElement%
else ; URLStart has a valid position in it, so compare it with ArrayElement.
{
if ArrayElement <> -1
if ArrayElement < %URLStart%
URLStart = %ArrayElement%
}
}
if URLStart = -1 ; No URLs exist in URLSearchString.
return
; Otherwise, extract this URL:
StringTrimLeft, URL, URLSearchString, %URLStart% ; Omit the beginning/irrelevant part.
Loop, parse, URL, %A_Tab%%A_Space%<> ; Find the first space, tab, or angle (if any).
{
URL = %A_LoopField%
break ; i.e. perform only one loop iteration to fetch the first "field".
}
; If the above loop had zero iterations because there were no ending characters found,
; leave the contents of the URL var untouched.
; If the URL ends in a double quote, remove it. For now, StringReplace is used, but
; note that it seems that double quotes can legitimately exist inside URLs, so this
; might damage them:
StringReplace, URLCleansed, URL, ",, All
FileAppend, %URLCleansed%`n
LinkCount += 1
; See if there are any other URLs in this line:
StringLen, CharactersToOmit, URL
CharactersToOmit += %URLStart%
StringTrimLeft, URLSearchString, URLSearchString, %CharactersToOmit%
Gosub, URLSearch ; Recursive call to self.
return
;===============================================================================
;_______________________________________________________________________________
;===============================================================================
CreateLists:
;TakeExt ist die Endung der Dateien, welche gedownloadet werden sollen.
;SearchExt ist die Endung der Dateien, welche eine Internetseite darstellen und in welchen nochmals gesucht werden soll.
;Hier legt Root Deepnes die tiefe des suchens fest.
;find in the File specivied Extension:
;_______________________________________________________________________________
loop, read, %PathToExtensions%
{
TakeExt = %A_LoopReadLine%
loop, read, %DestFile%
{
IfInString, A_LoopReadLine, %TakeExt%
{
fileURL = %A_LoopReadLine%
gosub, StoreFileURL
}
}
}
;_______________________________________________________________________________
loop, read, %PathToExtensions2%
{
SearchExt = %A_LoopReadLine%
loop, read, %DestFile%
{
IfInString, A_LoopReadLine, %SearchExt%
{
SearchURL = %A_LoopReadLine%
GoSub, StoreSearchURL
}
}
}
Msgbox Site- and Downloadfile Created :-)
Gosub, FillLists
;Analyze for "NewUrl" finished.
GoSub, DownLoad
GoSub, Analyze ;recursive call to self (break will access after download)
return
;===============================================================================
;_______________________________________________________________________________
FillLists:
Loop, read, %WellFileURLs%
{
GuiControl,, ListFiles, %ListFiles%%A_LoopReadLine%
}
Loop, read, %WellSearchURLs%
{
GuiControl,, ListSites, %ListSites%%A_LoopReadLine%
}
return
;_______________________________________________________________________________
;===============================================================================
StoreFileURL:
FileExist = 0
loop, read, %WellFileURLs%
{
if A_LoopReadLine = %FileURL%
{
;Wenn die Url schon im UrlFile-File existiert, dann exist true und den loop verlassen.
FileExist = 1
break
}
}
if FileExist = 0
{
fileappend, %FileURL%`n, %WellFileURLs%
}
fileURL =
return
;===============================================================================
StoreSearchURL:
LinkExist = 0
DeeperSection = %ActiveRootSection%
DeeperSection += 1
loop, read, %DMTemp%\%DeeperSection%.txt
{
if A_LoopReadLine = %SearchURL%
{
;Wenn die Url schon im UrlSearchfile existiert, dann exist true und loop verlassen.
LinkExist = 1
break
}
}
if LinkExist = 0
{
fileappend, %SearchURL%`n, %DMTemp%\%DeeperSection%.txt
}
searchURL =
return
;===============================================================================
;_______________________________________________________________________________
;===============================================================================
;DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
;DOWNLOAD SECTION
;Starts the download of the files in the WellFilesURLs.txt
;===============================================================================
DownLoad:
ButtonLoad:
GuiControlGet, DownloadLog
input = %DownloadLog%Preparing Download...
GuiControl,, DownloadLog, %Input%
IfNotExist, %WellFileURLs%
{
GuiControlGet, DownloadLog
input = %DownloadLog%`nThe Target Urls does not exist.`nRequired File: %WellFileURLs%
GuiControl,, DownloadLog, %Input%
if %NewUrlDeepnes% = %RootDeepnes%
{
Msgbox Order Finished !NewUrlDeepnes: %NewUrlDeepnes% = RootDeepnes: %RootDeepnes%
return
}
return
}
dz = 0
fz = 0
Loop, read, %WellFileURLs%
{
URLName = %A_LoopReadLine%
Gosub, TakeDirSub
URLDownloadToFile, %A_LoopReadLine%, %StoreDirIs%\%GenNameIS%
if Errorlevel = 1
{
GuiControlGet, DownloadLog
input = %DownloadLog%`nFaild: %A_LoopReadLine%
GuiControl,, DownloadLog, %Input%
fz += 1
}
Else
{
GuiControlGet, DownloadLog
input = %DownloadLog%`n%A_LoopReadLine%
GuiControl,, DownloadLog, %Input%
dz += 1
}
StoreDirIs = ;Means to make the folder variable blank...
GenNameIS =
Gui, show
}
GuiControlGet, DownloadLog
input = %DownloadLog%`n ==================================`nDownload Finished`nThere are %dz% new Files`n and %fz% Files are faild to load.
GuiControl,, DownloadLog, %Input%
if %NewUrlDeepnes% = %RootDeepnes%
{
Msgbox Order Finished !NewUrlDeepnes: %NewUrlDeepnes% = RootDeepnes: %RootDeepnes%
Finished = True
return
}
Gosub, Analyze
return
;===============================================================================
;===============================================================================
TakeDirSub:
;Will find a good Folder & Filenaeme or create any folder, where the
; downloaded File will be stored.
GuiControlGet, MDownloadDestEdit ;Liest das Hauptdownload Ziel aus,
MainDirIs = %MDownloadDestEdit% ;Und stellt es in die Variable. MainDirIs
;Schauen was existiert:
FolderCount = 0 ;Means to set the Variable blank.
Loop, %MainDirIs%\* , 2 ;<-- Looks only for Folders.
{
FolderCount = %A_Index%
}
if FolderCount = 1
{
Gosub, Newfolder ;Wenn kein Folder besteht (A_index = 1) neuen erstellen.
GuiControlGet, DownloadLog
input = %DownloadLog%`nNo Existing Folder found!
GuiControl,, DownloadLog, %Input%
}
Else
{
; Es besteht ein Folder. Schauen ob dort noch "Platz" ist. Sonst auch neuer.
GuiControlGet, DownloadLog
input = %DownloadLog%`nExisting Folder found.
GuiControl,, DownloadLog, %Input%
Gui, Show
GoSub, CheckofSpace
}
;So nun sollte in StoreDirIs der DirPfad sein. Testen wir's nochmal
;(Warum auch immer...) wenn er existiert noch den unique Namen erstellen...
ifExist, %StoreDirIs%
{
GoSub, Genname
}
Else
{
Msgbox Fatal Error...can't find:`n File: "%StoreDirIs%"
return
}
;Es befindet sich nun in StoreDirIs der Pfad zu Ordner, und in GenNameIs der
; Name der neuen Datei.
;Bereit für den Download:
return
;===============================================================================
;===============================================================================
CheckofSpace:
;Es besteht ein Folder...checken ob er gut ist:
StoreDirIs =
Closed = 0
Loop, %MainDirIs%\* , 2 ;Nur Folder werden Angeschaut.
{
FolderToCheck = %A_LoopFileLongPath%
Loop, %FolderToCheck%\*, 0
{
FilesInDir = %A_Index%
}
if FilesInDir < %MaxFilesPerDir%
{
StoreDirIs = %FolderToCheck%
break
}
}
if StoreDirIs =
{
GuiControlGet, DownloadLog
input = %DownloadLog%`nThere are %FilesInDir% Files in the Dir by %MaxFilesPerDir%! Too much!
GuiControl,, DownloadLog, %Input%
GoSub, NewFolder
}
Else
{
;Ein brauchbarer Ordner gefunden. -->In diesen Downloaden
;Als Variable wurde StoreDirIs gesetzt.
}
return
;===============================================================================
;===============================================================================
Genname:
;Will generate a unique name in a dir.
FileNumber = 0
loop
{
SplitPath, URLName,,, Ext
GenNameIS = %StoreDirIs%\%NamePrefix%_%FileNumber%.%Ext%
ifNotExist, %GenNameIS%
{
break
}
;Wenn StoreDirIs nicht existiert, dann brich den loop ab. Sonst +1
FileNumber += 1
}
Gennamefile:
GenNameIS = %NamePrefix%_%FileNumber%.%Ext%
return
;===============================================================================
;===============================================================================
Newfolder:
GuiControlGet, DownloadLog
input = %DownloadLog%`nCreate a new folder
GuiControl,, DownloadLog, %Input%
DirNumber = 0 ; Starts with zero and loop so long,
; as the Folder will be unique.
loop
{
StoreDirIs = %MainDirIs%\%DirPfrefix%_%DirNumber%
ifNotExist, %StoreDirIs%
{
FileCreateDir, %StoreDirIs% ;Erstellt den neuen Ordner
break
}
;Wenn StoreDirIs noch nicht existiert, dann brich den loop ab. Sonst + 1
DirNumber += 1
}
return
;===============================================================================
;===============================================================================
GetNewUrl:
;This Sub takes the next Url in the given DeepnesSection
NewUrl =
LEOF = True
loop, read, %DMTemp%\%ActiveRootSection%.txt
{
;Link gefunden
LEOF = False
NewUrl = %A_LoopReadLine%
NewUrlDeepnes = %ActiveRootSection%
TextToDel = %A_LoopReadLine%
FileRead, ReadedText, %DMTemp%\%ActiveRootSection%.txt
filedelete, %DMTemp%\%ActiveRootSection%.txt
StringReplace, NewText, ReadedText, %TextToDel% ,, All
Loop
{
StringReplace, NewText, NewText, `r`n`r`n, `r`n, UseErrorLevel
if ErrorLevel = 0 ; No more replacements needed.
break
}
IF NewText =
{
;Dann das File nicht mehr erstellen.
}
Else
{
fileappend, %NewText%,%DMTemp%\%ActiveRootSection%.txt
}
;_______________________________________________________________________________
break
}
if LEOF = True
{
;wenn nichts gefunden wird, ist das file lehr. nächste Stage
;Das file löschen:
filedelete, %DMTemp%\%ActiveRootSection%.txt
;Schauen, ob noch was im INI Ordner existiert:
a = 0
loop, %DMTemp%\*
{
a += 1
}
if a = 0
{
; Es existiert nichts mehr. ende.
MsgBox Ende
Finished = True
return
}
ActiveRootSection += 1 ;Takes the RootSection one Stage higher
}
;sonst zu Analyze zurükkehren.
return
;===============================================================================
GuiClose:
GuiEscape:
ExitApp
|
Was würdet ihr ändern ?
Ratschläge/Konstruktive Kritik werden dankend angenommen.
Greetz
IsNull |
|
| Nach oben |
|
 |
denick
Anmeldedatum: 15.09.2006 Beiträge: 1230 Wohnort: Berlin
|
Verfasst am: Mo Nov 20, 2006 2:30 pm Titel: |
|
|
Hallo,
die Deiner Logik nächste Lösung für das Löschproblem könnte so aussehen (testen kann ich's nicht):
| Code: | GetNewUrl:
;This Sub takes the next Url in the given DeepnesSection
NewUrl =
LEOF := True
loop, read, %DMTemp%\%ActiveRootSection%.txt
{
;Link gefunden
LEOF := False
NewUrl = %A_LoopReadLine%
NewUrlDeepnes = %ActiveRootSection%
TextToDel = %A_LoopReadLine%
break
}
If (LEOF = False)
{
FileRead, ReadedText, %DMTemp%\%ActiveRootSection%.txt
filedelete, %DMTemp%\%ActiveRootSection%.txt
StringReplace, NewText, ReadedText, %TextToDel% ,, All
Loop
{
StringReplace, NewText, NewText, `r`n`r`n, `r`n, UseErrorLevel
if ErrorLevel = 0 ; No more replacements needed.
break
}
IF NewText = `r`n ; ein `r`n wird wohl immer übrig bleiben
{
LEOF := True ;Dann das File nicht mehr erstellen.
}
Else
{
fileappend, %NewText%,%DMTemp%\%ActiveRootSection%.txt
}
}
If (LEOF = True)
{
;wenn nichts gefunden wird, ist das file lehr. nächste Stage
;Das file löschen:
filedelete, %DMTemp%\%ActiveRootSection%.txt
;Schauen, ob noch was im INI Ordner existiert:
a = 0
loop, %DMTemp%\*
{
a += 1
}
if a = 0
{
; Es existiert nichts mehr. ende.
MsgBox Ende
Finished = True
return
}
ActiveRootSection += 1 ;Takes the RootSection one Stage higher
}
;sonst zu Analyze zurükkehren.
return |
Probier's doch mal aus.  _________________ Hilfe zur Hilfe
(de)nick |
|
| Nach oben |
|
 |
IsNull Gast
|
Verfasst am: Mo Nov 20, 2006 5:07 pm Titel: |
|
|
Thx, werds mal probieren.
| Zitat: | | die Deiner Logik nächste Lösung |
meine Logik, ich weis ...
MfG
IsNull |
|
| Nach oben |
|
 |
denick
Anmeldedatum: 15.09.2006 Beiträge: 1230 Wohnort: Berlin
|
Verfasst am: Di Nov 21, 2006 4:30 pm Titel: |
|
|
| IsNull hat Folgendes geschrieben: | Thx, werds mal probieren.
| Zitat: | | die Deiner Logik nächste Lösung |
meine Logik, ich weis ...
MfG
IsNull |
Hi, das war nicht negativ gemeint. Ich wollte nur Dein Script möglichst wenig verändern.
Wenn Du noch was brauchst, melde Dich wieder.  _________________ Hilfe zur Hilfe
(de)nick |
|
| Nach oben |
|
 |
|
|
Du kannst Beiträge in dieses Forum schreiben. Du kannst auf Beiträge in diesem Forum antworten.
|
Powered by phpBB © 2001, 2005 phpBB Group Deutsche Übersetzung von phpBB.de
|