Sign in to follow this  
Followers 0
robinsiebler

Help the brain dead newbie

8 posts in this topic

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)

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

BTW, what's up with the crappy formatting for AutoIt code? It didn't properly indent half of it and I had to do it manually. ;)

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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

Edit

(generally)

Edited by czardas

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Don't type or paste the code into the popup window. Instead of that, adding it directly to the post itself works for me.

Edited by czardas

Share this post


Link to post
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.

Share this post


Link to post
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
Sign in to follow this  
Followers 0