Jump to content

Weird thing or just blind?


 Share

Recommended Posts

Hi guys,

I'm either going crazy or AutoIT is.. :D

Basically I need to get to the parent folder of @scriptdir, to do that, I used:

$parentFolder=StringLeft(@ScriptDir, StringInStr(@ScriptDir, "\", 0, -1)) 

So far, all good. When I use MsgBox to show $parentfolder, I'm indeed able to see the folder above @scriptdir. Now, I've added a subfolderfile to the string with:

$PPID_Bulk_Big_printers_csv_path=$parentFolder&'Printers\printers_PPID_Big.csv' 

And also here, all fine, MsgBox shows me the file location correctly.

Now, for some weird reason, $PPID_Bulk_Big_printers_csv_path changes again!

See the complete part of the script below:

; CSV to 2D array
    $parentFolder=StringLeft(@ScriptDir, StringInStr(@ScriptDir, "\", 0, -1)) ;Goes one folder up
    MsgBox(0,'',@ScriptDir&'----'&$parentFolder&'Printers\printers_PPID_Big.csv')
    $PPID_Bulk_Big_printers_csv_path=$parentFolder&'Printers\printers_PPID_Big.csv' ;CSV location

    Dim $PPID_Bulk_Big_printers

    $PPID_Bulk_Big_filereadtoarray_result = _FileReadToArray($PPID_Bulk_Big_printers_csv_path, $PPID_Bulk_Big_printers) ;$PPID_Bulk_Big_filereadtoarray_result will contain any error (if there's any) - $printers is an array which contains the list of printers
MsgBox(0,'',$PPID_Bulk_Big_printers_csv_path) ; Still shows correct path
    ;Check if there was any error with the _FileReadToArray
        If $PPID_Bulk_Big_filereadtoarray_result <> 0 Then ;If no error reading the file

;Do Something
            
        Else ;If there was an error reading the CSV file
MsgBox(0,'hhh',"msg="&$PPID_Bulk_Big_printers_csv_path)
            MsgBox(48,'Problem detected!','The file "'&$PPID_Bulk_Big_printers_csv_path&'" was not found. Software will exit!')
            Sleep (50)
            Exit

        EndIf

So what's happening here is, I'm getting into the ELSE part of the script, so there was an error with reading the file and I'm getting indeed the message box with "Problem detected!" but NOT the message box above?? Why?

Cheers :)

Edited by simy8891
Link to comment
Share on other sites

All, please disregard and close the topic.

I was just blind: there are more functions down below in the script with a similar .csv file name, so it was complaining about the other and not this function.

Basically it's a script I've made a few months ago that I'm not re-elaborating so it took me a while to figure out what passed in my mind such a long time ago.

Thanks

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

×
×
  • Create New...