Copy link to clipboard
Copied
When I delete a token how can I find out later in the code, that I already deleted it - before I save!
There exists a Token.delete() function but e.g. no Token.isDeleted().
Copy link to clipboard
Copied
I suspect your question is not related to Adobe's RoboHelp product and that you have asked in the wrong forum.
See www.grainge.org for RoboHelp and Authoring tips
Copy link to clipboard
Copied
No. Again I am in the right forum. The question is targetting ExtendScript in RoboHelp.
Copy link to clipboard
Copied
Apologies. I read the content and not the title.
See www.grainge.org for RoboHelp and Authoring tips
Copy link to clipboard
Copied
What is your workflow? Do you have a piece of code that is giving you problems?
I always assumed that if you delete a token, it will not be available anymore in the TokenManager. The following works fine in my project:
while(typeof(token)!="undefined")
{
if(token.isTag(startTag) && token.getText() == Content) {//We're in a H3 so let's get all content
var warningtext = "";
var tokensToDelete = [];
var done = false;
var tmpToken = token;
while(done === false)
{
if(tmpToken.isTag("p")) {
warningtext = tmpToken.getText(true);
tokensToDelete.push(tmpToken);
}
else if(tmpToken.isTag("/p"))//Done!
{
tokensToDelete.push(tmpToken);
done = true;
}
else
{
tokensToDelete.push(tmpToken);
}
tmpToken = tmpToken.next;
}
token.insertText('<p class="letopkop">'+Content+'</p><p class="letopteskt">'+warningtext+'</p>', true);
for(var i=0; i<tokensToDelete.length;i++) {
tokensToDelete.delete();
}
saveme = true;
}
//Next token
token = token.next;
Copy link to clipboard
Copied
I want to cover following situation:
token.delete();
token = token.previous.next;
The 2nd line should not return the already deleted item or there should exist an "isDeleted()" function which tells me that I already deleted it.
Copy link to clipboard
Copied
Just tried and indeed, if you delete a token it is still there. There is no property or method available to check whether the token is deleted. Please consider leaving a feature request for this to be added: Adobe - Feature Request/Bug Report Form
I have tried if there is an easy workaround, but there is no simple workaround for writing your own deletetion option either. If you store the token, you can't simply check other tokens against it. So this is an oversight. Perhaps you can work around this by changing the behaviour of your script to not pass the same token twice. (Or save the file and load it up in the tokenmanager again for a second pass. Far from ideal, but it may help.)