Page 1 of 1
Special constants in source code to be passed to compiler
Posted: Sat Jan 19, 2013 12:41 am
by Techie42
Hi,
I know we can define constants within the "compiler options" area for use within compiler directives in source code, but I believe it may also be useful to be able to define special constants within the source for use within the "compiler options" area (the reverse direction of what we have now).
For example, I would like to be able to add something like the following to the head of my source code:
Code: Select all
#VERSION_MAJOR = 1
#VERSION_MINOR = 0
#VERSION_BUILD = 7
#VERSION_REVISION = 17
#VERSION_SPECIAL_MAJOR = 1
#VERSION_SPECIAL_MINOR = 2
; and so on ...
Then, I would like to be able to use these special constants in the "version info" area, in much the same way as the existing tokens %COMPILECOUNT and %BUILDCOUNT, e.g. %VERSION_MAJOR,%VERSION_MINOR, etc...
If any files are included that also define the same constants, then a compile-time error could be generated - duplicate definition.
This would permit easier version numbering within our source code, and so would be more likely to be kept up-to-date. The current facility is slightly long-winded in terms of ease of use, especially when compiling alternative versions such as special or private builds.
I hope what I am saying makes sense

Re: Special constants in source code to be passed to compile
Posted: Sat Jan 19, 2013 1:43 am
by skywalk
Yeah, it would be cool if we could edit these constants directly in the code, instead of a constrained gui.
Code: Select all
; ...located at bottom of source code.
; IDE Options = PureBasic 5.00 (Windows - x86)
; ExecutableFormat = Shared Dll
; CursorPosition = 5458
; FirstLine = 5419
; Folding = ----------------
; Executable = my.dll
; CurrentDirectory = C:\myapp\
; CompileSourceDirectory
; IncludeVersionInfo
; VersionField0 = 13.01.18.0
; VersionField1 = 13.01.18.0
; VersionField2 = YourCompany
; VersionField3 = my.dll
; VersionField4 = 13.01.18
; VersionField5 = 13.01.18
; VersionField6 = Your Description
; VersionField7 = my.dll
; VersionField9 = YourCompany
; VersionField10 = YourCompany
; VersionField13 = you@YourCompany.com
; VersionField14 = www.YourCompany.com
; VersionField17 = 0409 English (United States)
Re: Special constants in source code to be passed to compile
Posted: Sat Jan 19, 2013 3:07 am
by IdeasVacuum
...outside of the PB IDE you can do that of course (I use Ultra Edit for my coding)
Re: Special constants in source code to be passed to compile
Posted: Sat Jan 19, 2013 10:25 pm
by Franky
+1
Being able to change those within the PureBasic Source would be good especially because you would be able to use these information for About-Boxes.
There's nothing worse than different VersionInformation in 2 Places, some people want to kill poor programmers like us for such things
Best regards
Franky
Re: Special constants in source code to be passed to compile
Posted: Sat Oct 19, 2013 10:31 am
by Korolev Michael
+1, current solution is not flexible
Re: Special constants in source code to be passed to compile
Posted: Sat Oct 19, 2013 6:28 pm
by skywalk
Yes, there is a mix of goodies like /initial editor conditions/compiler paths/Version info/etc.
A workaround is to write a Tool that:
1) save your code
2) close your file
3) open your file in memory
4) append your desired values below
5) save the file
6) reopen file
7) compile
Currently, I let the IDE auto increment my version fields by date.
If I need better resolution than %dd, I manually edit. But that is rare.
Code: Select all
; IDE Options = PureBasic 5.20 LTS (Windows - x86)
; ExecutableFormat = Shared Dll
; CursorPosition = 66
; FirstLine = 44
; Folding = --------------------------
; Markers = 9467,9662,9818,9872
; Executable = my.dll
; CurrentDirectory = C:\myapp\
; CompileSourceDirectory
; IncludeVersionInfo
; VersionField0 = %yy,%mm,%dd,0
; VersionField1 = %yy,%mm,%dd,0
; VersionField2 = MyCo
; VersionField3 = myapp.dll
; VersionField4 = %yy.%mm.%dd
; VersionField5 = %yy.%mm.%dd
; VersionField6 = my description
; VersionField7 = my internal name
; VersionField9 = my copyright
; VersionField10 = my trademark
; VersionField13 = me@my.com
; VersionField14 = www.my.com
; VersionField17 = 0409 English (United States)
Re: Special constants in source code to be passed to compile
Posted: Thu May 31, 2018 3:23 pm
by Kwai chang caine
SkyWalk wrote:Yeah, it would be cool if we could edit these constants directly in the code, instead of a constrained gui.
+1
I have search today this option...and apparently that always not exist in 2018

Re: Special constants in source code to be passed to compile
Posted: Thu May 31, 2018 3:44 pm
by Josh
Kwai chang caine wrote:SkyWalk wrote:Yeah, it would be cool if we could edit these constants directly in the code, instead of a constrained gui.
+1
I have search today this option...and apparently that always not exist in 2018

Do you mean constants like this?
Code: Select all
#PB_Editor_FileVersionNumeric
#PB_Editor_ProductVersionNumeric
#PB_Editor_CompanyName
#PB_Editor_ProductName
#PB_Editor_ProductVersion
#PB_Editor_FileVersion
#PB_Editor_FileDescription
#PB_Editor_InternalName
#PB_Editor_OriginalFilename
#PB_Editor_LegalCopyright
#PB_Editor_LegalTrademarks
#PB_Editor_PrivateBuild
#PB_Editor_SpecialBuild
#PB_Editor_Email
#PB_Editor_Website
Re: Special constants in source code to be passed to compile
Posted: Thu May 31, 2018 4:05 pm
by Kwai chang caine
Hello JOSH
Yes i have found it now, i'm really happy

, but sad few seconds later
Because this CONSTANT is apparently ReadOnly, i don't understand why
If you enter a value to them you have the debug
Code: Select all
#PB_Editor_FileVersionNumeric = "1.1.1.1"
#PB_Editor_ProductVersionNumeric = "1.1.1.1"
#PB_Editor_CompanyName = "kkkk"
#PB_Editor_ProductName = "oooo"
#PB_Editor_ProductVersion = "pppp"
#PB_Editor_FileVersion = "5555"
#PB_Editor_FileDescription = "6666"
#PB_Editor_InternalName = "juiyt"
#PB_Editor_OriginalFilename = "fffff"
#PB_Editor_LegalCopyright = "oiuty"
#PB_Editor_LegalTrademarks = "ggggg"
#PB_Editor_PrivateBuild = "xxxxx"
#PB_Editor_SpecialBuild = "wwwww"
#PB_Editor_Email = "zzzzzz"
#PB_Editor_Website = "aaaaaaa"
Debug #PB_Editor_FileVersionNumeric
Debug #PB_Editor_ProductVersionNumeric
Debug #PB_Editor_CompanyName
Debug #PB_Editor_ProductName
Debug #PB_Editor_ProductVersion
Debug #PB_Editor_FileVersion
Debug #PB_Editor_FileDescription
Debug #PB_Editor_InternalName
Debug #PB_Editor_OriginalFilename
Debug #PB_Editor_LegalCopyright
Debug #PB_Editor_LegalTrademarks
Debug #PB_Editor_PrivateBuild
Debug #PB_Editor_SpecialBuild
Debug #PB_Editor_Email
Debug #PB_Editor_Website
If you compile, this CONSTANT is not sending to the compiler
The EXE not have the information in the windows explorer
Apparently only the value writing in the compiler panel is using

Or obviously if you modify the IDE file
Code: Select all
; IDE Options = PureBasic 5.61 (Windows - x86)
; CursorPosition = 3
; FirstLine = 1
; Folding = -
; Executable = PbExe.exe
; CompileSourceDirectory
; DisableCompileCount = 32
; IncludeVersionInfo
; VersionField0 = 1.1.1.1
; VersionField1 = 1.2.33.44
; VersionField2 = aaaaaaaaaaaa
; VersionField3 = zzzzzzzzzzzzz
; VersionField4 = eeeeeeeeeeeee
; VersionField5 = rrrrrrrrrrrrrr
; VersionField6 = tttttttttttttttttttt
; VersionField7 = yyyyyyyyyyyyyyyyyyy
; VersionField8 = uuuuuuuuuuuuuuuuuuu
; VersionField9 = iiiiiiiiiiiiiiiii
; VersionField10 = oooooooooooooooo
; VersionField11 = pppppppppppppppppppppp
; VersionField12 = qqqqqqqqqqqqq
; VersionField13 = sssssssssssssssss
; VersionField14 = dddddddddddddddddd
; VersionField18 = cacahuette
; VersionField19 = Kepi
; VersionField20 = couette
; VersionField21 = ffffffffffff
; VersionField22 = ggggggggggggg
; VersionField23 = hhhhhhhhhhhhh
Re: Special constants in source code to be passed to compile
Posted: Fri Jun 01, 2018 12:58 pm
by Kwai chang caine
Please FRED, can you tell me if it's a choice to not allow modify this constant in the code
Or it's because it's impossible to do ?
Re: Special constants in source code to be passed to compile
Posted: Fri Jun 08, 2018 11:07 am
by Mindphazer
Kwai chang caine wrote:Please FRED, can you tell me if it's a choice to not allow modify this constant in the code
Or it's because it's impossible to do ?
These constants are the result of what is set in the IDE. So you can't modify them, you can only read them
Re: Special constants in source code to be passed to compile
Posted: Fri Jun 08, 2018 5:27 pm
by Kwai chang caine
Hello Mindphazer
Yes, i have understand that, but you believe it's a choice of FRED or it's really impossible to do, even if FRED have wanted to adding this fonction ?