Atticus Posted June 16, 2008 Share Posted June 16, 2008 Hello everybody, I have a problem. I used a code find on this forum but I don't know how to explain it. Can someone explain me this code line by line please. Global $sFilePath = "\\Server\disqueCD\Commun XP CD\2008\CLIENTS\CREANCES CLTS EN COURS.xls" $sFilePath = FileGetShortName($sFilePath) Global $oExcel = _ExcelBookOpen($sFilePath) Global $avData = _ExcelReadArray($oExcel, 1, 1, 5000, 1, 1) Global $iLastUsed = 0, $iNextRow = 0 For $n = UBound($avData) - 1 To 1 Step -1 If StringStripWS($avData[$n], 8) <> "" Then $iLastUsed = $n ExitLoop EndIf Next If $iLastUsed Then $iNextRow = $iLastUsed + 1 EndIf I thank you by advance Link to comment Share on other sites More sharing options...
rudi Posted June 16, 2008 Share Posted June 16, 2008 (edited) Hello everybody, I have a problem. I used a code find on this forum but I don't know how to explain it. Can someone explain me this code line by line please.Well, I'm not going to explain every line, but I'll give you some hints where do readup all the stuff: Look at Autoit's help file: Global ... FileGetShortName() For $n = 20 To 1 Step -1 Next UBound() StringStripWS() ExitLoop If ... Then ElseIf Else EndIf For these have a look at ExcelCOM_UDF.AU3 _ExcelBookOpen() _ExcelReadArray() Regards, Rudi. Edited June 16, 2008 by rudi Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
Atticus Posted June 18, 2008 Author Share Posted June 18, 2008 Thanks but I still don't understand this code, can someone please explain me. I need to understand that code. Please. thanks Link to comment Share on other sites More sharing options...
Kerros Posted June 18, 2008 Share Posted June 18, 2008 Lets try this a different way. After reviewing the topics that Rudi suggested... What don't you understand? Kerros===============================================================How to learn scripting: Figure out enough to be dangerous, then ask for assistance. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted June 18, 2008 Moderators Share Posted June 18, 2008 Thanks but I still don't understand this code, can someone please explain me. I need to understand that code. Please. thanksYou shouldn't need more explanation than this, if you do, then you shouldn't be using the udf(s) in question.; Server file path Global $sFilePath = "\\Server\disqueCD\Commun XP CD\2008\CLIENTS\CREANCES CLTS EN COURS.xls" ; Short name to server file path $sFilePath = FileGetShortName($sFilePath) ; Read the Excel.au3 udf for specifics on these two functions on what each parameter means ; Open the above xls file in excel Global $oExcel = _ExcelBookOpen($sFilePath) ; Read the data into an array (again, read the excel udf to understand what the parameters are Global $avData = _ExcelReadArray($oExcel, 1, 1, 5000, 1, 1) ; Global vars to distinguish cells used and what row you are currently on Global $iLastUsed = 0, $iNextRow = 0 ; For/Next loop going backwards from Max index to 1 For $n = UBound($avData) - 1 To 1 Step -1 ; Strip all the whit spaces from the array element, if it actually has a value, proceed If StringStripWS($avData[$n], 8) <> "" Then $iLastUsed = $n ExitLoop EndIf Next ; If something was actually found in the stripped array elements, pad it by one, and add it to the row variable If $iLastUsed Then $iNextRow = $iLastUsed + 1 EndIf 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 More sharing options...
Atticus Posted June 18, 2008 Author Share Posted June 18, 2008 Thanks a lot or your response. I have almost understand. but I still don't understand this line For $n = UBound($avData) - 1 To 1 Step -1 what is -1 to 1 Step -1 Thanks Link to comment Share on other sites More sharing options...
DaRam Posted June 18, 2008 Share Posted June 18, 2008 Thanks a lot or your response. I have almost understand. but I still don't understand this line For $n = UBound($avData) - 1 To 1 Step -1 what is -1 to 1 Step -1 ThanksUBound($avData) Is the Upper Bound (Max # of items) in the Array. -1 ; You need to Discount it by 1 since the elements start from Zero. The Loop starts from the last element of the Array and works it way backward to the first element, hence the directive to Step -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