robinsiebler Posted June 7, 2012 Share Posted June 7, 2012 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 More sharing options...
robinsiebler Posted June 7, 2012 Author Share Posted June 7, 2012 (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 June 7, 2012 by robinsiebler Link to comment Share on other sites More sharing options...
robinsiebler Posted June 7, 2012 Author Share Posted June 7, 2012 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. Link to comment Share on other sites More sharing options...
czardas Posted June 7, 2012 Share Posted June 7, 2012 (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 June 7, 2012 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted June 7, 2012 Share Posted June 7, 2012 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 .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 Link to comment Share on other sites More sharing options...
robinsiebler Posted June 7, 2012 Author Share Posted June 7, 2012 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 More sharing options...
czardas Posted June 7, 2012 Share Posted June 7, 2012 (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 June 7, 2012 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted June 7, 2012 Share Posted June 7, 2012 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. .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 Link to comment Share on other sites More sharing options...
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