Writing to projects.ini and other settings files

Let us know what you would like to see in the next version of this software

Moderator: kfury77

Forum rules
Please follow these guidelines when posting feature requests. This will help to increase the value of your contribution.

  • Do not create new topics for already requested features. Add your comments to the existing feature request topics instead;
  • Create separate topic for each feature suggestion. Do NOT post a number of non-related feature suggestions in a single topic;
  • Give your topic a meaningful title. Do NOT create topics with meaningless titles, such as "My Suggestion" or "My Problem".

Please note that we DO READ all suggestions, even if a reply is not posted. Thanks!

Writing to projects.ini and other settings files

Postby pmk65 » Thu Apr 19, 2018 1:59 pm

I working on a new plugin :D
This time I want to extend the Project handling. I am able to read the "projects.ini" file and also write to it.
But as WeBuilder stores the content internally (registry?), my changes are not detected by WeBuilder.

Would it be possible to add some kind of method to trigger reloading of the file into memory?
Or a way to duplicate the code written in .ini file, into memory?
There are 10 types of people in the world: Those who understand binary and those who don't.
User avatar
pmk65
 
Posts: 552
Joined: Sun Dec 20, 2009 9:58 pm
Location: Copenhagen, Denmark

Re: Writing to projects.ini and other settings files

Postby Aivars » Thu Apr 19, 2018 4:24 pm

Not really, but the correct way to be to go through API anyways. What exactly are you trying to change for the projects?
Blumentals Software Programmer
User avatar
Aivars
Blumentals Software Developer
 
Posts: 2254
Joined: Thu Aug 22, 2002 1:40 pm
Location: Latvia

Re: Writing to projects.ini and other settings files

Postby pmk65 » Thu Apr 19, 2018 7:58 pm

Aivars wrote:Not really, but the correct way to be to go through API anyways. What exactly are you trying to change for the projects?


Since i can't add anything to the existing "Project" GUI, I basically want to clone as much of the existing Project functionality into a new plugin.
Then I can add my enhancements, and use the plugin as a replacement/addition to the "Project" menu.

I also tried setting properties of Script.ProjectSettings, but that result in a crash/error, so Im assuming they are read-only?

Code: Select all
    Script.ProjectSettings.SelectedProjectName = "testproject";

Result:
Plugin "Extended Projects handling.": Line 338:5: Access violation at address 00000000 in module 'webuild.exe'. Execution of address 00000000
There are 10 types of people in the world: Those who understand binary and those who don't.
User avatar
pmk65
 
Posts: 552
Joined: Sun Dec 20, 2009 9:58 pm
Location: Copenhagen, Denmark

Re: Writing to projects.ini and other settings files

Postby Aivars » Fri Apr 20, 2018 8:29 am

I'll check but I think that they are read-only.

One way to work around all this would be to have your special "Edit Project" dialog, where the general project info (name, path) is read-only with Edit button, that simply calls "Edit Current Project" action. That way you can focus on the extra stuff and not worry about standard project properties, even between major versions.
Blumentals Software Programmer
User avatar
Aivars
Blumentals Software Developer
 
Posts: 2254
Joined: Thu Aug 22, 2002 1:40 pm
Location: Latvia

Re: Writing to projects.ini and other settings files

Postby pmk65 » Sat Apr 21, 2018 1:19 pm

Aivars wrote:One way to work around all this would be to have your special "Edit Project" dialog, where the general project info (name, path) is read-only with Edit button, that simply calls "Edit Current Project" action.


I thought of that too, but it kind of defeat the purpose of having a docking panel. (Forgot to say it was a docking panel plugin :D)
There are 10 types of people in the world: Those who understand binary and those who don't.
User avatar
pmk65
 
Posts: 552
Joined: Sun Dec 20, 2009 9:58 pm
Location: Copenhagen, Denmark

Re: Writing to projects.ini and other settings files

Postby Aivars » Sat Apr 21, 2018 1:46 pm

Maybe it doesn't have to be. I don't know what you're making, maybe docking panel makes sense for this plugin, but generally you would need it only for stuff that you want to be visible and quickly accessible at all times.
Blumentals Software Programmer
User avatar
Aivars
Blumentals Software Developer
 
Posts: 2254
Joined: Thu Aug 22, 2002 1:40 pm
Location: Latvia

Re: Writing to projects.ini and other settings files

Postby Will Fastie » Tue Apr 24, 2018 4:58 am

I know what Peter is doing so let me ask a more general question.

Where can a plugin read and write persistent data? For example, can a plugin read/write the Windows registry?

I can see both points of view here. Because Peter's plugin relates to project management, the logical place to persist his data is in projects.ini. I agree with him that it makes sense.

On the other hand, I would worry that persisting data there runs the risk of conflicting with a future Blumentals change.

Personally, I like the idea of the Registry.
Will
WebDesignBuild.biz, Fastie.com
User avatar
Will Fastie
 
Posts: 134
Joined: Mon Jan 31, 2005 6:47 pm
Location: Timonium, MD USA

Re: Writing to projects.ini and other settings files

Postby Aivars » Tue Apr 24, 2018 7:11 am

Plugins can read/write persistent data in multiple ways and Peter has done it before. I'm sure he already has ideas how to go about it this time.
Blumentals Software Programmer
User avatar
Aivars
Blumentals Software Developer
 
Posts: 2254
Joined: Thu Aug 22, 2002 1:40 pm
Location: Latvia

Re: Writing to projects.ini and other settings files

Postby Will Fastie » Tue Apr 24, 2018 2:46 pm

I'd like to know how it is done. The online documentation for plugins is very thin.
Will
WebDesignBuild.biz, Fastie.com
User avatar
Will Fastie
 
Posts: 134
Joined: Mon Jan 31, 2005 6:47 pm
Location: Timonium, MD USA

Re: Writing to projects.ini and other settings files

Postby Aivars » Wed May 02, 2018 2:11 pm

1. Using properties.ini (I'm using parts of Peter's script for this example). The advantage of this method is that these values can be customized by anyone via Plugin Manager.

Create properties.ini:

Code: Select all
[Properties]
Trigger sequence=string
Trigger on keywords only=check

[Values]
Trigger sequence=/**
Trigger on keywords only=0

[Hints]
Trigger sequence=Keyboard sequence to trigger plugin
Trigger on keywords only=If checked, DocBlock Comment will only be inserted if next line contains a matching keyword.


Reading the setting:

Code: Select all
var triggerCombo      = Script.ReadSetting("Trigger sequence", "/**"),
triggerKeywordsOnly   = Script.ReadSetting("Trigger on keywords only", "1");


Writing the setting:

Code: Select all
Script.WriteSetting("Trigger sequence", triggerCombo);
Script.WriteSetting("Trigger on keywords only", triggerKeywordsOnly);



2. Using custom ini file:

Code: Select all
function WriteIni(Sender) {
  var lastFileName = Document.FileName;
  var ini = new TIniFile(Script.Path + "test.ini");
  ini.WriteString("My Settings", "Last File", lastFileName);
  delete ini;
}

function ReadIni(Sender) {
  var ini = new TIniFile(Script.Path + "test.ini");
  var fileName = ini.ReadString("My Settings", "Last File", "file not found");
  delete ini;
  Script.Message(fileName);
}

Script.RegisterAction("", "Test INI Read", "", &ReadIni);
Script.RegisterAction("", "Test INI Write", "", &WriteIni);


You can use this plugin as reference as to what other methods TIniFile combined with its parent TCustomIniFile supports: viewtopic.php?f=33&t=7407. In most cases Read/WriteString, Read/WriteInteger, Read/WriteBool is enough.
Blumentals Software Programmer
User avatar
Aivars
Blumentals Software Developer
 
Posts: 2254
Joined: Thu Aug 22, 2002 1:40 pm
Location: Latvia

Re: Writing to projects.ini and other settings files

Postby Will Fastie » Wed May 02, 2018 2:45 pm

Thank you.

While I appreciate the time you took to add these notes, I hope they can be added to the standard documentation set so they are readily available from help.
Will
WebDesignBuild.biz, Fastie.com
User avatar
Will Fastie
 
Posts: 134
Joined: Mon Jan 31, 2005 6:47 pm
Location: Timonium, MD USA


Return to HTMLPad / Rapid CSS / Rapid PHP / WeBuilder Feature Requests

Who is online

Users browsing this forum: No registered users and 1 guest

cron