Dual Support PB604 and PB610 Identification

Just starting out? Need help? Post your questions and find answers here.
dfw1417
User
User
Posts: 16
Joined: Tue Mar 01, 2022 1:45 am

Dual Support PB604 and PB610 Identification

Post 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.
Experience is what you get when you didn't get what you thought you wanted!
Acer TC895 32gb i5-2.9ghz Win10 1.5tb ssd Asus Gsyn 4k and Vizio 1080 hd monitors.
User avatar
jacdelad
Addict
Addict
Posts: 1991
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: Dual Support PB604 and PB610 Identification

Post 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$
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
User avatar
mk-soft
Always Here
Always Here
Posts: 6201
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Dual Support PB604 and PB610 Identification

Post 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
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
Michael Vogel
Addict
Addict
Posts: 2797
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Re: Dual Support PB604 and PB610 Identification

Post 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))
User avatar
Kiffi
Addict
Addict
Posts: 1484
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: Dual Support PB604 and PB610 Identification

Post 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:
Hygge
Quin
Addict
Addict
Posts: 1122
Joined: Thu Mar 31, 2022 7:03 pm
Location: Colorado, United States
Contact:

Re: Dual Support PB604 and PB610 Identification

Post 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!
dfw1417
User
User
Posts: 16
Joined: Tue Mar 01, 2022 1:45 am

Re: Dual Support PB604 and PB610 Identification

Post by dfw1417 »

Thanks All :lol:
Experience is what you get when you didn't get what you thought you wanted!
Acer TC895 32gb i5-2.9ghz Win10 1.5tb ssd Asus Gsyn 4k and Vizio 1080 hd monitors.
User avatar
blueb
Addict
Addict
Posts: 1111
Joined: Sat Apr 26, 2003 2:15 pm
Location: Cuernavaca, Mexico

Re: Dual Support PB604 and PB610 Identification

Post 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

- It was too lonely at the top.

System : PB 6.21(x64) and Win 11 Pro (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
Fred
Administrator
Administrator
Posts: 18150
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Dual Support PB604 and PB610 Identification

Post by Fred »

#PB_Compiler_64Bit can be used for this:

Code: Select all

Debug #PB_Compiler_64Bit
User avatar
Blue
Addict
Addict
Posts: 964
Joined: Fri Oct 06, 2006 4:41 am
Location: Canada

Re: Dual Support PB604 and PB610 Identification

Post 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.
PB Forums : Proof positive that 2 heads (or more...) are better than one :idea:
Quin
Addict
Addict
Posts: 1122
Joined: Thu Mar 31, 2022 7:03 pm
Location: Colorado, United States
Contact:

Re: Dual Support PB604 and PB610 Identification

Post 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
User avatar
Michael Vogel
Addict
Addict
Posts: 2797
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Re: Dual Support PB604 and PB610 Identification

Post 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
User avatar
Blue
Addict
Addict
Posts: 964
Joined: Fri Oct 06, 2006 4:41 am
Location: Canada

Re: Dual Support PB604 and PB610 Identification

Post 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.
PB Forums : Proof positive that 2 heads (or more...) are better than one :idea:
Jeromyal
Enthusiast
Enthusiast
Posts: 216
Joined: Wed Jul 17, 2013 8:49 am

Re: Dual Support PB604 and PB610 Identification

Post 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.
User avatar
Blue
Addict
Addict
Posts: 964
Joined: Fri Oct 06, 2006 4:41 am
Location: Canada

Re: Dual Support PB604 and PB610 Identification

Post 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.

 
PB Forums : Proof positive that 2 heads (or more...) are better than one :idea:
Post Reply