Jump to content
Sign in to follow this  
Pauletp

Passing string to _FileListToArray

Recommended Posts

Pauletp

I have a problem with the following code.

If I run

;------------------Reference:
;----------------- Window open in Explorer is
;-----------------"e:\abc\script_test"
;-----------------"Script_test" contains 5 other folders


;---------- get path of window in Explorer
$GetTextString = WinGetText("")

;-------------locate the line break
$pos = StringInStr($GetTextString,@LF ) 

;-------------take out the first line for the folder path
$folderpath = StringLeft($GetTextString, $pos)
MsgBox (0,"", $folderpath,2)

#Include <File.au3>
#Include <Array.au3>

;-------------manual insertion of path string
;$FileList =_FileListToArray("E:\abc\Script_test","*", 2)
$FileList =_FileListToArray($folderpath,"*", 2)

_ArrayDisplay($FileList,"$FileList")

If @Error=1 Then
    MsgBox (0,"","No Files\Folders Found.")
    Exit
EndIf

;----------------

I get the message "No Files\Folders Found."

But if I manually insert the "E:\abc\Script_test"

I get the array listed as I expected showing the names of the folders.

I must be missing something basic here.

Anyone see the problem?

Thanks for a tip.

Share this post


Link to post
Share on other sites
weaponx

Does the msgbox show "E:\abc\Script_test"?

Share this post


Link to post
Share on other sites
someone

Well the first thing to jump out at me is that your if @error is after arraydisplay, so getting that error is actualy saying something went wrong with that(specifically, error 1 means what you are trying to display isn't an array). What is the error code coming off filelisttoarray?

EDIT cause grammer is my friend....

Edited by someone

While ProcessExists('Andrews bad day.exe')
	BlockInput(1)
	SoundPlay('Music.wav')
	SoundSetWaveVolume('Louder')
WEnd

Share this post


Link to post
Share on other sites
someone

Hmm this is interesting... look at this code - create a folder with some folders in it, and leave the explorer window open...

#Include <File.au3>
#Include <Array.au3>

WinActivate("[CLASS:CabinetWClass]", "") ;activate explorer
$GetTextString = WinGetText("")
$pos = StringInStr($GetTextString,@LF ) 
$folderpath = StringLeft($GetTextString, $pos)
;$folderpath = StringLeft($GetTextString, $pos -1)
ClipPut($folderpath)
ConsoleWrite($folderpath)
MsgBox (0,"", $folderpath)
$FileList =_FileListToArray($folderpath,"*", 2)
If @error Then
    MsgBox(0, "error code", @error)
EndIf

_ArrayDisplay($FileList,"$FileList")

If @Error=1 Then
    MsgBox (0,"","Not array.")
Send("#r")
ControlSetText("Run", "", "[CLASSNN:Edit1]", ClipGet())
Exit
EndIf

If you look, this will fail despite the message box containing what looks like the correct path. However, look at what gets pasted into the run dialog box..

to fix, uncomment the $pos -1 line, and comment the original. Is that a leftover linefeed character?


While ProcessExists('Andrews bad day.exe')
	BlockInput(1)
	SoundPlay('Music.wav')
	SoundSetWaveVolume('Louder')
WEnd

Share this post


Link to post
Share on other sites
Pauletp

Does the msgbox show "E:\abc\Script_test"?

Yes, it does.

Share this post


Link to post
Share on other sites
Pauletp

Hmm this is interesting... look at this code - create a folder with some folders in it, and leave the explorer window open...

#Include <File.au3>
#Include <Array.au3>

WinActivate("[CLASS:CabinetWClass]", "") ;activate explorer
$GetTextString = WinGetText("")
$pos = StringInStr($GetTextString,@LF ) 
$folderpath = StringLeft($GetTextString, $pos)
;$folderpath = StringLeft($GetTextString, $pos -1)
ClipPut($folderpath)
ConsoleWrite($folderpath)
MsgBox (0,"", $folderpath)
$FileList =_FileListToArray($folderpath,"*", 2)
If @error Then
    MsgBox(0, "error code", @error)
EndIf

_ArrayDisplay($FileList,"$FileList")

If @Error=1 Then
    MsgBox (0,"","Not array.")
Send("#r")
ControlSetText("Run", "", "[CLASSNN:Edit1]", ClipGet())
Exit
EndIf

If you look, this will fail despite the message box containing what looks like the correct path. However, look at what gets pasted into the run dialog box..

to fix, uncomment the $pos -1 line, and comment the original. Is that a leftover linefeed character?

Thank you for your help.

That's done the trick.

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.