Sign in to follow this  
Followers 0
youknowwho4eva

Replace Key in ini

2 posts in this topic

Another simple little script I came up with because when I had created my .ini I didn't like the Key's that came out. When I used the replace in notepad, it would freeze because the ini is so big. so I wrote this up and fixed all 86 key's in one swipe for over 300 sections. Figured it might be helpful for someone that needs to do a mass key replace as I did.

$section = IniReadSectionNames("your file here")

For $r = 1 to $section[0] step 1
    $was = IniReadSection("your file here",$section[$r])
For $n = 1 to $was[0][0] Step 1
    

If $n = 1 Then $is = "PART #"
If $n = 2 Then $is = "PART NAME"
If $n = 3 Then $is = "RESIN INV. #"
If $n = 4 Then $is = "NUMBER OF CAVITIES"
If $n = 5 Then $is = "PROJECTED AREA (in.)"
If $n = 6 Then $is = "PART WEIGHT (oz.)"
If $n = 7 Then $is = "MAX TONNAGE"
If $n = 8 Then $is = "PREFERED PRESS"
If $n = 9 Then $is = "OTHER PRESSES"
If $n = 10 Then $is = "MOLD WEIGHT (lbs.)"
If $n = 11 Then $is = "SPRUE BUSHING DIA."
If $n = 12 Then $is = "SPECIAL INFORMATION"
If $n = 13 Then $is = "MOLD LENGTH"
If $n = 14 Then $is = "MOLD WIDTH"
If $n = 15 Then $is = "STACK HEIGHT"
If $n = 16 Then $is = "WATER STATIONARY"
If $n = 17 Then $is = "WATER MOVING"
If $n = 18 Then $is = "SPRUE HEATER"
If $n = 19 Then $is = "TEMPERATURE CONTROLLER TYPE"
If $n = 20 Then $is = "SPRUE SETTING"
If $n = 21 Then $is = "MANIFOLD 1 SETTING"
If $n = 22 Then $is = "MANIFOLD 1 MODE"
If $n = 23 Then $is = "MANIFOLD 2 SETTING"
If $n = 24 Then $is = "MANIFOLD 2 MODE"
If $n = 25 Then $is = "ZONE 1 SETTING"
If $n = 26 Then $is = "ZONE 1 MODE"
If $n = 27 Then $is = "ZONE 2 SETTING"
If $n = 28 Then $is = "ZONE 2 MODE"
If $n = 29 Then $is = "ZONE 3 SETTING"
If $n = 30 Then $is = "ZONE 3 MODE"
If $n = 31 Then $is = "ZONE 4 SETTING"
If $n = 32 Then $is = "ZONE 4 MODE"
If $n = 33 Then $is = "ZONE 5 SETTING"
If $n = 34 Then $is = "ZONE 5 MODE"
If $n = 35 Then $is = "ZONE 6 SETTING"
If $n = 36 Then $is = "ZONE 6 MODE"
If $n = 37 Then $is = "ZONE 7 SETTING"
If $n = 38 Then $is = "ZONE 7 MODE"
If $n = 39 Then $is = "ZONE 8 SETTING"
If $n = 40 Then $is = "ZONE 8 MODE"
If $n = 41 Then $is = "NOZZLE TIP ORIFICE"
If $n = 42 Then $is = "NOZZLE LENGTH (BODY)"
If $n = 43 Then $is = "REVERSE TAPER?"
If $n = 44 Then $is = "HEATER BAND SIZE(BODY)"
If $n = 45 Then $is = "QUANTITY OF NOZZLE BANDS"
If $n = 46 Then $is = "MOLD DIMENSIONS"
If $n = 47 Then $is = "ZONE 9 SETTING"
If $n = 48 Then $is = "ZONE 9 MODE"
If $n = 49 Then $is = "ZONE 10 SETTING"
If $n = 50 Then $is = "ZONE 10 MODE"
If $n = 51 Then $is = "ZONE 11 SETTING"
If $n = 52 Then $is = "ZONE 12 MODE"
If $n = 53 Then $is = "ZONE 12  SETTING"
If $n = 54 Then $is = "ZONE 11  MODE"
If $n = 55 Then $is = "STATIONARY CORE SELECT SEQ."
If $n = 56 Then $is = "STATIONARY CORE POS."
If $n = 57 Then $is = "STATIONARY CORE SPEED"
If $n = 58 Then $is = "STATIONARY CORE PRESSURE"
If $n = 59 Then $is = "STATIONARY CORE SELECT SEQ"
If $n = 60 Then $is = "MOVEING CORE POS."
If $n = 61 Then $is = "MOVEING CORE SPEED"
If $n = 62 Then $is = "MOVEING CORE PRESSURE"
If $n = 63 Then $is = "TIP LENGTH"
If $n = 64 Then $is = "TIP HEATER QUANTITY"
If $n = 65 Then $is = "TIP HEATER BAND WATTAGE"
If $n = 66 Then $is = "KO STROKE MOVING"
If $n = 67 Then $is = "KO MOVING POS/FLOATING"
If $n = 68 Then $is = "KO STROKE STATIONARY"
If $n = 69 Then $is = "KO STATIONARY POS/FLOATING"
If $n = 70 Then $is = "FRONT,TOP,STATIONARY,HALF"
If $n = 71 Then $is = "BACK BOTTOM MOVING HALF"
If $n = 72 Then $is = "REMARKS"
If $n = 73 Then $is = "NOZZLE BAND WATTAGE"
If $n = 74 Then $is = "FILTER DISC"
If $n = 75 Then $is = "NOZZLE HEATER BAND SIZE"
If $n = 76 Then $is = "ADDITIONAL REMARKS"
If $n = 77 Then $is = "DATE"
If $n = 78 Then $is = "REST PREVENTATIVE"
If $n = 79 Then $is = "STD. CYCLE"
If $n = 80 Then $is = "RUNNER SYSTEM"
If $n = 81 Then $is = "CUSTOMER"
If $n = 82 Then $is = "MOLD LIST REMARKS"
If $n = 83 Then $is = "P/N"
If $n = 84 Then $is = "DATE PIN"
If $n = 85 Then $is = "WATER STATIONARY LINKED"
If $n = 86 Then $is = "WATER MOVING LINKED"
    If IniRead("your file here",$section[$r],$was[$n][0],"") <> "" Then
IniWrite("your file here",$section[$r],$is,$was[$n][1])
Else
    IniWrite("your file here",$section[$r],$is,"")
EndIf

IniDelete("your file here",$section[$r],$was[$n][0])

Next
Next


Giggity

Share this post


Link to post
Share on other sites



I supose this one the same, but shorter :)

$sIniFile = "Config.ini"
$aSection = IniReadSectionNames($sIniFile)

$aKeyNames_Arr = StringSplit("PART #|PART NAME|RESIN INV. #|NUMBER OF CAVITIES|PROJECTED AREA (in.)|PART WEIGHT (oz.)|MAX TONNAGE|PREFERED PRESS|OTHER PRESSES|MOLD WEIGHT (lbs.)|SPRUE BUSHING DIA.|SPECIAL INFORMATION|MOLD LENGTH|MOLD WIDTH|STACK HEIGHT|WATER STATIONARY|WATER MOVING|SPRUE HEATER|TEMPERATURE CONTROLLER TYPE|SPRUE SETTING|MANIFOLD 1 SETTING|MANIFOLD 1 MODE|MANIFOLD 2 SETTING|MANIFOLD 2 MODE|ZONE 1 SETTING|ZONE 1 MODE|ZONE 2 SETTING|ZONE 2 MODE|ZONE 3 SETTING|ZONE 3 MODE|ZONE 4 SETTING|ZONE 4 MODE|ZONE 5 SETTING|ZONE 5 MODE|ZONE 6 SETTING|ZONE 6 MODE|ZONE 7 SETTING|ZONE 7 MODE|ZONE 8 SETTING|ZONE 8 MODE|NOZZLE TIP ORIFICE|NOZZLE LENGTH (BODY)|REVERSE TAPER?|HEATER BAND SIZE(BODY)|QUANTITY OF NOZZLE BANDS|MOLD DIMENSIONS|ZONE 9 SETTING|ZONE 9 MODE|ZONE 10 SETTING|ZONE 10 MODE|ZONE 11 SETTING|ZONE 12 MODE|ZONE 12  SETTING|ZONE 11  MODE|STATIONARY CORE SELECT SEQ.|STATIONARY CORE POS.|STATIONARY CORE SPEED|STATIONARY CORE PRESSURE|STATIONARY CORE SELECT SEQ|MOVEING CORE POS.|MOVEING CORE SPEED|MOVEING CORE PRESSURE|TIP LENGTH|TIP HEATER QUANTITY|TIP HEATER BAND WATTAGE|KO STROKE MOVING|KO MOVING POS/FLOATING|KO STROKE STATIONARY|KO STATIONARY POS/FLOATING|FRONT,TOP,STATIONARY,HALF|BACK BOTTOM MOVING HALF|REMARKS|NOZZLE BAND WATTAGE|FILTER DISC|NOZZLE HEATER BAND SIZE|ADDITIONAL REMARKS|DATE|REST PREVENTATIVE|STD. CYCLE|RUNNER SYSTEM|CUSTOMER|MOLD LIST REMARKS|P/N|DATE PIN|WATER STATIONARY LINKED|WATER MOVING LINKED", "|")

For $r = 1 To $aSection[0]
    $aKeys_Values = IniReadSection($sIniFile, $aSection[$r])
    
    For $n = 1 To $aKeys_Values[0][0]
        $sKeyName = $aKeyNames_Arr[$n]
        
        If IniRead($sIniFile, $aSection[$r], $aKeys_Values[$n][0], "") <> "" Then
            IniWrite($sIniFile, $aSection[$r], $sKeyName, $aKeys_Values[$n][1])
        Else
            IniWrite($sIniFile, $aSection[$r], $sKeyName, "")
        EndIf
        
        IniDelete($sIniFile, $aSection[$r], $aKeys_Values[$n][0])
    Next
Next

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

AutoIt is simple, subtle, elegant. © AutoIt Team

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