It's very usefull as a developper to use .ini file to store settings of apps or MortScript scripts.
Unfortunately, you may have so many complicated settings (check IPTWeather for instance ), that you or newbies would like to be able to edit those settings without having to open the .ini configuration file.
That's why I've created the iniEditor.mscr script to get a friendly menu out of an .ini file:
This is more a proof of concept, and I would really like some developper can port it to a real .exe app to have a great layout as in the S2U2 settings for instance!
It can be used for any app or MortScript script that uses a .ini configuration file.
In the attachment, checkout the iniEditor.mscr which needs two parameters: the .ini file to edit, and your application name.
I've attached:
- the 'iniEditor.mscr' script which is the generic .ini file parser and configurator.
- the 'sample.ini' file to be edited.
- the 'sample.ini.desc' file that is the description file so you can remove all the comments in the 'sample.ini' file but still have them in the iniEditor menus to improve speed performance of your apps reading the 'sample.ini' file! All values in the 'sample.ini.desc' are the default values that are proposed if you cancel your changes for a field.
- the 'sampleConfig.mscr' script which calls the 'iniEditor.mscr' script with the right arguments.
- the 'calledScript.mscr' script which is called for one of the settings.
For the moment, you can set four types for the different settings:
- list: the setting is in a choice list defined in the .ini file;
- int: the setting is an integer;
- callscript: the setting is set using a MortScript script defined in the .ini file;
- fullfilepath: the setting is the full path of a file, to be set with a specific selection dialog box;
- path: the setting is a path, to be set with a specific selection dialog box;
- default: the setting is any entered string.
You set the type of a setting in the .ini.desc file by adding a comment just after the settings, like that:
You can also add some comments to be displayed for the user, by adding comments (on several lines if you want), like that:
And that gives you that:
Sometimes, there are so many things to say on a setting, that you don't want to or can't display all the comments about a setting in the menus of iniEditor.mscr.
Then, just added two semicolons at the beginning of the first "comment" line (after the "type" line"), like that:
And that gives you that:
If you set a parameter of type int, the user will be able to enter only an integer value:
If you set a parameter of type fullfilepath, you get this:
If you set a parameter of type path, you get this:
Feel free to use or modify my iniEditor.mscr, and if someone could make a real .exe app out of it, that would be great!
Unfortunately, you may have so many complicated settings (check IPTWeather for instance ), that you or newbies would like to be able to edit those settings without having to open the .ini configuration file.
That's why I've created the iniEditor.mscr script to get a friendly menu out of an .ini file:
This is more a proof of concept, and I would really like some developper can port it to a real .exe app to have a great layout as in the S2U2 settings for instance!
It can be used for any app or MortScript script that uses a .ini configuration file.
In the attachment, checkout the iniEditor.mscr which needs two parameters: the .ini file to edit, and your application name.
I've attached:
- the 'iniEditor.mscr' script which is the generic .ini file parser and configurator.
- the 'sample.ini' file to be edited.
- the 'sample.ini.desc' file that is the description file so you can remove all the comments in the 'sample.ini' file but still have them in the iniEditor menus to improve speed performance of your apps reading the 'sample.ini' file! All values in the 'sample.ini.desc' are the default values that are proposed if you cancel your changes for a field.
- the 'sampleConfig.mscr' script which calls the 'iniEditor.mscr' script with the right arguments.
- the 'calledScript.mscr' script which is called for one of the settings.
For the moment, you can set four types for the different settings:
- list: the setting is in a choice list defined in the .ini file;
- int: the setting is an integer;
- callscript: the setting is set using a MortScript script defined in the .ini file;
- fullfilepath: the setting is the full path of a file, to be set with a specific selection dialog box;
- path: the setting is a path, to be set with a specific selection dialog box;
- default: the setting is any entered string.
You set the type of a setting in the .ini.desc file by adding a comment just after the settings, like that:
Code:
[Some settings]
enableFeatureA=0
;list,0,1
You can also add some comments to be displayed for the user, by adding comments (on several lines if you want), like that:
Code:
[Some settings]
enableFeatureA=0
;list,0,1
;Set 0 to disable Feature A.
;Set 1 to enable Feature A.
And that gives you that:
Sometimes, there are so many things to say on a setting, that you don't want to or can't display all the comments about a setting in the menus of iniEditor.mscr.
Then, just added two semicolons at the beginning of the first "comment" line (after the "type" line"), like that:
Code:
advancedSetting=
;
;;Please check FAQ or sample.ini.desc file for more help on this setting.
;This is an advanved option.
;It is so long to explain how it works.
;I cannot show it in a MortScript message dialog box.
;But your are an advanced user.
;So you can find some tips directly here, but not through the iniEditor.mscr script.
If you set a parameter of type int, the user will be able to enter only an integer value:
If you set a parameter of type fullfilepath, you get this:
If you set a parameter of type path, you get this:
Feel free to use or modify my iniEditor.mscr, and if someone could make a real .exe app out of it, that would be great!
Attachments
-
EnterNewStringValue.jpg33 KB · Views: 251
-
EnterNewIntegerValue.jpg21.7 KB · Views: 171
-
ChooseValueFromList.jpg17.6 KB · Views: 234
-
ChooseValueFromList2.jpg21.8 KB · Views: 91
-
fullfilepath.jpg34.4 KB · Views: 177
-
path.jpg42.7 KB · Views: 182
-
iniEditor.gif76.5 KB · Views: 2,368
-
iniEditor_v05.zip3.3 KB · Views: 529
Last edited: