Jump to content

Problem with script conversion


williamk
 Share

Recommended Posts

I have a fairly simple script. I can compile it and run it on my computer just fine. Two problems though. If I move the executable to any other directory than the one I compiled it to it will partially run and not exit. If I move it to another computer it runs but does nothing. All the files and directories referenced in my File statements are have been copied to the computer I am trying to run it from. Could this be a problem with my #includefiles Any ideas?

#include <file.au3>
#include <array.au3>
DIM $extract
$dirpath = "C:\Data_Track_Conversion\input\" 
$outdir = "C:Data_Track_Conversion\output\"
$empaddfn = "mast256.csv"
$inf = $dirpath & $empaddfn
MsgBox (1,"AS400 Generation","Please generate the employee export file on the AS400.  Click OK when this is done")
shellExecuteWait ("C:\Data_Track_Conversion\apps\AS400_emp_export.dtf")
If Not _FileReadToArray($inf,$extract) Then 
   MsgBox(4096,"Error", " Error reading log to Array     error:" & @error)
   Exit
  EndIf
  FileDelete ("C:\Data_Track_Conversion\input\*.*")
  FileDelete ("C:\Data_Track_Conversion\output\*.*")
  FileDelete ("C:\Data_Track_Conversion\merge_files\*.*")
        For $x = 1 to $extract[0] -1
        $array = StringSplit($extract[$x], "|") ; split the current line into $array using "|" as delimeter
        $array[2] = stringstripWS ($array[2],2)
        $array[3] = stringstripWS ($array[3],2)
        $array[4] = stringstripWS ($array[4],3)
        $array[5] = stringstripWS ($array[5],1)
            if $array[7] <> "" or $array[7] <> " " Then
                if $array[4] = "" Then
                  $outf = Fileopen ($outdir & $array[7] & "empadd.csv",1)               
                  FileWrite($outf, $array[1] & ";" & $array[2] & ", " & $array[3] & ";" & $array[5] & ";" & $array[6] & ";" & $array[7] & @CRLF)
                  ;FileClose ($outf)
                Else
                  $outf = Fileopen ($outdir & $array[7] & "empadd.csv",1)
                  FileWrite($outf, $array[1] & ";" & $array[2] & ", " & $array[3] & " " & $array[4] & ";" & $array[5] & ";" & $array[6] & ";" & $array[7] & @CRLF)
                  ;FileClose ($outf)
                Endif 
                FileClose ($outf)   
            Endif
        Next
FileClose ($inf)
$rnchArray = _ArrayCreate("RS", "SL", "OT", "CR", "JW", "MT", "PS", "PT")
For $cnt = 1 to 7
FileDelete ("C:\Data_Track_Conversion\output\temp.csv")
If FileExists("C:\Data_Track_Conversion\output\ empadd.csv") Then
    filemove ("C:\Data_Track_Conversion\output\ empadd.csv", "C:\Data_Track_Conversion\no_ranch.txt")
Endif
 filemove ("C:\Data_Track_Conversion\output\"& $rnchArray[$cnt] & "empadd.csv", "C:\Data_Track_Conversion\output\temp.csv")
 $i = 0
 While $i = 0
     If FileExists("C:\Data_Track_Conversion\output\temp.csv") Then
     sleep (1000)
    runwait ("C:\Data_Track_Conversion\apps\EmpImport.exe", "C:\Data_Track_Conversion\apps")
     $i = 1
     Endif
Wend
 filemove ("C:\Data_Track_Conversion\merge_files\empfile.mrg", "C:\Data_Track_Conversion\merge_files\" & $rnchArray[$cnt] & "empadd.mrg")
Next
Link to comment
Share on other sites

  • Moderators

Could it have anything to do with you hard coding the directories (Not everyone's main drive is "C", and I'm sure not everyone has C:\Data_Track_Conversion\output\temp.csv, therefore $i never will = 0 to exit.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Could it have anything to do with you hard coding the directories (Not everyone's main drive is "C", and I'm sure not everyone has C:\Data_Track_Conversion\output\temp.csv, therefore $i never will = 0 to exit.

Well, I can see where that should be changed. However, like I said I have checked numerous times to make sure all the files, directories, programs, etc are replicated exactly. Also, this does not explain why the program runs when in script form but not in executable form when in a different directory other than the directory in was compiled to. I compiled it to C:\. If I move it to any other diretory is hangs. I put a msg statement in my while loop and it doesn't pop up so I know that's not the issue.

Link to comment
Share on other sites

Well, I can see where that should be changed. However, like I said I have checked numerous times to make sure all the files, directories, programs, etc are replicated exactly. Also, this does not explain why the program runs when in script form but not in executable form when in a different directory other than the directory in was compiled to. I compiled it to C:\. If I move it to any other diretory is hangs. I put a msg statement in my while loop and it doesn't pop up so I know that's not the issue.

Hi

There is a syntax error here;

$outdir = "C:Data_Track_Conversion\output\"

But if that is not the answer, post a small sample of the csv file and we can try to debug with you...

Or put in some "ArrayDisplay" and consolewrite lines yourself to see where you are not getting what you expected.

Best, randall

Link to comment
Share on other sites

Hi

There is a syntax error here;

$outdir = "C:Data_Track_Conversion\output\"

But if that is not the answer, post a small sample of the csv file and we can try to debug with you...

Or put in some "ArrayDisplay" and consolewrite lines yourself to see where you are not getting what you expected.

Best, randall

Well, the syntax error did help on another machine. What I discovered too was that the only other location the program will not run correctly from is a users desktop. I'm guessing that is some kind of windows xp security thing. Anyway, problem solved. Thanks all.
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...