Jump to content

merging duplicated data


Recommended Posts

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.

Link to comment
Share on other sites

@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 by FrancescoDiMuro

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

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 by Shark007
compared the new script with a backup for line count
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...