Compiling and save bug / error

Post bugs related to the IDE here
User avatar
bfernhout
Enthusiast
Enthusiast
Posts: 123
Joined: Mon Feb 26, 2018 10:41 pm
Location: Netherlands
Contact:

Compiling and save bug / error

Post by bfernhout »

I did post it also in the ide Forum and notice that it was the wrong forum place. (Sorry)

Its actually not a real bug.

I encouter a problem by accident.
When i compile a source code and enter the name of the source code, the file is compiled correctly and saved as a exe.
But than i made a little change in the program to test something. No problem. Then i compile the code again to get a exe. By not noticing i saw the name and hit save.
Here is the problem. Normally a program that has to override an already existed program, needs to ask the user if its okay to override the already existed program.
PureBasic compiler(saver) do not ask this. The file is overwritten without asking.

Mainly this is no problem. But in my case it was. cause i wanted the keep the original and use a test file for testing.

So my question is !! can this corrected.
Trying to override a source PB is comming with the questing for overriding the previous file.

thanks
From my first self made computer till now I stil like computers.
User avatar
chi
Addict
Addict
Posts: 1028
Joined: Sat May 05, 2007 5:31 pm
Location: Linz, Austria

Re: Compiling and save bug / error

Post by chi »

bfernhout wrote:So my question is !! can this corrected.
Trying to override a source PB is comming with the questing for overriding the previous file.
An easy way would be to write a little program yourself and place it under "Tools" (Configure Tools...) and trigger it with "Before Create Executable".

Code: Select all

exe$ = GetEnvironmentVariable("PB_TOOL_Executable")

If FileSize(exe$) > -1
  If MessageRequester("File already exists!", exe$ + #LFCR$ + #LFCR$ + "Do you want to rename the original file?", #PB_MessageRequester_YesNo|#PB_MessageRequester_Info) = #PB_MessageRequester_Yes
    RenameFile(exe$, GetPathPart(exe$) + GetFilePart(exe$) + "_orig." + GetExtensionPart(exe$))
  EndIf
EndIf
[/size]
Et cetera is my worst enemy
User avatar
bfernhout
Enthusiast
Enthusiast
Posts: 123
Joined: Mon Feb 26, 2018 10:41 pm
Location: Netherlands
Contact:

Re: Compiling and save bug / error

Post by bfernhout »

That is the easy way. But then I have to do it on every program i start writing.

For me it's much easier when the program IDE is reacting on it.
Why is it working when i try to overwrite the source code
and not the exe.
From my first self made computer till now I stil like computers.
Axolotl
Enthusiast
Enthusiast
Posts: 435
Joined: Wed Dec 31, 2008 3:36 pm

Re: Compiling and save bug / error

Post by Axolotl »

Hi bfernhout

I replied to you other post already, anyways here is my opinion on this topic.

I understand your point, but I would like to describe my way of compile and test process.

I always use Compiler | Compile/Run (F5) to test my code.
After all testing is done I use Compiler | Create Executable ...

So I do not have the problem you described with the existing behavior.
And I can see the existing executable in the save dialog as well.

Happy Coding and Stay healthy.
Mostly running PureBasic <latest stable version and current alpha/beta> (x64) on Windows 11 Home
BarryG
Addict
Addict
Posts: 3292
Joined: Thu Apr 18, 2019 8:17 am

Re: Compiling and save bug / error

Post by BarryG »

bfernhout wrote:then I have to do it on every program i start writing
What? No you don't. I don't think you understand what chi's code does. It works for every exe you create, anytime that you start writing. It's all automatic.

Note: The only thing Chi forgot to mention is that you also need to turn on "Wait until tool quits" for the tool setting. So the tool should look like below.

This is something that should be built-in as an optional setting, though; if someone wants to edit it into the IDE source code (hint, hint).

Image
User avatar
chi
Addict
Addict
Posts: 1028
Joined: Sat May 05, 2007 5:31 pm
Location: Linz, Austria

Re: Compiling and save bug / error

Post by chi »

Yes, the "Wait until tool quits" is important for the tool to work... Forgot to mention that.

Also, instead of "_orig." it might be better to use something like this:

Code: Select all

"_" + FormatDate("%yy%mm%dd%hh%ii%ss", Date()) + "."
[/size]
Et cetera is my worst enemy
User avatar
bfernhout
Enthusiast
Enthusiast
Posts: 123
Joined: Mon Feb 26, 2018 10:41 pm
Location: Netherlands
Contact:

Re: Compiling and save bug / error

Post by bfernhout »

Thank all for the good reply.

To Axolotl i think is missed the point here. What i did not mentioned was that when i had done a code and its complete i compile it. Then when there are updates to the program and after checking with the compile/run option. i check the program again. But then i am ready and want to create another exe. Then on that moment i hit save, but forgot to change the name. So my earlyer version is now gone. That is actually my problem. On that occasion i like to have the question to overwrite the file.

Sorry that I was not that clear abaut it.

But Chi and BarryG did give me the solution for this problem.
Thanks all.

Bart.
From my first self made computer till now I stil like computers.
User avatar
bfernhout
Enthusiast
Enthusiast
Posts: 123
Joined: Mon Feb 26, 2018 10:41 pm
Location: Netherlands
Contact:

Re: Compiling and save bug / error

Post by bfernhout »

He Chi Yuor idea is beter. Thanks.
From my first self made computer till now I stil like computers.
Axolotl
Enthusiast
Enthusiast
Posts: 435
Joined: Wed Dec 31, 2008 3:36 pm

Re: Compiling and save bug / error

Post by Axolotl »

bfernhout wrote:Thank all for the good reply.

To Axolotl i think is missed the point here. What i did not mentioned was that when i had done a code and its complete i compile it. Then when there are updates to the program and after checking with the compile/run option. i check the program again. But then i am ready and want to create another exe. Then on that moment i hit save, but forgot to change the name. So my earlyer version is now gone. That is actually my problem. On that occasion i like to have the question to overwrite the file.

Sorry that I was not that clear abaut it.

But Chi and BarryG did give me the solution for this problem.
Thanks all.

Bart.
Hi Bart,
mostly it's me and my lack of understanding of the questions.
I have already had the experience myself. In the 'Create Executable Dialog' I changed the already existing executable file before I created the new one by OK.
Anyways, building your own tool and including it is of course much more elegant.
I am glad the other guys could help. (i am just the moral support)
Have fun and stay healthy
Mostly running PureBasic <latest stable version and current alpha/beta> (x64) on Windows 11 Home
User avatar
chi
Addict
Addict
Posts: 1028
Joined: Sat May 05, 2007 5:31 pm
Location: Linz, Austria

Re: Compiling and save bug / error

Post by chi »

Glad we could help ;)
Et cetera is my worst enemy
Post Reply