NoteWorthy Composer Forum

Forums => Tips & Tricks => User Tools => Topic started by: Bornagaintubist on 2010-05-06 12:16 am

Title: First time user-tool user.
Post by: Bornagaintubist on 2010-05-06 12:16 am
Good evening one and all.
I'm new to the user tools and am having a problem trying to create one of my own. I have downloaded the starter kit, and have played around with the supplied ones. I wish to make an amended version of Notenames, and tried to copy the php file in the scripts/lib directory, but I don't have the required permision on my computer. I am the admin user, but I dont know how to change the required permissions. I tried to copy it to my documents folder, but when I try to execute my amended version I get the following error message...

Warning: require_once(lib/nwc2clips.inc): failed to open stream: No such file or directory in C:\Users\phil\Documents\nwsw_Tubavalves.php on line 26

Fatal error: require_once(): Failed opening required 'lib/nwc2clips.inc' (include_path='.') in C:\Users\phil\Documents\nwsw_Tubavalves.php on line 26


Could one of you more experienced users please explain where I go from here.

My thanks in advance.
Title: Re: First time user-tool user.
Post by: Rick G. on 2010-05-06 12:44 am
I tried to copy it to my documents folder, but when I try to execute my amended version I get the following error message...

Warning: require_once(lib/nwc2clips.inc): failed to open stream: No such file or directory in C:\Users\phil\Documents\nwsw_Tubavalves.php on line 26

Fatal error: require_once(): Failed opening required 'lib/nwc2clips.inc' (include_path='.') in C:\Users\phil\Documents\nwsw_Tubavalves.php on line 26
The script is looking for: lib/nwc2clips.inc
You will need to modify line 26 so it can find the file
    --- or ----
Create a folder: C:\Users\phil\Documents\lib and copy nwc2clips.inc into it.
Title: Re: First time user-tool user.
Post by: NoteWorthy Online on 2010-05-06 11:24 am
If you want your script to be similar to the starter kit scripts, you can create your own files within the NWC2 scripts folder. You would need to use "Run as administrator" on your text editor in a similar fashion to what is described in FAQ - How do I create my own templates? (http://ntworthy.com/composer/faq/19.htm).

When working from your user folder, the easiest approach would be to add the full path when including nwc2clips, like require_once("c:/program files/noteworthy software/noteworthy composer 2/scripts/lib/nwc2clips.inc");

I would recommend against using our existing script filename for your custom script.

I would also generally recommend that you create your own starter include file that includes the nwc2clips library. You can then include that intermediate file in all of your scripts, and then only one file would need to be updated in the event that you change the location for the installed NWC2 program files.


Version 2.11 of the Starter Kit now allows you to use a relative include path to the nwc2clips library.

See also:

PHP include_path:
http://www.php.net/manual/en/ini.core.php#ini.include-path

PHP Include/Require:
http://php.net/manual/en/function.include.php
Title: Re: First time user-tool user.
Post by: Randy Williams on 2010-05-06 04:58 pm
Instead of modifying the standard require line:
Quote
require_once("lib/nwc2clips.inc");

Is it better, worse, or the same architecturally to just add this line before it:
Code: [Select · Download]
set_include_path("C:/Program Files/Noteworthy Software/NoteWorthy Composer 2/Scripts");

Either way, is there an easy way for a script to obtain the path from a registry entry, rather than hard-coding it?
Title: Re: First time user-tool user.
Post by: Bornagaintubist on 2010-05-06 05:33 pm
Thanks all. I can now run my own scripts. Can't seem to get it to do what I want though.....
Title: Re: First time user-tool user.
Post by: Rick G. on 2010-05-06 06:14 pm
is there an easy way for a script to obtain the path from a registry entry, rather than hard-coding it?
https://forum.noteworthycomposer.com/?topic=7044.msg48459#msg48459
Title: Re: First time user-tool user.
Post by: Randy Williams on 2010-05-07 05:48 am
But how do I view registry entries in Windows (XP)?  And how does a script retrieve a value from the registry?
Title: Re: First time user-tool user.
Post by: Rick G. on 2010-05-07 06:36 am
Regedit.exe is normally used to view/modify the registry. Usual caveats about destroying your computer apply.
I don't think that the version of php.exe supplied with NWC's toolkit can read the registry.
It is a fairly simple matter with VBScript. Example <here> (https://forum.noteworthycomposer.com/?topic=6964.0).

For a User Tool, the registry is not needed to get NWC's program path. It is always the current working directory when the tool is invoked. So:
Quote from: CurrDir.php
<?php
  // current directory
  fputs(STDERR,getcwd());
?>
works when run as a User Tool.
Title: Re: First time user-tool user.
Post by: NoteWorthy Online on 2010-05-08 02:52 pm
Version 2.11 of the NWC2 User Tool Starter Kit includes built-in support for relative include of the NWC2 "lib" modules. You should not need to include the full path to the NWC2 clip library now. You should be able to use the same require/include statements used by the built-in starter kit tools.

Version 2.11 also includes support for accessing NWC2 user config data.

  • an updated nwc-conv.exe for command line conversion of *.nwc to and from *.nwctxt
  • a new custom edition of PHP 5.3 that includes support for the COM class interface
  • an updated php.ini environment for easier access to the starter kit's include library from a user development folder outside of the NWC2 program files
  • a new nwc2config lib module for developers to access NWC2 user config data
Title: Re: First time user-tool user.
Post by: Rick G. on 2010-06-27 03:29 pm
is there an easy way for a script to obtain the path from a registry entry, rather than hard-coding it?
Code: [Select · Download]
<?php
/*******************************************************************************
rg_Path.php Version 1.00
This script shows the version of the Starter Kit that is installed and
the install path for NWC2.x as retrieved from the Registry.
*******************************************************************************/
require_once("lib/nwc2clips.inc");
require_once("lib/nwc2config.inc");
$libver = NWC2ClipLibVersion();
$appPath = NWC2CONFIG_AppFolder;
$usermsg = <<<__EOMSG
Clip Library Version: $libver
App Path: $appPath
__EOMSG;
fputs(STDOUT,$usermsg);
exit(NWC2RC_REPORT);
?>