Jump to content

DirCreate($DIR_NAME) doesn't work


Recommended Posts

Hi guys,

I have a file "sourcetoc2.txt" which contains only this:

<B>Before you begin:</B><BR>

I'm trying to make create a folder/dir like this

DirCreate($DIR_NAME)

but no folder gets created, no errors either.

Here's the full script:

Any Suggesions?

Thanks a lot ahead of time.

#include <file.au3>

Dim $aRecords

If Not _FileReadToArray("F:\hien\saveurl\sourcetoc2.txt",$aRecords) Then

MsgBox(4096,"Error", " Error reading log to Array error:" & @error)

Exit

EndIf

For $x = 1 to $aRecords[0]

msgbox(0,'', $aRecords[$x])

$CHECK_SRC_1 = StringInStr($aRecords[$x], "<B>",":</B>")

msgbox(0,"",$CHECK_SRC_1)

if $CHECK_SRC_1 = 1 Then

$READ_SRC_1 = $aRecords[$x]

MsgBox(0,"",$READ_SRC_1)

$REPL1 = StringReplace($READ_SRC_1, "<B>","")

$REPL2 = StringReplace($REPL1, ":</B>","")

$REPL3 = StringReplace($REPL2, "<BR>","")

$STRIP_CR = StringStripCR ($REPL3)

; create folder names from header titles extracted above

$DIR_NAME = '"F:\hien\results\'&$STRIP_CR&'"'

;$DIR_NAME = '\' & $REPL3 & '"'

msgbox(0, " ", $DIR_NAME)

;msgbox(0, " ", $REPL3)

;DirCreate("F:\hien\results\"&$REPL3&"test1")

DirCreate($DIR_NAME)

EndIf

Next

Exit

Edited by techshots
Link to comment
Share on other sites

Hi,

try this:

#include <file.au3>

Dim $aRecords
If Not _FileReadToArray("F:\hien\saveurl\sourcetoc2.txt", $aRecords) Then
    MsgBox(4096, "Error", " Error reading log to Array error:" & @error)
    Exit
EndIf

For $x = 1 To $aRecords[0]
    If StringInStr($String, "<B>", ":</B>") <> 0 Then
        DirCreate('F:\hien\results\' & _StringBetween1($String, "<B>", ":</B><BR>"))
    EndIf
Next
Exit

Func _StringBetween1($s_String, $s_Start = 0, $s_End = 0)
    $s_Start = StringInStr($s_String, $s_Start) + StringLen($s_Start)
    Return StringMid($s_String, $s_Start, StringInStr($s_String, $s_End) - $s_Start)
EndFunc  ;==>_StringBetween1

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Thanks! that worked!!!

But I want to know why

Dircreate($DIR_NAME) doesn't work

Hi,

try this:

#include <file.au3>

Dim $aRecords
If Not _FileReadToArray("F:\hien\saveurl\sourcetoc2.txt", $aRecords) Then
    MsgBox(4096, "Error", " Error reading log to Array error:" & @error)
    Exit
EndIf

For $x = 1 To $aRecords[0]
    If StringInStr($String, "<B>", ":</B>") <> 0 Then
        DirCreate('F:\hien\results\' & _StringBetween1($String, "<B>", ":</B><BR>"))
    EndIf
Next
Exit

Func _StringBetween1($s_String, $s_Start = 0, $s_End = 0)
    $s_Start = StringInStr($s_String, $s_Start) + StringLen($s_Start)
    Return StringMid($s_String, $s_Start, StringInStr($s_String, $s_End) - $s_Start)
EndFunc ;==>_StringBetween1

So long,

Mega

Link to comment
Share on other sites

HI,

:) okay.

I think you have to change one line to this:

$DIR_NAME = 'c:\hien\results\' & $STRIP_CR

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

I found that is a leading space issue...

I added this to check my theory

$STRIP_CR = StringStripWS($REPL3,8)

msgbox(0, "STRIP_CR ", $STRIP_CR)

And it works!

Thanks again for all ur help..

HI,

:) okay.

I think you have to change one line to this:

$DIR_NAME = 'c:\hien\results\' & $STRIP_CR

So long,

Mega

Link to comment
Share on other sites

Here's my revision..it works now for anyone who might be able to use it

The fix was to make sure there were no leading/trailing spaces.

Thnx!

#include <file.au3>

Dim $aRecords

If Not _FileReadToArray("F:\hien\saveurl\sourcetoc2.txt",$aRecords) Then

MsgBox(4096,"Error", " Error reading log to Array error:" & @error)

Exit

EndIf

For $x = 1 to $aRecords[0]

msgbox(0,'', $aRecords[$x])

$CHECK_SRC_1 = StringInStr($aRecords[$x], "<B>",":</B>")

msgbox(0,"",$CHECK_SRC_1)

if $CHECK_SRC_1 = 1 Then

$READ_SRC_1 = $aRecords[$x]

MsgBox(0,"",$READ_SRC_1)

$REPL1 = StringReplace($READ_SRC_1, "<B>","")

$REPL2 = StringReplace($REPL1, ":</B>","")

$REPL3 = StringReplace($REPL2, "<BR>","")

;$STRIP_CR = StringStripCR ($REPL3)

$STRIP_CR1 = StringStripWS($REPL3,1)

$STRIP_CR2 = StringStripWS($STRIP_CR1,2)

msgbox(0, "STRIP_CR ", $STRIP_CR2)

; create folder names from header titles extracted above

;$DIR_NAME = '"F:\hien\results\'&$STRIP_CR&'"'

;$DIR_NAME = '\' & $REPL3 & '"'

;msgbox(0, " ", $DIR_NAME)

msgbox(0, " ", $REPL3)

DirCreate('F:\hien\results\' & $STRIP_CR2 )

;DirCreate($DIR_NAME)

EndIf

Next

Exit

Thanks! that worked!!!

But I want to know why

Dircreate($DIR_NAME) doesn't work

Link to comment
Share on other sites

Here's my revision..it works now for anyone who might be able to use it

The fix was to make sure there were no leading/trailing spaces.

Thnx!

#include <file.au3>

Dim $aRecords

If Not _FileReadToArray("F:\hien\saveurl\sourcetoc2.txt",$aRecords) Then

MsgBox(4096,"Error", " Error reading log to Array error:" & @error)

Exit

EndIf

For $x = 1 to $aRecords[0]

msgbox(0,'', $aRecords[$x])

$CHECK_SRC_1 = StringInStr($aRecords[$x], "<B>",":</B>")

msgbox(0,"",$CHECK_SRC_1)

if $CHECK_SRC_1 = 1 Then

$READ_SRC_1 = $aRecords[$x]

MsgBox(0,"",$READ_SRC_1)

$REPL1 = StringReplace($READ_SRC_1, "<B>","")

$REPL2 = StringReplace($REPL1, ":</B>","")

$REPL3 = StringReplace($REPL2, "<BR>","")

;$STRIP_CR = StringStripCR ($REPL3)

$STRIP_CR1 = StringStripWS($REPL3,1)

$STRIP_CR2 = StringStripWS($STRIP_CR1,2)

msgbox(0, "STRIP_CR ", $STRIP_CR2)

; create folder names from header titles extracted above

;$DIR_NAME = '"F:\hien\results\'&$STRIP_CR&'"'

;$DIR_NAME = '\' & $REPL3 & '"'

;msgbox(0, " ", $DIR_NAME)

msgbox(0, " ", $REPL3)

DirCreate('F:\hien\results\' & $STRIP_CR2 )

;DirCreate($DIR_NAME)

EndIf

Next

Exit

There are several ways of doing this.

Maybe this one?

$Strip_Chrs = StringSplit("<B>,</B>,<BR>",",")
$Dir_Name = $READ_SRC_1
For $I = 1 To $Strip[0]
$Dir_Name = StringReplace($Dir_Name,$Strip[$I],Chr(0))
Next
$Dir_Name = 'F:\hien\results\' & StringStripWS($Dir_Name,3)
DirCreate($Dir_Name)

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...