justt Posted December 21, 2010 Share Posted December 21, 2010 Question 1 Say I have a function (N1) that within it uses a command that requires 3 inputs (X,Y,Z) Now what I want is to be able to use something (N2) to get X,Y and automatically place it into N1 So I could type something along the lines of N2 (AB,CD) N2 (GE,SG) N2 (WD,XD) which would then run function N1 three times, filling in the X and Y variables into N1 automatically. Hopefully that makes sense. Question 2 This isn't really important but I'm curious so I'll ask. Say someone is able to help me figure out Question 1 and I really like how N2 works and want to use it often. How could I make N2 (and I guess by extension N1) available for use at all times, even if I start another script, besides rewriting the code manually for each new script. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 21, 2010 Moderators Share Posted December 21, 2010 justt,Welcome to the AutoIt forum. Second question first. You save the code you want to reuse as a file and then use the #include directive to add it to your new script. This inserts the contents of that file into the new script at the point of the directive when the script is run or compiled. You can then call functions in that file as if they were in the new script - although of course you cannot actually see them. More details are in the Help file under "#include"Now to the first question. Just use another function as you suggested in your pseudo-code:; Determine the 3 parameters using function _N2 $iFirst = _N2(2, 2) ; should return 4 $iSecond = _N2(2, 3) ; should return 6 $iThird = _N2(4, 5) ; should return 20 ; Pass them to function _N1 $iResult = _N1($iFirst, $iSecond, $iThird) ; Should return 30 MsgBox(0, "First Result", $iResult) ; And so should this where we determine the parameter values directly $iResult = _N1(_N2(2, 2), _N2(2, 3), _N2(4, 5)) MsgBox(0, "Second Result", $iResult) ; Functions ; This function adds the 3 parameters Func _N1($vA, $vB, $vC) Return ($vA + $vB + $vC) EndFunc ; This function multiplies the 2 parameters Func _N2($vA, $vB) Return ($vA * $vB) EndFuncPlease ask if you have any questions on the code. M23P.S. Have you read the tutorials that that you can find here and here - they will help you get over the first few bumps in the road. Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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