• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Check to see if a file exists

Guest
Dec 09, 2008 Dec 09, 2008

Copy link to clipboard

Copied

Hello all,

I have a small problem that I can't seem to figure out. I have several .htm files that I will need to run through the .chm and I want to check to see if a file exists prior to attempting to load it. If the file does not exist, I want it to load a default "File not found" page that I will create in my .chm.

I am familiar with .net programming, but JavaScript is fairly new to me. If someone could point me in the right direction, I would appreciate it.

I will now go and keep googling...thanks in advanced for any help you can provide.

Views

672

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
community guidelines
Engaged ,
Dec 09, 2008 Dec 09, 2008

Copy link to clipboard

Copied

Since you are using a .chm output, you can use VBScript. I'm sure there is also a way to do this in javascript, but I am not as conversant in javascript. I've attached code I used to test an annotation script. In looking at it, I should have put the script in the HEAD section. But this does work and lets the user know if the annotation file exists before they try to read it.

John

Votes

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
community guidelines
Guest
Dec 16, 2008 Dec 16, 2008

Copy link to clipboard

Copied

Thanks John,

I was wondering though...how could I make this redirect the page to the file that I want? The page, if found, would be in the file system (%programfiles%\Alphav8\WhatsNew\WhatsNew.htm)

Can I have that file displayed in the .chm using this? If the file is not found, I would like to redirect the page to a topic that is in the .chm (.\failedtofind.htm).

Sorry for all the questions, I am not too familiar with VBScript, thanks.

Votes

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
community guidelines
Engaged ,
Dec 16, 2008 Dec 16, 2008

Copy link to clipboard

Copied

Andrew,

It has been a while since I wrote this code, but I included the whole thing so you could see how it works. These days you may get a security warning based on your computer settings since scripts can be harmful. In this script, the text is directed to a message box. That is not what you want. I think I can combine this with a hidden link script and provide what you are looking for. I should be able to get to it sometime today. Just to be clear - you are producing a .chm output and the file is an external file, correct? What type of file is it - .doc, .txt, .htm, pdf? You can email me or post here.

John

Votes

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
community guidelines
Engaged ,
Dec 16, 2008 Dec 16, 2008

Copy link to clipboard

Copied

LATEST
By the way, I do not think it is possible to read a user's computer (search for files) from a CHM file without some kind of warning message from our Big Brother at Microsoft. I think things that are allowed by an application should be allowed by that application's help file. If you trust a company's executable to run on your computer, why is their companion help file seen as a security risk? It makes no sense to me but that's the way of things...

When you run a script to read the user's files, you will get a warning. If your users are knowledgable they can proceed. If not, they may panic.

John

Votes

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
community guidelines
Resources
RoboHelp Documentation
Download Adobe RoboHelp