Jump to content
Sign in to follow this  
Brenda1

FileSaveDialog Issue!

Recommended Posts

Brenda1

Hello guys, I have a problem with the FileSaveDialog, here is the thing: I want the user specify some palce to save a file my script is creating, but it doesn't create the file, I don't know what is missing, here is the code:

$saveIn= PathFile()

GetforwardList($path,$saveIn)


Func PathFile()
    
    $MyDocsFolder = "::{450D8FBA-AD25-11D0-98A8-0800361B1103}"

$filePath = FileSaveDialog( "Choose a name.", $MyDocsFolder, "Text File (*.csv)", 2,"FowardMail")


If @error Then
    MsgBox(4096,"","Save cancelled.")
Else
;MsgBox(4096,"","You chose " & $filePath)
    Return $filePath
EndIf

EndFunc



Func GetforwardList($path,$saveIn)
    
$strCategory = "person"
$field = "SamAccountName"
$strUserName = "*"
$objConnection = ObjCreate("ADODB.Connection")
$objConnection.Open ("Provider=ADsDSOObject;")
$objCommand = ObjCreate("ADODB.Command")
$objCommand.ActiveConnection = $objConnection
$objCommand.CommandText = "<GC://"& $path &">;(&(objectCategory=" & $strCategory & ")" & "("& $field & "=" & $strUserName & "));altRecipient,name,co,SamAccountName,distinguishedname,Company;Subtree"
$objRecordSet = $objCommand.Execute


$file = FileOpen($saveIn&".csv",2); here it supposed to create the file
If $file = -1 Then
  MsgBox(0, "Error", "The file can not be open.")
    Exit
EndIf
.
.
.
.

endfunc

help please, I don't see the error!! :)

Share this post


Link to post
Share on other sites
PsaltyDS

You haven't set the Global Catalog path in $path before calling GetForwardList(), so your AD query won't work.

Does the MsgBox that displays $filepath show the expected path in PathFile()?

Does the error MsgBox in GetForwardList() come up - or just nothing happens?

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
Brenda1

You haven't set the Global Catalog path in $path before calling GetForwardList(), so your AD query won't work.

Does the MsgBox that displays $filepath show the expected path in PathFile()?

Does the error MsgBox in GetForwardList() come up - or just nothing happens?

:)

Nop, no error message, nothing happens, and yes it shows me the expected path, the only thing I am not sure about, is the Global catalog note you are going, I don't understand what you are saying, I am sending the path to the function, properly, I guess... any advice?

Share this post


Link to post
Share on other sites
PsaltyDS

Nop, no error message, nothing happens, and yes it shows me the expected path, the only thing I am not sure about, is the Global catalog note you are going, I don't understand what you are saying, I am sending the path to the function, properly, I guess... any advice?

Well, the code you showed did not set $path.

You also didn't show anything writing to the file. You could put some more debug displays in like this:

$objRecordSet = $objCommand.Execute
MsgBox(32, "Debug", "Debug: Record set count = " & $objRecordSet.count)

$file = FileOpen($saveIn & ".csv", 2); 2 = overwrite
If $file = -1 Then
  MsgBox(16, "Error", "The file can not be opened.")
    Exit
Else
    MsgBox(32, "Debug", "Debug: Successfully opened file for write at: " & $saveIn)
EndIf

; What code down here writes to the file...?
FileWrite($file, "Debug: Record set count = " & $objRecordSet.count & @CRLF)

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
Brenda1

Well, the code you showed did not set $path.

You also didn't show anything writing to the file. You could put some more debug displays in like this:

$objRecordSet = $objCommand.Execute
MsgBox(32, "Debug", "Debug: Record set count = " & $objRecordSet.count)

$file = FileOpen($saveIn & ".csv", 2); 2 = overwrite
If $file = -1 Then
  MsgBox(16, "Error", "The file can not be opened.")
    Exit
Else
    MsgBox(32, "Debug", "Debug: Successfully opened file for write at: " & $saveIn)
EndIf

; What code down here writes to the file...?
FileWrite($file, "Debug: Record set count = " & $objRecordSet.count & @CRLF)

:)

I didn't put all the code, that's why you can not see, what the program is writting in the file, I already see the error, and you were right, I was sending nothing in "$Path" variable, but do you know why if I am using a Select function, I can not use the variables that are inside the select, in a diferent case?

for exemple:

Select

case $x=1
        $var=2

case $w=3
        if $var=2 then; Here $var doesn't take any value even if $x=1, is because I can not use the variables inside  other case?
           $y=4
           else 
             msgbox(0,"error","var is not equal to 2.")
endselect

Is just an example, for you to see my question. I am asking you this because that was the problem, I was thinking, I was sending a value in $path, like that, putting the value in a select inside another case.

Thanks for your note about $path variable, that solved me the problem. :)

Edited by Brenda1

Share this post


Link to post
Share on other sites
PsaltyDS

I didn't put all the code, that's why you can not see, what the program is writting in the file, I already see the error, and you were right, I was sending nothing in "$Path" variable, but do you know why if I am using a Select function, I can not use the variables that are inside the select, in a diferent case?

for exemple:

Select

case $x=1
        $var=2

case $w=3
        if $var=2 then; Here $var doesn't take any value even if $x=1, is because I can not use the variables inside  other case?
           $y=4
           else 
             msgbox(0,"error","var is not equal to 2.")
endselect

Is just an example, for you to see my question. I am asking you this because that was the problem, I was thinking, I was sending a value in $path, like that, putting the value in a select inside another case.

Thanks for your note about $path variable, that solved me the problem. :)

Select/Case stops looking at the first Case matched, so the other cases don't get checked at all. So once your case $x=1 is matched, it does $var=2, and then goes straight to EndSelect (same with Switch/Case/EndSwitch and If/ElseIf/EndIf).

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
GEOSoft

When playing with Switch and Select statements, more good reading is ContinueCase


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!"

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.