Jump to content

This is a weird one


Recommended Posts

8 hours ago, TheDcoder said:

Wow... an assumption, you never mentioned that you were using _FileCreate to zero it's contents :P

I beg to differ, I only suggested FileOpen to create or empty the file, you need not to use it for Ini functions. I went the extra mile to show you how _FileCreate could be replaced in such a way that it never produces a BOM:

; Drop in replacement for _FileCreate
Func _FileCreateNoBOM($sFilePath)
    Local $hFile = FileOpen($sFilePath, $FO_OVERWRITE + $FO_UTF8_NOBOM)
    FileClose($hFile)
EndFunc

Another surprise: The _FileCreate function also uses FileOpen, have a look at it yourself in File.au3 include :muttley:

A pretty good ASSumption I reckon, all things considered. :P

And yes I did mention _FileCreate in my second post, not in the exact zero byte words, but that is what it does. :wacko:

I use IniWrite to create the INI file, as it is supposed to do. Doing an extra step by using FileOpen to create the INI file instead, is just not reasonable to my mind. And If I am gonna muck around using FileOpen to wipe the INI file content, I might as well just use the simpler FileDelete command instead. ;)

In addition to all that, if _FileCreate as you say is using FileOpen, which no doubt it is (according to my memory and your confirmation), then am I really avoiding the issue? Perhaps I am, if the flag _FileCreate uses with FileOpen is not $FO_UT8_NOBOM.

But anyway, as you know, I am now probably gonna just use SQL instead of INI. Especially now we have sussed the likely problem.

Maybe I should whip up some pseudo like SQL INI functions, to ease the transition ... that appeals to the simple man within. :D

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

Indeed. o:)

P.S. What can I say? Me addicted to the quick and easy ... especially when the endgame is something else ... HTML in this instance. :lol:

Edited by TheSaint

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

20 hours ago, TheSaint said:

FileOpen is not really appropriate for INI stuff, and certainly no replacement for _FileCreate.

Actually, _FileCreate uses FileOpen, so I'm not understanding what you're saying here.

Func _FileCreate($sFilePath)
    Local $hFileOpen = FileOpen($sFilePath, BitOR($FO_OVERWRITE, $FO_CREATEPATH))
    If $hFileOpen = -1 Then Return SetError(1, 0, 0)

    Local $iFileWrite = FileWrite($hFileOpen, "")
    FileClose($hFileOpen)
    If Not $iFileWrite Then Return SetError(2, 0, 0)
    Return 1
EndFunc   ;==>_FileCreate

 

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

20 hours ago, BrewManNH said:

Actually, _FileCreate uses FileOpen, so I'm not understanding what you're saying here

Yes I know. You must have missed where we already discussed that.

And I am guessing you misunderstood my meaning - if it is essentially the same, but a step or two more than just _FileCreate, then where's the point, especially as the issue seems related somehow. Far better to just use FileDelete.

Sure, using FileOpen directly and using the NOBOM flag might solve this rare issue, but I see no way to prove that ... only in theory.

So as they say, right tool for the job - INI functions for INI files.
And best way to remove everything in a file that is no longer required and will be automatically created again at need, is to just to FileDelete it ... right tool again. EDIT - I thought leaving an empty file behind, saved something needing to be redone, which is why I used _FileCreate (have done for years).

I can't see the point in mucking around doing extra function calls.

P.S. What can I say. I am just a hobby programmer, who learned mostly by monkey see monkey do, and not a lot of theory involved, as most of it was beyond my understanding and went over my head. Over the years I have gradually picked up certain concepts etc, and still do. I've had no formal training anywhere in coding, and relatively speaking, started late in life. I've made various attempts to educate myself better, but not a lot stuck or was understood ... I'm a simple man who has a penchant for logic ... and not good at remembering names or numbers.

Edited by TheSaint

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...