Jump to content

Help the brain dead newbie


Recommended Posts

I know there has to be a way to turn the below code into 1 function, but it's been a long day and I am not seeing it. Pointers, anyone?

For $item in x($sConf&'.Config.Branch')
    $Branch = $Branch & $item & "|"
Next

$Branch = StringTrimRight($Branch, 1)

For $item in x($sConf&'.Config.Type')
    $Type = $Type & $item & "|"
Next

$Type = StringTrimRight($Type, 1)

For $item in x($sConf&'.Config.Options')
    $Options = $Options & $item & "|"
Next

$Options = StringTrimRight($Options, 1)
Link to comment
Share on other sites

Well, after pounding my head against a wall for a while, I figured out a way to do it. It might not be the most elegant way, but it works. ;)

Local $BranchData, $TypeData, $OptionsData
Dim $foo[3] = ["Branch", "Type", "Options"]
Local $tempvar
For $item in $foo
    Assign("tempvar", $item)
    For $entry in  x($sConf&'.Config.'&$tempvar)
        Assign($tempvar, $entry)
        Select
            Case $tempvar = "Branch"
                $BranchData = $BranchData & $entry & "|"
            Case $tempvar = "Type"
                $TypeData = $TypeData & $entry & "|"
            Case $tempvar = "Options"
                $OptionsData = $OptionsData & $entry & "|"
        EndSelect
     Next
Next
Edited by robinsiebler
Link to comment
Share on other sites

Quick example assuming both variables are locals...

_FunctionXYZ($sConf, $Branch)
_FunctionXYZ($sConf, $Type)
_FunctionXYZ($sConf, $Options)

Func _FunctionXYZ($parameter1, $parameter2)
    For $item in x($parameter1 & '.Config.Options')
        $parameter2 = $parameter2 & $item & "|"
    Next

    $parameter2 = StringTrimRight($parameter2, 1)
EndFunc
Link to comment
Share on other sites

If you first add the AutoIt Code tags to your post and then paste the code between them afterwards, the formatting is not corrupted.

It is for me. I have tried manually typing in the code tags and I have clicked the AutoIT button. When I click the AutoIT button and paste the code in the the popup dialog, it looks correct. However, when I submit the code, the formatting is all f*'d up. And I am pasting directly from Scite.

Link to comment
Share on other sites

Here's how I usually do: don't use the AutoIt button, instead write the tags yourself, toggle editing mode and then paste the code between the tags.

Tabs are still turned to spaces for some bloody reason but you can use Tidy to fix that for you when you copy code from the forum.

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...