mr_synapse Posted April 8, 2016 Share Posted April 8, 2016 I am trying to edit a script that I found, and I am not having any luck getting it to compile/run. Here is the script: #include <FileConstants.au3> #include <MsgBoxConstants.au3> $file_src = FileOpenDialog ( “Choose a CSV file with host objects”, @ScriptDir, “Comma delimeted files (*.csv)” ) $source = FileOpen($file_src) $dest = FileOpen(@ScriptDir & “\cli-commands.txt”, $FO_OVERWRITE ) ; file format <service name>,<service protocol>,<service port(s)> While 1 $line = FileReadLine($source) If @error Then ExitLoop $split_line = StringSplit($line, “,”) $hName = $split_line[1] $hAddr = $split_line[2] $hDesc = $split_line[3] FileWriteLine($dest, ‘set service ‘ & ‘”‘ & $hName & ‘” protocol “‘ & $hAddr & ‘” port ‘ & $hDesc) WEnd FileClose($file_src) FileClose($dest) I get an error at line 3 (FileOpenDialog line). I have tried what little I can find online, but I don't know where to proceed from here. The script should take values from a .csv file and creat text lines with those values in a particular format. The script looks okay to me... help! Thank you!!! Link to comment Share on other sites More sharing options...
Developers Jos Posted April 8, 2016 Developers Share Posted April 8, 2016 You have used the wrong characters for your string quotations, both the double and single quotes. #include <FileConstants.au3> #include <MsgBoxConstants.au3> $file_src = FileOpenDialog("Choose a CSV file with host objects", @ScriptDir, "Comma delimeted files (*.csv)" ) $source = FileOpen($file_src) $dest = FileOpen(@ScriptDir &"\cli-commands.txt", $FO_OVERWRITE ) ; file format <service name>,<service protocol>,<service port(s)> While 1 $line = FileReadLine($source) If @error Then ExitLoop $split_line = StringSplit($line,",") $hName = $split_line[1] $hAddr = $split_line[2] $hDesc = $split_line[3] FileWriteLine($dest, 'set service ' & '"' & $hName & '" protocol"' & $hAddr & '" port ' & $hDesc) WEnd FileClose($file_src) FileClose($dest) Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
alien4u Posted April 8, 2016 Share Posted April 8, 2016 (edited) @Jos answare is the correct one, mine was wrong, my eyes just fail me. Kind Regards Alien. Edited April 8, 2016 by alien4u Wrong Answare... Link to comment Share on other sites More sharing options...
AutoBert Posted April 8, 2016 Share Posted April 8, 2016 @Alien4u: the original line is correct, yours must throw error. Read in helpfile about missing 2. param $delimiter. The fields are comma separated so it's correct. Link to comment Share on other sites More sharing options...
alien4u Posted April 8, 2016 Share Posted April 8, 2016 1 hour ago, AutoBert said: @Alien4u: the original line is correct, yours must throw error. Read in helpfile about missing 2. param $delimiter. The fields are comma separated so it's correct. You are right read my previous post, you probably was writing this when I was editing my post. Link to comment Share on other sites More sharing options...
mr_synapse Posted April 8, 2016 Author Share Posted April 8, 2016 @Jos - I must apologize, but I don't know exactly what you mean. Is there somewhere where I can go to read about how to do this correctly? Thank you very much, I appreciate your time/help. Link to comment Share on other sites More sharing options...
Developers Jos Posted April 8, 2016 Developers Share Posted April 8, 2016 Just use my posted code which is corrected. One example: Your code: FileOpenDialog ( “Choose My code: FileOpenDialog( "Choose Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
MagnumXL Posted April 9, 2016 Share Posted April 9, 2016 This often happens if code is copied and pasted from Word or a similar program. It automatically changes double and single quotes to those damned opening and closing quotes that are not the same character at all. Whoever that that was a good idea was.. well... wrong. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now