ndw Posted October 6, 2011 Posted October 6, 2011 My apologies if the terminology in the title is wrong, if you can better word it, i'll edit it so others can search for it easier. What i would like to do is have a script full of functions that do various things, i.e. click a certain position, drag a certain distance. Then i would like to have a textfile that listed these functions so when i read the textfile in, it executes them in order. So a textfile could read OpenExplorer Doubleclick(x,y) RightClickCopy And the program would read in "OpenExplorer" and run OpenExplorer(). Then read in Doubleclick(x,y) and run Doubleclick(x,y). I know thats clear as mud but hopefully you understand what i mean. Is this possible? Calling a function from a read in string/variable? My end vision for this is to create test scripts as textfiles that can be easily editted and created.
AdmiralAlkex Posted October 6, 2011 Posted October 6, 2011 The word actually is Call(), see helpfile .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
Moderators Melba23 Posted October 6, 2011 Moderators Posted October 6, 2011 ndw,My end vision for this is to create test scripts as textfiles that can be easily editted and createdAnd just how does this vision differ from an AutoIt script with the functions in a separate #include file? M23 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
ndw Posted October 6, 2011 Author Posted October 6, 2011 ndw, And just how does this vision differ from an AutoIt script with the functions in a separate #include file? M23 Sorry, badly wrote that. I meant to say i'll have an Auto IT script with loads of Functions in it, with text files that can be read in which cherry picks which to run. I was thinking about sticking all the functions in their own files but... i have no idea about the include stuff It might be ebtter in the long run to to that but, i'll leave that for another day.
ndw Posted October 6, 2011 Author Posted October 6, 2011 The word actually is Call(), see helpfile Such a simple answer, i feel like a newbie. Thank you for that, looked it up in the help and that should do me.
ndw Posted October 6, 2011 Author Posted October 6, 2011 The word actually is Call(), see helpfile I have this working now for my functions that don't require arguements, but for something that does require arguements, i guess i'm gonna have to do something clever? In the file, let's say i have a some text that says "Reposition($x,$y,20,20)" where $x and $y are integers already definied earlier in the script. Do i need some kind of method that will break down the string in to characters, and stop at "(" ")" and "," and start cutting up the string to an array? Currently using FileReadLine.
AdmiralAlkex Posted October 6, 2011 Posted October 6, 2011 Yes you would have to do some processing to get it in a format Call() accepts, as I'm sure you can see from the example in helpfile. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
ndw Posted October 6, 2011 Author Posted October 6, 2011 I've managed to work myself a mountain out of a mole hill on this one. I've written out some code to show what i'm trying to do. The issue i have is determining how many arguements there are. I have some Functions that don't require any parameters, and others that have a few. I don't know of a way to make it able to handle any number of parameters. Local $textfile, $i, $text, $array, $num1, $num2 $textfile = FileOpen("textfile.txt") $num1 = Random(0,10) $num2 = Random(0,10) For $i = 1 to _FileCountLines("textfile.txt") $text = FileReadLine($textfile,$i) ; Format of text in file "Addition;$num1;$num2;7", but some functions have no arguements $array = StringSplit($text, ";") ; This would call a function with no arguements ; Call($array[0]) ; But how would you call a function when you don't know how many arguements there are? Call ($array[0], $array[1]) ; $array[2] etc.. Next Func Addition ($a, $b, $c) Msgbox (0,"Number", $a+$b+$c) EndFunc I hope i've made this clear enough. I was stuck on the _FileCountLines for a while till i realised it was cause i was using the file handle when it can only deal with the path, which is a shame.
AdmiralAlkex Posted October 6, 2011 Posted October 6, 2011 I was stuck on the _FileCountLines for a while till i realised it was cause i was using the file handle when it can only deal with the path, which is a shame.You could always copy the function to your script and edit it to use a handle. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
ndw Posted October 6, 2011 Author Posted October 6, 2011 You could always copy the function to your script and edit it to use a handle.Oh ok, i thought there might be some issue with editting somebody else's work or something silly but i'll look in to the after, it's working just not exacting as i want it. More concerned about the Call function and how to tackle that
ndw Posted October 7, 2011 Author Posted October 7, 2011 Also, i've put this in to the wrong forum. I think this would be better suited being in the general help. If this could be moved, would be much appreciated.
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