It is currently Sun Oct 22, 2017 6:09 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: #PB_Editor_CreateExecutable
PostPosted: Mon Mar 20, 2017 9:49 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat Feb 13, 2010 3:45 pm
Posts: 573
Can anybody say to me, why I have to activate #PB_Editor_CreateExecutable in Compiler-Options before using? Why is this constant not set by default, when I'm starting my program from Ide?

_________________
sorry for my bad english


Top
 Profile  
Reply with quote  
 Post subject: Re: #PB_Editor_CreateExecutable
PostPosted: Mon Mar 20, 2017 10:42 pm 
Offline
Addict
Addict
User avatar

Joined: Mon Jul 25, 2005 3:51 pm
Posts: 3420
Location: Utah, USA
Josh wrote:
Can anybody say to me, why I have to activate #PB_Editor_CreateExecutable in Compiler-Options before using? Why is this constant not set by default, when I'm starting my program from Ide?

I imagine that one of the reasons is that you have to name the executible that is created and where it will be written (I think these can be set as a part of projects). Also, when you are creating the executible you don't usually want to execute it at the same time, it may be part of a group of other files that all need to be produced (i.e. assembled, compiled, etc.) before being used.

Testing and debugging a source code is far more common than creating a final executible.

_________________
Image


Top
 Profile  
Reply with quote  
 Post subject: Re: #PB_Editor_CreateExecutable
PostPosted: Mon Mar 20, 2017 11:14 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat Feb 13, 2010 3:45 pm
Posts: 573
Demivec wrote:
Testing and debugging a source code is far more common than creating a final executible.

As far as I know, this compiler-option does nothing other, than it makes the constant #PB_Editor_CreateExecutable disposable for the compiler. There is no executable created or not, if this constant is set or not.

_________________
sorry for my bad english


Top
 Profile  
Reply with quote  
 Post subject: Re: #PB_Editor_CreateExecutable
PostPosted: Tue Mar 21, 2017 12:22 am 
Offline
Addict
Addict
User avatar

Joined: Mon Jul 25, 2005 3:51 pm
Posts: 3420
Location: Utah, USA
Josh wrote:
Demivec wrote:
Testing and debugging a source code is far more common than creating a final executible.

As far as I know, this compiler-option does nothing other, than it makes the constant #PB_Editor_CreateExecutable disposable for the compiler. There is no executable created or not, if this constant is set or not.


I apologize, I misunderstood your question when I first read it and thought it was simply about the need to having a 'create executable' menu option.

Returning to your actual question, wouldn't the #PB_Editor_CreateExecutable constant be useful to allow a program to create code for test data or make logging options active if the program is not the final executable?

Perhaps something like this:
Code:
;If code is compiled without using the compiler option that creates
;the #PB_Editor_CreateExecutable constant it will set up code for
;logging data to either a file or the debugger window (based on the
;value of #UseDebugForLoggingFunctions).

;If the #PB_Editor_CreateExecutable constant is activated in the
;compiler options it will not include code for the logging
;functions and make them non-existent for the resulting executable.



CompilerIf Not Defined(PB_Editor_CreateExecutable, #PB_Constant)
  #PB_Editor_CreateExecutable = #False ;If not defined in compiler options or otherwise, set it to #False
CompilerEndIf

CompilerIf #PB_Editor_CreateExecutable = 1
 
  ;don't create logging code if this is an executable, create do-nothing substitutes instead
  Macro createLogFile(filename)
    0
  EndMacro
  Macro logToFile(fileID, text)
  EndMacro
  Macro closeLogFile(fileID)
  EndMacro 
 
CompilerElse
 
  #UseDebugForLoggingFunctions = #True ; set to #False to use file output, #True = debugger output window
 
  ;create logging functions
  Procedure createLogFile(filename.s)
    CompilerIf #UseDebugForLoggingFunctions
      a = -1
    CompilerElse
      a = OpenFile(#PB_Any, filename)
    CompilerEndIf
   
    If Not a
      MessageRequester("Error", "Couldn't create log file.")
    EndIf
    ProcedureReturn a
  EndProcedure
 
  Procedure logToFile(fileID, text.s)
    If fileID = -1
      Debug Str(fileID) + ": " + text.s
    Else
      WriteStringN(FileID, text)
    EndIf
  EndProcedure
 
  Procedure closeLogFile(fileID)
    If IsFile(fileID)
      CloseFile(fileID)
    EndIf
  EndProcedure

CompilerEndIf

Define fileID = createLogFile("J:\filename.log") ;0 = function not available

For i = 1 To 10
  logToFile(fileID, "Line #" + i)
  ;some processing functions
Next

closeLogFile(fileID)


If code is compiled without using the compiler option that creates the #PB_Editor_CreateExecutable constant it will set up code for logging data to either a file or the debugger window (based on the value of #UseDebugForLoggingFunctions).

If the #PB_Editor_CreateExecutable constant is activated in the compiler options it will not include code for the logging functions and make them non-existent for the resulting executable.

In any case there are 3 distinct compiling choices: one for debugging, one for testing and one for the final executable. This constant helps distinguish between the two that are not debugging options.

I agree that it may be better to simply replace it with a compiling constant that is always available. It should only depend on if it is possible to always know if something is a final executable or not when it is being compiled.

_________________
Image


Top
 Profile  
Reply with quote  
 Post subject: Re: #PB_Editor_CreateExecutable
PostPosted: Tue Mar 21, 2017 1:56 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat Feb 13, 2010 3:45 pm
Posts: 573
Hohoho, you are really, really near to my current project. I have three states too:

1) #IsSimModeRunning = #True (is equivalent to #PB_Editor_CreateExecutable = #False, only a better understandable name)
2) #IsSimModeRunning = #False (is equivalent to #PB_Editor_CreateExecutable = #True, only a better understandable name)
3) #CompileFinalExe, this constant I have set in my code at the absolute top. In this case, no SimMode, no Logfile, no additional checks in code and some other stuff is not created.

Like you described, I could set my third state in the compiler-options, but I think, I w'ont, because in 2 years I'm looking annoyed what I have created there and don't think at the small check-box-tick. Probably I will create a project with two destinations, than is all clear in 5 years too.

But back to the topic:
I think, the checkbox in compiler-options for #PB_Editor_CreateExecutable is useless and confusing. The same is with #PB_Editor_BuildCount and #PB_Editor_CreateExecutable at the same place in compileroptions. I don't see no reason why here must be a checkbox.

_________________
sorry for my bad english


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye