Extendscript / Token

Explorer ,
Jun 01, 2015

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().

Views

193

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Extendscript / Token

Explorer ,
Jun 01, 2015

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().

Views

194

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jun 01, 2015 0
Adobe Community Professional ,
Jun 02, 2015

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

@petergrainge

Please use the blue Reply button at the top to help me help you. The black Reply link nests replies and they sort out of order.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 02, 2015 0
Explorer ,
Jun 02, 2015

Copy link to clipboard

Copied

No. Again I am in the right forum. The question is targetting ExtendScript in RoboHelp.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 02, 2015 0
Adobe Community Professional ,
Jun 02, 2015

Copy link to clipboard

Copied

Apologies. I read the content and not the title.


See www.grainge.org for RoboHelp and Authoring tips

@petergrainge

Please use the blue Reply button at the top to help me help you. The black Reply link nests replies and they sort out of order.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 02, 2015 0
LEGEND ,
Jun 03, 2015

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;

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 03, 2015 0
Explorer ,
Jun 03, 2015

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 03, 2015 0
LEGEND ,
Jun 03, 2015

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.)

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 03, 2015 0