Removing Conditionals From Project

Please post all questions relating to Help & Manual 6 here!

Moderators: Alexander Halser, Tim Green

User avatar
Olivier Beltrami
Posts: 393
Joined: Mon Jul 15, 2002 3:30 pm
Location: Nantes, France
Contact:

Removing Conditionals From Project

Unread post by Olivier Beltrami »

I have an H&M 6 project that has a lot of conditionals, both within text, and at the topic level, which allows me to use the same project for the documentation to versions 1, 2 and 3 of my software. But, now, version 1 and 2 of my software are being terminated, and all the v.1 and v.2 conditionals are making the project awkward to manage (for no good reason anymore).

What I would like to do is to get rid of all the v.1 and v.2 conditional stuff, to clean-up my project.

I know H&M knows how to do this, because that is what it does every time I generate v.3 CHM and HTML output. But, how can I do it myself to be left with a cleaned-up H&M project ?

Very best regards,

Olivier
Olivier Beltrami
https://www.qppstudio.net
Worldwide Public Holidays and Calendar Data
Ivo Bily
Posts: 65
Joined: Thu Jan 25, 2007 10:37 pm
Location: Praha, Czech Republic

Re: Removing Conditionals From Project

Unread post by Ivo Bily »

Hi Olivier,
there is no straightforward way to do it, as far as I know - you can't save project with desired builds only.
What way to choose depends mainly on organization of your project, i.e. how do you use text, snippets, variables, styles, conditions etc.

I may suggest this scenario:

1. create backup
2. save project as hmxp (uncompressed) format
3. clean up project - remove topics completely designated for unwanted builds (could be done on the end as well)
4. save working copy of this project
5. in working copy remove topics where conditions are not used in text
6. export to HTML format with desired build
7. import to new project from HTML
8. correct what was lost (styles etc.), or remove topic completetly, if correcting exceeds editing in original
9. when satisfied copy xml files from this version over files in original uncompressed version (see 3.)
10. check and polish result in original

Decide if correcting lost information (see 8.) is more work than removing conditional text in H&M editor, then remove it "manualy", or you can combine both methods.

You may try Tim's Help&Manual Toolbox: http://helpman.it-authoring.com/viewtop ... it=toolbox
I did test it briefly but search/replace did not work for me.
I can imagine some scripting run over XML text, but is is probably not worth the effort if needed only once.

Regards
Ivo
User avatar
Tim Green
Site Admin
Posts: 23156
Joined: Mon Jun 24, 2002 9:11 am
Location: Bruehl, Germany
Contact:

Re: Removing Conditionals From Project

Unread post by Tim Green »

Hi Olivier,

You can do this with the Help & Manual Toolbox power user tool that I have posted on the forum. See this forum thread for information and a download link:

http://helpman.it-authoring.com/viewtop ... 22&t=12586

I attach a loadable search profile that is already set up to perform this task. Here's how to use it:
  1. Make a backup of your project.
  2. You did make a backup of your project, right? Do it now!
  3. Load your project in Help & Manual Toolbox. If you have a large project it is better to do this in uncompressed HMXP format, not in an HMXZ.
  4. In the Tools menu, select "Complex Find & Replace". Click on the Load button at the bottom and load the search profile.
  5. Change the value of the dummy USER1 conditional tag to the value of the tag you want to remove.
  6. Run a Preview to make sure it is working OK. You will see a warning if what you are doing creates invalid XML. If you have a big project it's best to restrict the preview rather than checking the entire project. (You have a backup, right?)
  7. Make sure that you really made a backup and that it is in a safe place.
  8. Perform the operation with Replace.

Be warned that this will delete the tags AND all the content between the tags, including any nested content. So make a backup and check after each run. 8)
You do not have the required permissions to view the files attached to this post.
Regards,
Tim (EC Software Documentation & User Support)

Private support:
Please do not email or PM me with private support requests -- post to the forum directly.
User avatar
Olivier Beltrami
Posts: 393
Joined: Mon Jul 15, 2002 3:30 pm
Location: Nantes, France
Contact:

Re: Removing Conditionals From Project

Unread post by Olivier Beltrami »

Hi Tim,

Thank you very much for your help. I followed your instructions, but when I try to replace USER1 with any of the Conditionals of my project, I get the message:
No Matches Found - No matching source code found. Nothing to preview
Any idea what I am missing ?

Very best regards,

Olivier
Olivier Beltrami
https://www.qppstudio.net
Worldwide Public Holidays and Calendar Data
User avatar
Tim Green
Site Admin
Posts: 23156
Joined: Mon Jun 24, 2002 9:11 am
Location: Bruehl, Germany
Contact:

Re: Removing Conditionals From Project

Unread post by Tim Green »

Hi Olivier,

Please mail me a small demo project to support AT ec-software.com (replace the AT with @) with a couple of topics containing examples of your conditionals and I will check it for you. The regex probably needs to be adjusted slightly for your project.
Regards,
Tim (EC Software Documentation & User Support)

Private support:
Please do not email or PM me with private support requests -- post to the forum directly.
User avatar
Olivier Beltrami
Posts: 393
Joined: Mon Jul 15, 2002 3:30 pm
Location: Nantes, France
Contact:

Re: Removing Conditionals From Project

Unread post by Olivier Beltrami »

Hi Tim,

I sent you a minimalist project a few minues ago (hope broken links are not an issue).
Very best regards,

Olivier
Olivier Beltrami
https://www.qppstudio.net
Worldwide Public Holidays and Calendar Data
User avatar
Tim Green
Site Admin
Posts: 23156
Joined: Mon Jun 24, 2002 9:11 am
Location: Bruehl, Germany
Contact:

Re: Removing Conditionals From Project

Unread post by Tim Green »

Hi Olivier,

The problem was that the project you send was uncompressed and the profile I mailed you was for compressed projects. HM Toolbox renders the XML slightly differently when it has to uncompress the files, because they are then rendered by the Microsoft XML parser instead of being read directly (HM Toolbox is written in C#).

I mailed you the corrected profile already, but I attach it here as well in case anyone else wants to use it.
You do not have the required permissions to view the files attached to this post.
Regards,
Tim (EC Software Documentation & User Support)

Private support:
Please do not email or PM me with private support requests -- post to the forum directly.
User avatar
Olivier Beltrami
Posts: 393
Joined: Mon Jul 15, 2002 3:30 pm
Location: Nantes, France
Contact:

Re: Removing Conditionals From Project

Unread post by Olivier Beltrami »

Hi Tim,

Thnak you very much for your assistance.

When I test the second .hmsearch you sent me, as is (ie. with IFNOT and ONLY_XE2), on the mini-project I sent you, it does report finding many occurrences and then I am able to replace them. But, when I open the project in H&M the replaced conditionals are still there ... and if I try to replace again I am told there nothing lsft to replace. I am confused; does the tool make a separate copy of the project somewhere else or under another name ?

Very best regards,

Olivier
Olivier Beltrami
https://www.qppstudio.net
Worldwide Public Holidays and Calendar Data
User avatar
Tim Green
Site Admin
Posts: 23156
Joined: Mon Jun 24, 2002 9:11 am
Location: Bruehl, Germany
Contact:

Re: Removing Conditionals From Project

Unread post by Tim Green »

Hi Olivier,

Please mail me the full project to support AT ec-software.com (replace the AT with @) and I'll check it out. (Just the project without any graphics or additional files -- if those are in the project folder remove them before zipping it.) Sometimes you need to play with the regexes to get it to work correctly and this is an operation I haven't done before.
Regards,
Tim (EC Software Documentation & User Support)

Private support:
Please do not email or PM me with private support requests -- post to the forum directly.
User avatar
Olivier Beltrami
Posts: 393
Joined: Mon Jul 15, 2002 3:30 pm
Location: Nantes, France
Contact:

Re: Removing Conditionals From Project

Unread post by Olivier Beltrami »

Hi Tim,

Thnak you very much for your quick reply.
I am getting the issues I mention, using even the small micro-project I sent you yesterday.
Are you getting correct results with my mini project and with IFNOT and ONLY_XE2 ?

Very best regards,

Olivier
Olivier Beltrami
https://www.qppstudio.net
Worldwide Public Holidays and Calendar Data
User avatar
Tim Green
Site Admin
Posts: 23156
Joined: Mon Jun 24, 2002 9:11 am
Location: Bruehl, Germany
Contact:

Re: Removing Conditionals From Project

Unread post by Tim Green »

Hi Olivier,

It's working fine on your demo project. I wouldn't have sent you the profile otherwise. See the attache before/after pictures along with the search screen.
replace_conditionals.png
You do not have the required permissions to view the files attached to this post.
Regards,
Tim (EC Software Documentation & User Support)

Private support:
Please do not email or PM me with private support requests -- post to the forum directly.
User avatar
Olivier Beltrami
Posts: 393
Joined: Mon Jul 15, 2002 3:30 pm
Location: Nantes, France
Contact:

Re: Removing Conditionals From Project

Unread post by Olivier Beltrami »

Tim Green wrote:I wouldn't have sent you the profile otherwise.
Of course, sorry for doubting.

So I have gone back to the project I sent you and tried again, and found something weird:

1) I replace IFNOT ONLY_XE2 and all workd well.
2) I close the toolbox and open the project and see that these conditionals are gone. Good.
3) Then I go back to the ToolBox and do a replacement of IF ANSI.
4) Close the toolbox and open the project ... and the IF ANSI are gone ... but the IFNOT ONLY_XE2 are back.

This is very odd. Also, even after all these change, the timestamp of my project file remains the same, is that normal ?

Anyways, I will spend soem time brushing up on regular expressions, and try to fix the issues myself, before imposing again.

Thnak you very much,

Olivier
Olivier Beltrami
https://www.qppstudio.net
Worldwide Public Holidays and Calendar Data
User avatar
Tim Green
Site Admin
Posts: 23156
Joined: Mon Jun 24, 2002 9:11 am
Location: Bruehl, Germany
Contact:

Re: Removing Conditionals From Project

Unread post by Tim Green »

Hi Olivier,

It's not possible for the deleted things to come back if you were editing the same project -- my guess is that you were accidentally opened another copy of the same project. However, I have discovered a problem in another area: After you perform the replacement the .NET XML routines save the XML with each tag node on a separate line (paragraph). Help & Manual saves all the tag nodes belonging to a paragraph in a single line (paragraph). Both are 100% valid XML, they are just different. But what happens then is that the next time you search, the search won't find the tags spanning the nodes on the multiple lines, even though they belong to the same paragraph.

At the moment the only way to solve this problem is to re-save everything with Help & Manual after each search and replace, and to do that you would need to make a change in Help & Manual so that the topics get re-saved, which would be a lot of work. I'm afraid there's no way around this because it requires a change in the search routines in HM Toolbox. Sorry about that... :?
Regards,
Tim (EC Software Documentation & User Support)

Private support:
Please do not email or PM me with private support requests -- post to the forum directly.
User avatar
Tim Green
Site Admin
Posts: 23156
Joined: Mon Jun 24, 2002 9:11 am
Location: Bruehl, Germany
Contact:

Re: Removing Conditionals From Project

Unread post by Tim Green »

Hi Olivier,

Update: There was a problem in the regex routine in HM Toolbox when performing multiple replacements on the same topic with different regexes one after another. I've now updated it with the correction. Just download the new version from the HM Toobox thread on the forum and install it to get the fix:

http://helpman.it-authoring.com/viewtop ... 22&t=12586

In addition to this I attach an improved search profile that will work on both compressed hmxz and uncompressed hmpx projects and takes modifications in the XML formatting into account when performing multiple searches. You should find that it works smoothly now. You should still make backups before using this, of course... 8)
You do not have the required permissions to view the files attached to this post.
Regards,
Tim (EC Software Documentation & User Support)

Private support:
Please do not email or PM me with private support requests -- post to the forum directly.
User avatar
Olivier Beltrami
Posts: 393
Joined: Mon Jul 15, 2002 3:30 pm
Location: Nantes, France
Contact:

Re: Removing Conditionals From Project

Unread post by Olivier Beltrami »

Thnak you very much, Tim.

Looking at the regex samples you sent me goy me thinking that I could probably write a program to do what I needed.

This would allow me to do fancier replaces such as IF_ANSI / ELSE / ENDIF which I would presumably have to process in 2 steps, deleting all from IF_ANSI to just before ELSE, then replacing ELSE by IF_NOT_ANSI so that the conditional is not broken.

Does the Toolbox allow for IF ELSE ENDIF constructs ? or just IF ENDIF ?
Olivier Beltrami
https://www.qppstudio.net
Worldwide Public Holidays and Calendar Data
Post Reply