Page 1 of 1

Dual Support PB604 and PB610 Identification

Posted: Tue Apr 02, 2024 2:55 pm
by dfw1417
I have a program developed originally on the 32 bit versions currently working well and also same source compiles and runs well on 6.10 version. I have placed the 32 bit version in PBUNI604 folder and the 64 bit version in PBUNI610 folder. The program is a project and is setup so that no compiler info is saved or stored once compiled in the project. I want to continue developing these as 32 and 64 bit versions as clones of each other. What I want to do now is find a way to adjust an added string content to reflect whether the program when running is the 32 bit version or the 64 bit version and I would like to do it dynamically. In other words I dont want to manually assign "32" to the string and "64" to the same string based upon which version I am running because then the source codes for each project would not be the same. I want a way using the same source code to be able to identify and adjust programatically when run the string contents to either "32" or "64" to reflect which version 32 or 64 is running. Something similar to the CompileIf but just identifying 32 or 64 bit version. I was thinking along the lines of code which throws an error in the 64 bit version but not in the 32 bit version when the program starts up which then adjusts the string contents based on the On Error Syntax. Is there an easy way to do this? My main objective is that the source code in the project must remain the exact same for both 32 and 64 bit versions to make support and development fluid and easy. Thanks in advance for any thoughts.

Re: Dual Support PB604 and PB610 Identification

Posted: Tue Apr 02, 2024 3:07 pm
by jacdelad
Hi,
if I understand your request right, you can use the system constant #PB_Processor_x64:

Code: Select all

CompilerSelect #PB_Compiler_Processor
  CompilerCase #PB_Processor_x64
    #MyConst$ = "x64"
  CompilerCase #PB_Processor_x86
    #MyConst$ = "x86"
  CompilerCase #PB_Processor_Arm32
    #MyConst$ = "ARM32"
  CompilerCase #PB_Processor_Arm64
    #MyConst$ = "ARM64"
  CompilerDefault
    #MyConst$ = "Uh, oh..."
CompilerEndSelect
Debug #MyConst$

Re: Dual Support PB604 and PB610 Identification

Posted: Tue Apr 02, 2024 3:07 pm
by mk-soft

Code: Select all

CompilerSelect #PB_Compiler_Processor
  CompilerCase #PB_Processor_x86
    #RTProcessor = "x86"
  CompilerCase #PB_Processor_x64
    #RTProcessor = "x64"
  CompilerCase #PB_Processor_Arm32
    #RTProcessor = "arm32"
  CompilerCase #PB_Processor_Arm64
    #RTProcessor = "arm64"
CompilerEndSelect

Debug #RTProcessor

Re: Dual Support PB604 and PB610 Identification

Posted: Tue Apr 02, 2024 4:44 pm
by Michael Vogel
Brute short version... :lol:

Code: Select all

a=(#PB_Compiler_Processor-1)/2
Debug Mid("ARMX",(~a&2)<<1,3) + Str(32<<Bool(a%3))

Re: Dual Support PB604 and PB610 Identification

Posted: Tue Apr 02, 2024 4:48 pm
by Kiffi
Michael Vogel wrote: Tue Apr 02, 2024 4:44 pmBrute short version... :lol:

Code: Select all

a=(#PB_Compiler_Processor-1)/2
Debug Mid("ARMX",(~a&2)<<1,3) + Str(32<<Bool(a%3))
:shock:

Re: Dual Support PB604 and PB610 Identification

Posted: Tue Apr 02, 2024 5:12 pm
by Quin
Michael Vogel wrote: Tue Apr 02, 2024 4:44 pm Brute short version... :lol:

Code: Select all

a=(#PB_Compiler_Processor-1)/2
Debug Mid("ARMX",(~a&2)<<1,3) + Str(32<<Bool(a%3))
Wow. I didn't think it was possible to code golf in PB like that :D. Good job!

Re: Dual Support PB604 and PB610 Identification

Posted: Tue Apr 02, 2024 5:29 pm
by dfw1417
Thanks All :lol:

Re: Dual Support PB604 and PB610 Identification

Posted: Wed Apr 03, 2024 2:06 pm
by blueb

Code: Select all

;Is 32/64Bit
If SizeOf(Integer) = 8
     Debug "64-bit system (x64)"
ElseIf SizeOf(Integer) = 4
     Debug "32-bit system (x86)"
Else 
     Debug "Something wrong here."
EndIf


Re: Dual Support PB604 and PB610 Identification

Posted: Wed Apr 03, 2024 3:05 pm
by Fred
#PB_Compiler_64Bit can be used for this:

Code: Select all

Debug #PB_Compiler_64Bit

Re: Dual Support PB604 and PB610 Identification

Posted: Thu Apr 04, 2024 3:12 pm
by Blue
Michael Vogel wrote: Tue Apr 02, 2024 4:44 pm Brute short version... :lol:

Code: Select all

a=(#PB_Compiler_Processor-1)/2
Debug Mid("ARMX",(~a&2)<<1,3) + Str(32<<Bool(a%3))
😳🤓👍
I’m in awe… but
Fred wrote: Wed Apr 03, 2024 3:05 pm #PB_Compiler_64Bit can be used for this:

Code: Select all

Debug #PB_Compiler_64Bit
So simple and, especially, so much clearer.

Re: Dual Support PB604 and PB610 Identification

Posted: Thu Apr 04, 2024 4:18 pm
by Quin
Blue wrote: Thu Apr 04, 2024 3:12 pm
Michael Vogel wrote: Tue Apr 02, 2024 4:44 pm Brute short version... :lol:

Code: Select all

a=(#PB_Compiler_Processor-1)/2
Debug Mid("ARMX",(~a&2)<<1,3) + Str(32<<Bool(a%3))
😳🤓👍
I’m in awe… but
Fred wrote: Wed Apr 03, 2024 3:05 pm #PB_Compiler_64Bit can be used for this:

Code: Select all

Debug #PB_Compiler_64Bit
So simple and, especially, so much clearer.
True, unless you want to tell more than just 32 or 64-bit. Michael's method can also tell you ARM/ARM64

Re: Dual Support PB604 and PB610 Identification

Posted: Thu Apr 04, 2024 5:50 pm
by Michael Vogel
Endless variations are possible... :wink:

Code: Select all

CompilerIf #PB_Compiler_Version<600
	Debug Mid("ARMX",Bool(#PB_Compiler_Processor&6-6)<<2,3) + Str(32<<Bool(#PB_Compiler_Processor&$D=4))
CompilerElse
	Debug Mid("ARMX",Bool(#PB_Compiler_Processor&6-6)<<2,3) + Str(32<<#PB_Compiler_64Bit)
CompilerEndIf

Re: Dual Support PB604 and PB610 Identification

Posted: Thu Apr 04, 2024 5:55 pm
by Blue
Michael Vogel wrote: Thu Apr 04, 2024 5:50 pm Endless variations are possible... :wink:
[…]
oh yes.
Endless obfuscations too.
But, as i commented above, I’m still in awe of the intellectual contorsions.
It takes a code acrobat to come up with something like this, and I’ve always envied acrobats.

Re: Dual Support PB604 and PB610 Identification

Posted: Sun Apr 07, 2024 1:56 pm
by Jeromyal
Blue wrote: Thu Apr 04, 2024 5:55 pm
Michael Vogel wrote: Thu Apr 04, 2024 5:50 pm Endless variations are possible... :wink:
[…]
oh yes.
Endless obfuscations too.
But, as i commented above, I’m still in awe of the intellectual contorsions.
It takes a code acrobat to come up with something like this, and I’ve always envied acrobats.
Does being skilled at inserting a foot in own ones mouth count? There are days I could put on a great act.

Code: Select all

"Foot in one's mouth" is an idiom that means to say something foolish, embarrassing, or tactless. For example, "Jane put her foot in her mouth when she called him by her first husband's name". This idea is sometimes expressed as having "foot-in-mouth disease". "Foot-in-mouth disease" is an informal, facetious term for the habit of making inappropriate, insensitive, or imprudent statements.

Re: Dual Support PB604 and PB610 Identification

Posted: Wed Apr 17, 2024 3:33 pm
by Blue
Jeromyal wrote: Sun Apr 07, 2024 1:56 pm [...]
Does being skilled at inserting a foot in own ones mouth count? There are days I could put on a great act.
[…]
Are you saying you're agile at putting your foot in your mouth ? :shock:
That would certainly count... however you do it. :lol:
We run a club for that. You could join.