Jump to content
UBot Underground

Ini Save And Load Settings Framework


Recommended Posts

It's been a long time sense I shared something, so I thought I would take a bit to give back. Hear is my ini Save And Load Settings Framework, the Framework uses Aymens [Free] ini File Reader Hear http://www.ubotstudio.com/forum/index.php?/topic/15252-free-ini-file-reader-plugin-save-read-data-on-the-fly/ . Let me know if you have any questions. You can also use my free tool to build your ini containers Hear  http://www.ubotstudio.com/forum/index.php?/topic/16879-free-ini-quick-config-code-generator/

ui button("Save Settings") {
    set(#Settings Trigger, 1, "Global")
    Save And Load Settings(#Save And Load Settings)
}
ui button("Load Setting") {
    set(#Settings Trigger, 2, "Global")
    Save And Load Settings(#Save And Load Settings)
}
define Save And Load Settings(#Save And Load Settings) {
    if($comparison(#Selected Settings, "=", $nothing)) {
        then {
            alert("Please select a setting to save or load!")
            stop script
        }
    }
    if($comparison(#Selected Settings, "=", "Function One")) {
        then {
            Save Settings One(#Save Settings One)
        }
        else if($comparison(#Selected Settings, "=", "Function Tow")) {
            Save Settings Two(#Save Settings Two)
        }
        else if($comparison(#Selected Settings, "=", "Function Three")) {
            Save Settings Three(#Save Settings Three)
        }
        else if($comparison(#Selected Settings, "=", "Function Four")) {
            Save Settings Four(#Save Settings Four)
        }
        else if($comparison(#Selected Settings, "=", "Function Five")) {
            Save Settings Five(#Save Settings Five)
        }
    }
}
ui list box("Save/Load Settings", "Function One,Function Tow,Function Three,Function Four,Function Five", #Selected Settings)
define Save Settings One(#Save Settings One) {
    if($comparison(#Settings Trigger, "=", 1)) {
        then {
            save to file("{$special folder("Application")}\\settings\\Function One.ini", $nothing)
            comment("Place Save ini Container Below.")
            alert("Function One Settings Saved!")
        }
        else if($comparison(#Settings Trigger, "=", 2)) {
            set(#Settings Read, $read file("{$special folder("Application")}\\settings\\Function One.ini"), "Global")
            if($comparison(#Settings Read, "!=", $nothing)) {
                then {
                    comment("Place Load ini Container Below.")
                    set(#Settings Read, $nothing, "Global")
                    alert("Function One Bot Settings Loaded!")
                }
                else if($comparison(#Settings Read, "=", $nothing)) {
                    in new browser {
                        thread {
                            alert("You don\'t have any settings saved for this function.")
                        }
                    }
                }
            }
        }
    }
}
define Save Settings Two(#Save Settings Two) {
    if($comparison(#Settings Trigger, "=", 1)) {
        then {
            save to file("{$special folder("Application")}\\settings\\Function Two.ini", $nothing)
            comment("Place Save ini Container Below.")
            alert("Function Two Bot Settings Saved!")
        }
        else if($comparison(#Settings Trigger, "=", 2)) {
            set(#Settings Read, $read file("{$special folder("Application")}\\settings\\Function Two.ini"), "Global")
            if($comparison(#Settings Read, "!=", $nothing)) {
                then {
                    comment("Place Load ini Container Below.")
                    set(#Settings Read, $nothing, "Global")
                    alert("Function Two Bot Settings Loaded!")
                }
                else if($comparison(#Settings Read, "=", $nothing)) {
                    in new browser {
                        thread {
                            alert("You don\'t have any settings saved for this function.")
                        }
                    }
                }
            }
        }
    }
}
define Save Settings Three(#Save Settings Three) {
    if($comparison(#Settings Trigger, "=", 1)) {
        then {
            save to file("{$special folder("Application")}\\settings\\Function Three.ini", $nothing)
            comment("Place Save ini Container Below.")
            alert("Function Three Settings Saved!")
        }
        else if($comparison(#Settings Trigger, "=", 2)) {
            set(#Settings Read, $read file("{$special folder("Application")}\\settings\\Function Three.ini"), "Global")
            if($comparison(#Settings Read, "!=", $nothing)) {
                then {
                    comment("Place Load ini Container Below.")
                    set(#Settings Read, $nothing, "Global")
                    alert("Function Three Bot Settings Loaded!")
                }
                else if($comparison(#Settings Read, "=", $nothing)) {
                    in new browser {
                        thread {
                            alert("You don\'t have any settings saved for this function.")
                        }
                    }
                }
            }
        }
    }
}
define Save Settings Four(#Save Settings Four) {
    if($comparison(#Settings Trigger, "=", 1)) {
        then {
            save to file("{$special folder("Application")}\\settings\\Function Four.ini", $nothing)
            comment("Place Save ini Container Below.")
            alert("Function Four Bot Settings Saved!")
        }
        else if($comparison(#Settings Trigger, "=", 2)) {
            set(#Settings Read, $read file("{$special folder("Application")}\\settings\\Function Four.ini"), "Global")
            if($comparison(#Settings Read, "!=", $nothing)) {
                then {
                    comment("Place Load ini Container Below.")
                    set(#Settings Read, $nothing, "Global")
                    alert("Function Four Bot Settings Loaded!")
                }
                else if($comparison(#Settings Read, "=", $nothing)) {
                    in new browser {
                        thread {
                            alert("You don\'t have any settings saved for this function.")
                        }
                    }
                }
            }
        }
    }
}
define Save Settings Five(#Save Settings Five) {
    if($comparison(#Settings Trigger, "=", 1)) {
        then {
            save to file("{$special folder("Application")}\\settings\\Function Five.ini", $nothing)
            comment("Place Save ini Container Below.")
            alert("Function Five Settings Saved!")
        }
        else if($comparison(#Settings Trigger, "=", 2)) {
            set(#Settings Read, $read file("{$special folder("Application")}\\settings\\Function Five.ini"), "Global")
            if($comparison(#Settings Read, "!=", $nothing)) {
                then {
                    comment("Place Load ini Container Below.")
                    set(#Settings Read, $nothing, "Global")
                    alert("Function Five Settings Loaded!")
                }
                else if($comparison(#Settings Read, "=", $nothing)) {
                    in new browser {
                        thread {
                            alert("You don\'t have any settings saved for this function.")
                        }
                    }
                }
            }
        }
    }
}
  • Like 4
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...