I have looked for an answer in the various posts but have not found anything, so here is the question.
I am using Arbortext Editor 5.3. We have a couple of script files (init.acl and user.acl) on a network folder, say s:\scripts.
To avoid network latency the script files are copied to a local hard drive and loaded from there when Arbortext is executed. Occasionally one or more of these scripts may change. I want to make it easy for users to check for updates by providing an menu option they can use. The idea is it checks the version of the local script and then checks the version of the network script.
In each script file I put a version that I want to check against later, e.g $initscriptver=1 and $userscriptver=1,
what I want to do in my check_for_updates.acl script is something similar to the following:
I am having trouble working out how to do step 3 (and possibly step 2 ). As I may not be the only one updating the scripts, the version number position may change (e.g. there could be whitespace either side of the "=")
An example of the code is:
function Find_string_in_file(strtofind, from)
{
srcFile = open(from, "r")
if (srcFile < 0)
{
eval "Couldn’t open file for read:", from
return 0
}
while (getline(srcFile, line))
{
$pos=span($line, $strtofind);
if ($pos > 0)
{
#
# extract the version somehow
#
break;
}
}
close(srcFile)
return 1; # True
}
Any pointers would be greatly appreciated.
You can do it this way but I would recommend to save yourself the hard work and use the built-in Arbortext feature
"zipped customisations". This is documented in the Arbortext Help Center (topic #17122). In your case you can host your custom scripts on a web server and on the client simply set APTCUSTOM=http://my.server.com/arbortext/scripts.zip
Here is an extract:
Thanks for your reply, Gareth. I would love to make my jo simpler but, alas, the organisation I work for has pretty much locked everything down on the local drives and also wrt web servers. I am in a technical publications team and the scripts are for the team. They do not have a wider audience so even if we were able to deploy a webserver it would probably be overkill. We are very much restricted to what we can access on a network drive and essentially one unlocked folder on our local hard drives. So I am somewhat forced to do it the hard way.
Cheers
I think the zipped customisations can work from a regular file share too, as you don't have a web server. Try it out and see? This will avoid you needing to write any code.
I'm not able to use customizations. Is there a way to get a string from a text (script) file?
Thanks
The Arbortext Help Center is a great resource. It is included with Arbortext as an optional download and is also available online: https://support.ptc.com/help/arbortext/r8.1.0.0/en/
Navigate to Programming -> Arbortext Command Language -> Functions by Category -> File Identifier Functions. You will find complete reference materials for open() read() seek() getline() close() etc.