Shark007 Posted March 18, 2021 Posted March 18, 2021 Currently, I have 4 different functions (list of 36 names) that use the same data. The portion of the lists in parenthesis is identical to all 4 lists other than the function calls. This layout works fine for me but it also bothers me that I have all this duplicated data. Func unlocker() ; this is what I call from the gui unlock("brenda") unlock("jim") unlock("frank") unlock("karen") unlock("steve") Func unlock() ; is called by the above function and performs tasks on each individual name consecutively Func kinder() ; this is what I call from the gui kind("brenda") kind("jim") kind("frank") kind("karen") kind("steve") Func kind() ; is called by the above function and performs different tasks I've been trying to merge the 4 lists into one and and have different function calls as required. Any suggestion would be greatly appreciated.
FrancescoDiMuro Posted March 18, 2021 Posted March 18, 2021 (edited) @Shark007 Use an array to store the names, and use a "global" function to call all the other functions in a loop (untested): ; Call the function once General() Func General() Local $arrNames[] = ["Brenda", "Jim", "Frank", "Karen", "Steve"], _ $strName ; Iterate through the names For $strName in $arrNames ; Calls the functions here unlock($strName) kind($strName) Next EndFunc Edited March 19, 2021 by FrancescoDiMuro Shark007 1 Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
Shark007 Posted March 19, 2021 Author Posted March 19, 2021 (edited) Thank you. I was able to make your solution work. I reduced my script by 140 210 lines of code with your assistance. edit: compared the new script with a backup for a better line count Edited March 19, 2021 by Shark007 compared the new script with a backup for line count
FrancescoDiMuro Posted March 19, 2021 Posted March 19, 2021 @Shark007 Glad I could help Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
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