MikeK6MKF Posted March 5, 2015 Author Share Posted March 5, 2015 Had a friend clue me in, so I get this: @@ Debug(61) : '"C:Program Files (x86)AdobeReader 11.0ReaderAcroRd32.exe" /A page="'& $page &'" "C:PredictionsUTC_80.pdf"' = "C:Program Files (x86)AdobeReader 11.0ReaderAcroRd32.exe" /A page="22.27" "C:PredictionsUTC_80.pdf" >Error code: 1 Link to comment Share on other sites More sharing options...
MikeK6MKF Posted March 5, 2015 Author Share Posted March 5, 2015 When I run with my original statement I get this: @@ Debug(61) : '"C:Program Files (x86)AdobeReader 11.0ReaderAcroRd32.exe" /A page="'& $page &'" "C:PredictionsUTC_80.pdf"' = "C:Program Files (x86)AdobeReader 11.0ReaderAcroRd32.exe" /A page="22.32" "C:PredictionsUTC_80.pdf" >Error code: 0 And when I run with my Run with variable statement: Run('" & $AcrobatPath & " /A "page=' & $page & '" "C:PredictionsUTC_80.pdf"') Wait a moment ... it Worked! Run('" & $AcrobatPath & " /A "page=' & $page & '" "C:PredictionsUTC_80.pdf"') now works, so this is my answer! Thank you so much for this. And now I know how to read STDOUT, too. Link to comment Share on other sites More sharing options...
Developers Jos Posted March 5, 2015 Developers Share Posted March 5, 2015 Page 22.27 sounds wrong ...right? So try converting $page to Integer with: $page = Int($Page) 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...
MikeK6MKF Posted March 5, 2015 Author Share Posted March 5, 2015 That cleaned up $page. I was premature in claiming victory, it seems. This still fails: Local $AcrobatEx = "C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe" ... Run(' & $AcrobatEx & /A "page=' & $page & '" "C:\Predictions\UTC_80.pdf"') Link to comment Share on other sites More sharing options...
TheSaint Posted March 6, 2015 Share Posted March 6, 2015 (edited) That cleaned up $page. I was premature in claiming victory, it seems. This still fails: Local $AcrobatEx = "C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe" ... Run(' & $AcrobatEx & /A "page=' & $page & '" "C:\Predictions\UTC_80.pdf"') That is wrong, you have embedded you first variable inside the quotes. It becomes just text when you do that. It should be outside like this. Run($AcrobatEx & ' /A "page=' & $page & '" "C:\Predictions\UTC_80.pdf"') Edited March 6, 2015 by TheSaint Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage) Link to comment Share on other sites More sharing options...
sdfaheemuddin Posted March 6, 2015 Share Posted March 6, 2015 Run($AcrobatPath & ' /A Page="' & $Page & '" ' & $PDFDir & 'UTC_80.pdf') Ensure space before /A and in '" ' Link to comment Share on other sites More sharing options...
zalomalo Posted March 6, 2015 Share Posted March 6, 2015 (edited) You are having troubles with symbols, i could give you some good points. If you declare Vars for paths and so, to make the code more readable, use it from the beginning and dont wait to work with static strings and later must test again, when you change them. Never use " (double-quotes) inside your code with strings, use ' (single-quotes), and double-quotes only inside your strings when needed, by example arguments for a executable, but if you know for sure the filepaths havent spaces you dont need it; it is needed just when the spaces makes imposible to know if is another argument (space-based) or space inside the argument. Allways follow the same rule/pattern you wish and use spaces to do readable, by example: $var &'string'& $var. Use a text editor than helps you, i use Notepad++ with dark background to work and Scite to check and test. The line: Run(' & $AcrobatEx & /A "page=' & $page & '" "C:\Predictions\UTC_80.pdf"') Has string than later you will change by a variable. Do it now, save time. Your vars have strings inside, dont do '$var', since $var='string' , so i could write: Local $pID=RunAs( 'username', 'Logondomain', 'mypass',1, @ScriptDir &'\SelSteamG.exe "arg1 arg2... argn"', @ScriptDir, @SW_HIDE) And your line: Run( $AcrobatExe & ' /A page='& $pagenumber &' '& $PDFDir &'\UTC_'& $pdfnumber &'.pdf' ) I put here some of my code so you can see its important begin right, or could be very confused: If Not StringIsSpace($LHArgs) Then $sEXEParams=(StringInStr($LHArgs,'"',2,2))?($sEXEParams&' '&StringStripWS($LHArgs,3)):($sEXEParams&' "'&StringStripWS($LHArgs,3)&'"') If Not( StringIsSpace($Args) Or StringInStr($Args,'"',2,2) ) Then $Exe=$Exe&' "'&StringStripWS($Args,3)&'"' $Switchs=' -accepteula '& StringStripWS($Switchs,7) Return(Run(@ScriptDir&'\'& $PSexeX & $Switchs &' -w "'& $Dir &'" -u domain -p pass '& $Exe,$Dir,Execute($fShowMode))) By other hand, if you have a long case sentence with same N lines inside every Case, may be you didnt designed well. Consider this comparation: ;------------------------ Select ; Option 1 Case $iMsg = $idM80 $utc = _GetUTC() $page = (($utc + 100) / 100 ) Run('Whatever') ;...N times Case $iMsg = $idM40 $utc = _GetUTC() $page = (($utc + 100) / 100 ) Run('Whatever') EndSelect ;------------------------ Switch $iMsg ; Option 2 Case $idM80 $var='AAA' ;...N times Case $idM40 $var='NNN' Case Else _ReportError('What are you doing?') Exit(-3) EndSwitch $utc = _GetUTC($var) $page= ( $utc+100 ) / 100 Run('Whatever') I hope this could help you a bit, now and future. Edited March 6, 2015 by zalomalo MikeK6MKF 1 My english shucks, i know it. Link to comment Share on other sites More sharing options...
Solution MikeK6MKF Posted March 6, 2015 Author Solution Share Posted March 6, 2015 (edited) I have been able to get this to work with the help of a more knowledgeable friend than me. So here is the code I have working now: Local $AcrobatPath = '"C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe" /A page=' Local $PDFDir = ' C:\Predictions\' ... Select Case $iMsg = $idM80 ; 80M button is clicked ; calculate page number from $utc value $utc = _GetUTC() $page = StringFormat("%02d", (($utc + 100) / 100 )) $strTest = ($AcrobatPath & $page & $PDFDir & 'UTC_80.pdf') Run($strTest) ... Thanks to all who hung in there with me as I struggled with this. Much appreciated. Edited March 10, 2015 by MikeK6MKF Link to comment Share on other sites More sharing options...
MikeK6MKF Posted March 6, 2015 Author Share Posted March 6, 2015 And thank you, Zalomalo, for these tips about Vars and single and double quotes. I have much to learn about AutoIt, but it's fun. zalomalo 1 Link to comment Share on other sites More sharing options...
zalomalo Posted March 6, 2015 Share Posted March 6, 2015 (edited) I would like to help even more. Dont just think about your code is working just now. Think about in one or more months may be doing other script you could take and recycle code done time ago. Sometimes happens you cant remember why you did something in someway and why it works. Because this i think is important having good habbits that may be arent important just now, but can save you time in future. Its not just about AutoIt but general programming. Autoit internal functions (allmost everyone) related to filepaths takes directories without final backslash, follow same rule. Have just the filepath without spaces before or after, so: $PDFDir = ' C:\Predictions\' I would define: $PDFDir = 'C:\Predictions' And add the neccesary when use the vars to concatenate, this way: $strTest = ( $AcrobatPath & $page &' '& $PDFDir & '\UTC_80.pdf' ) If you are doing recursive operation with documents than have all of them the same name format convenction, ¿could be usefull for you going futher in your tasks to have a var with the document number?. This gives you the chance, by example do the same task for several documents, even you can take a list of numbers and know how many you got: Local $sListDocNumbers='5,6,80,99,345,999' Local $arrayDocNumbers=StringSplit($sListDocNumbers,',') ; This allways gives a array and allways one component at least For $i=1 to $arrayDocNumbers[0] ; $arrayDocNumbers[0] <-- is 6 ; (Doing something with $arrayDocNumbers[$i] Next So i could write the line: $strTest = ( $AcrobatPath & $page &' '& $PDFDir & '\UTC_'& $arrayDocNumbers[$NN] &'.pdf' ) - Also, you dont need "doublequote" a filepath that is is going to be used by AutoIt (having spaces inside a $var its not a trouble), you need do it when the string is going to used by "Others" and you dont know how them will takes spaces and arguments in a comandline by example: Local $AcrobatPath = '"C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe" /A page=' can be with no problem, since its your Autoit function who must find the right path to execute, and run Acrobat. This is by the same reason you dont do $KK='"'&@ScriptDir&'"' nor even worse $KK='@ScriptDir' , so: Local $AcrobatPath = 'C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe /A page=' but you need, by the case, double quote the string you are passing to another application as argument, because you dont know what/how is going to do with it, like i put in my other post. My english shucks, i know it. Cheers. Edited March 6, 2015 by zalomalo My english shucks, i know it. Link to comment Share on other sites More sharing options...
MikeK6MKF Posted March 7, 2015 Author Share Posted March 7, 2015 Thanks, Zalomalo. All good advice. Your English is 100% better than any other language I'd try to speak. zalomalo 1 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