Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

[MortScript] iniEditor: get a friendly menu out of an .ini file!

OP michoob

27th September 2010, 02:54 PM   |  #1  
michoob's Avatar
OP Retired Recognized Developer
Flag Brussels
Thanks Meter: 64
 
1,270 posts
Join Date:Joined: Dec 2008
Donate to Me
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:
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.
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!
Attached Thumbnails
Click image for larger version

Name:	EnterNewStringValue.jpg
Views:	129
Size:	33.0 KB
ID:	408235   Click image for larger version

Name:	EnterNewIntegerValue.jpg
Views:	73
Size:	21.7 KB
ID:	408236   Click image for larger version

Name:	ChooseValueFromList.jpg
Views:	125
Size:	17.6 KB
ID:	408237   Click image for larger version

Name:	ChooseValueFromList2.jpg
Views:	53
Size:	21.8 KB
ID:	408238   Click image for larger version

Name:	fullfilepath.jpg
Views:	78
Size:	34.4 KB
ID:	409083   Click image for larger version

Name:	path.jpg
Views:	78
Size:	42.7 KB
ID:	409084   Click image for larger version

Name:	iniEditor.gif
Views:	1805
Size:	76.5 KB
ID:	409653  
Attached Files
File Type: zip iniEditor_v05.zip - [Click for QR Code] (3.3 KB, 273 views)
Last edited by michoob; 18th April 2011 at 10:18 PM. Reason: iniEditor v05
27th September 2010, 03:09 PM   |  #2  
Retired Recognized Developer
Flag Bordeaux
Thanks Meter: 83
 
650 posts
Join Date:Joined: Apr 2006
Donate to Me
More
Wink Pas mal !
Bon outils (qui simplifie la vie) comme je les aime !

A++
28th September 2010, 04:52 PM   |  #3  
michoob's Avatar
OP Retired Recognized Developer
Flag Brussels
Thanks Meter: 64
 
1,270 posts
Join Date:Joined: Dec 2008
Donate to Me
Thank you for your support JMHL .

I know I'm alone in my ini editor trip, but I've added two types of parameters: fullfilepath and path.
Just check the first post to have more information on these.

Still no one motivated to developp this in CF.Net for instance?
28th September 2010, 09:36 PM   |  #4  
michoob's Avatar
OP Retired Recognized Developer
Flag Brussels
Thanks Meter: 64
 
1,270 posts
Join Date:Joined: Dec 2008
Donate to Me
I've seen that two people have downloaded my second version of iniEditor.
Please find in the first post a new version with a small bug corrected.
29th September 2010, 05:37 PM   |  #5  
sv0911's Avatar
Senior Member
Thanks Meter: 288
 
679 posts
Join Date:Joined: May 2010
More
Thumbs up
Hi michoob,

A BIG THANKS for your new fantastic MortScript app...!!!!
As usual a great work...!!!!

I will of course use it also in my apps...!!!!

Greetings
sv0911
29th November 2010, 08:41 PM   |  #6  
jwoegerbauer's Avatar
Senior Member
Bavaria (Germany)
Thanks Meter: 197
 
581 posts
Join Date:Joined: Jul 2009
Thumbs up Thanks, thanks and again thanks
michoob,

a really great job you did! Extremely user friendly and tremendously fast!
30th November 2010, 12:57 AM   |  #7  
michoob's Avatar
OP Retired Recognized Developer
Flag Brussels
Thanks Meter: 64
 
1,270 posts
Join Date:Joined: Dec 2008
Donate to Me
You're welcome jwoegerbauer!
30th November 2010, 09:21 AM   |  #8  
jwoegerbauer's Avatar
Senior Member
Bavaria (Germany)
Thanks Meter: 197
 
581 posts
Join Date:Joined: Jul 2009
Quote:
Originally Posted by michoob

Feel free to use or modify my iniEditor.mscr

I followed your invitation. These are the 2 changes I mainly made in my copy of your iniEditor.mscr

Code:
Copy(fileName, fileName & ".bak", 1)
iniChanged = 0
choosenSection = 1
While (choosenSection <> 0)
	choosenSection = Choice(appName & " settings", "Please choose a settings section:", 0,0, sectionList)
	If (choosenSection <> 0)
		Call("IPTWkeys")
	EndIf
EndWhile
If(not iniChanged)
	Delete(fileName & ".bak")
EndIf


If (confirmation)
	valueList[choosenKey] = newValue
	keyValueList[choosenKey] = keyList[choosenKey] & "=" & newValue
	IniWrite(fileName, sectionList[choosenSection], keyList[choosenKey], newValue)
	iniChanged += 1
EndIf
Last edited by jwoegerbauer; 30th November 2010 at 09:43 AM.
17th February 2011, 08:50 AM   |  #9  
michoob's Avatar
OP Retired Recognized Developer
Flag Brussels
Thanks Meter: 64
 
1,270 posts
Join Date:Joined: Dec 2008
Donate to Me
I've just updated the iniEditor.mscr script with a new feature really usefull when you have huge .ini files to improve reading performance of your .ini file and have your MortScript apps run faster!
This new feature is the use of the .ini.desc file that contains all default values and all the comment structure of iniEditor. Now, the .ini file can be comment free and still you'll have all the information while editing your .ini file through iniEditor!

As usual, you can test this new version with IPTWeather.

Feedbacks welcomed!
24th February 2011, 06:21 PM   |  #10  
jwoegerbauer's Avatar
Senior Member
Bavaria (Germany)
Thanks Meter: 197
 
581 posts
Join Date:Joined: Jul 2009
Quote:
Originally Posted by michoob

I've just updated the iniEditor.mscr script with a new feature really usefull when you have huge .ini files to improve reading performance of your .ini file and have your MortScript apps run faster!
This new feature is the use of the .ini.desc file that contains all default values and all the comment structure of iniEditor. Now, the .ini file can be comment free and still you'll have all the information while editing your .ini file through iniEditor!

Tried v04. Simply an ingenious improvement. Thanks.

Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes