Jump to content

In IE/JS: ADODB.stream's method SaveToFile() not working for me only with save option: "adSaveCreateOverwrite"


zeroflag

Recommended Posts

With IE/Javascript, I am trying to do scripting (programming) on local file access functionalities (reading/writing), kind of creating a wrapper functions of my own using ADODB.stream. Purpose is not something an attempt to access from remote internet, but intended accessing local file data from my own local PC/IE only.Any security restrictions imposed by Windows system are cleared by make proper registry settings. I have made it successfully reading local data files using LoadFromFile() method (one of ADODB.stream's methods), even OK writing (/saving) data using SaveToFile() but with another save option: "adSaveCreateNotExist". I failed to get SaveToFile() working when with its option "adSaveCreateOverwrite" ONLY -- the symptom is when calling SaveToFile() with "adSaveCreateOverwrite" option, as if nothing happened, regardless of save-to file existing or not (I tried both cases): the existing file is not overwritten in the case it exists, or no new file is created in the case it do not exist - in a word nothing happens.Why like that? What could be wrong - MS or me? I appreciate anyone's help.***** OS used: Windows XP (prof) SP2 (Japanese) / IE6

Link to comment
Share on other sites

So using adSaveCreateNotExist works, but adSaveCreateOverwrite doesn't work? Have you tried to create a file with the not exist flag, then overwrite the same file?
Right - I tried the option "adSaveCreateNotExist ", it works. In fact, first I tried this option, and I saw the save-to file created from non-existing... then, I simply modified JS code by changing this option from "adSaveCreateNotExist " to "adSaveCreateOverwrite", running it, however, nothing overwriting happened -- this can be confirmed by the timestamp of the save-to file.. (or, before overwriting, I can copy a totally different data file as the same name with this "save-to file", then run script, but file content has nothing changed). This is really weird. In my previous scripting (with other languages, and other purpose), occasionally, I noticed MS functions not behavioring as expected.I appreciate your further advice.
Link to comment
Share on other sites

What version of IE are you testing with? Are there any Javascript errors that would help?
==> IE 6.==> No any error message, it just dropped mid-way. Say, test code like this: ................. var adSaveCreateOverwrite = 2; . . . . . . . . . alert("In my func saveTextFile() .... ---1---"); // debug msg #1 objStrm.SaveToFile(save2Filespec, adSaveCreateOverwrite); // Call SaveToFile method alert("In my func saveTextFile() .... ---2---"); // debug msg #2 . . . . . . . . .On running, first msg ("---1---") is displayed, but the second not, if checking result file at this point, nothing overwritten happened.
Link to comment
Share on other sites

If there is a fatal error that is stopping an alert message from being displayed, then there will also be an error message. I'm not sure if there's a way to disable Javascript error messages in IE, but make sure that they are enabled and that you are checking for them. IE8 also has much better error reporting than IE6.

Link to comment
Share on other sites

I may check later to see if somewhere settings that enable/disable error messages. but it doesn't seem like a fatal error that will occur - I checked again and again: method's calling syntax is correct, params (filespec and save options) are valid, params' values are valid, calling with another save option works ok as well, and so on.I am frustrated about why part of functionalities working fine while not others -- this is an inconsistency issue: in fact, I have a post of the same question on a MS forum: Offical Scripting Guy Forum, please see discussions there and my latest arguments in following URL -- http://social.technet.microsoft.com/Forums...e6-8056d5d14a89

Link to comment
Share on other sites

but it doesn't seem like a fatal error that will occur
It does to me. If the code stops running at some point (i.e., the second alert doesn't run), it sure sounds like a fatal error is stopping execution. If a fatal error was not stopping execution, then the second alert would execute. The error message will give an indication as to what the problem is.
Link to comment
Share on other sites

It does to me. If the code stops running at some point (i.e., the second alert doesn't run), it sure sounds like a fatal error is stopping execution. If a fatal error was not stopping execution, then the second alert would execute. The error message will give an indication as to what the problem is.
Justsomeguy, your advice finally worked -- all sorted out!Your advice and insisting on having me looking for fatal errors is a correct direction leadingto finally spotting where is wrong!First, I found the IE options that enable displaying all detail messages for JS runtime errors. Then IE showed me following why/where my JS code stopped running: "variable 'adSaveCreateOverwrite' not defined" (declared)While I do rember having defined the variable on top of the JS lib file like below: var adSaveCreateOverWrite = 2;After having a careful look, my god, the difference is found to be because of the different letter cases of one letter "W": one is as "adSaveCreateOverWrite", the other "adSaveCreateOverwrite".After correction, all set!Over a long time, I have primarily worked with Windows and VBScript programming, a case-insensitive platform; I am using an editor of Notepad++, which didn't alert me for using a variable name that mayinvolve letters of unmatched letter cases. Well, this time MS is innocent.To benifit others for whom to avoid similar mistakes, I decided to publicize my error details as a screenshot, please see following URL link for reference -- http://firestorage.jp/download/8d2449b13ae...670409efde4abb3Again really appreciate your help!
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...