Bitness Column

Discuss and share scripts and script files...
admin
Site Admin
Posts: 60288
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Bitness Column

Post by admin »

The new get("bitness") function can easily make a nice column:
ColumnBitness.png
ColumnBitness.png (46.12 KiB) Viewed 2179 times
Configuration in Configuration | Information | Custom Columns:
ColumnBitnessConf.png
ColumnBitnessConf.png (11.67 KiB) Viewed 2179 times

Code: Select all

$bits = get("bitness", <cc_item>);
if ($bits == 32) {
  return "32-bit";
} elseif ($bits == 64) {
  return "64-bit";
} else {
  return "unknown";
}

admin
Site Admin
Posts: 60288
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Bitness Column

Post by admin »

Changes in next beta:

Code: Select all

    * SC get("bitness"): Changed the return from numbers to a full string (not 
      translated by MSL so you know what to expect), and added 2 new cases so we 
      have 5 possible returns now:
        "16-bit"
        "32-bit"
        "64-bit"
        "64-bit Itanium"
        "(unknown)"
      Tip: In a Custom Column you can use this line in the Script field:
        return get("bitness", <cc_item>);
      Note that there is quite a number of file types that can have the 
      PE-format, not just EXE and DLL, for example: acm, ax, com, cpl, dat, dll, 
      drv, exe, iec, lrc, ocx, rll, rs, scr, tlb, tsp.

sl23
Posts: 223
Joined: 03 Feb 2015 23:34

Re: Bitness Column

Post by sl23 »

I've tried to adapt your code to show only 32, 64 or ? instead of 32-bit, 64-bit and unknown, but it doen't work.
Could I please get some help. I have searched the help file but don't really now what I'm looking for!
Thanks

Code: Select all

$bits = get("bitness", <cc_item>);
if ($bits == 32) {
  return "32";
} elseif ($bits == 64) {
  return "64";
} else {
  return "?";
}

highend
Posts: 13260
Joined: 06 Feb 2011 00:33

Re: Bitness Column

Post by highend »

get("bitness") returns a string instead of a number and your comparison does what?...
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

sl23
Posts: 223
Joined: 03 Feb 2015 23:34

Re: Bitness Column

Post by sl23 »

Thanks for your reply highend...
No worries, solved it:

Code: Select all

get("bitness", <cc_item>);
if ("bitness", <cc_item> == 32) {
  return "32";
} elseif ("bitness", <cc_item> == 64) {
  return "64";
} else {
  return "?";
}

highend
Posts: 13260
Joined: 06 Feb 2011 00:33

Re: Bitness Column

Post by highend »

No, you did not or aren't you recognizing that all files are now 32-bit, regardless if they are 64-bit ones?
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

sl23
Posts: 223
Joined: 03 Feb 2015 23:34

Re: Bitness Column

Post by sl23 »

Damn! ok. Would you please provide a non cryptic tip?

sl23
Posts: 223
Joined: 03 Feb 2015 23:34

Re: Bitness Column

Post by sl23 »

highend wrote: 01 Jun 2021 22:07 get("bitness") returns a string instead of a number and your comparison does what?...
But I already tried this:

Code: Select all

if ("bitness", <cc_item> == 32-bit) {
  return "32";
but I just get ? for everything!!!

Can you help please highend?

notabot
Posts: 59
Joined: 24 Feb 2021 12:34

Re: Bitness Column

Post by notabot »

I think you overlooked this post:
admin wrote: 28 Aug 2020 16:42

Code: Select all

* SC get("bitness"): Changed the return from numbers to a full string (not 
      translated by MSL so you know what to expect), and added 2 new cases so we 
      have 5 possible returns now:
        "16-bit"
        "32-bit"
        "64-bit"
        "64-bit Itanium"
        "(unknown)"
      Tip: In a Custom Column you can use this line in the Script field:
        return get("bitness", <cc_item>);
So get("bitness") no longer returns a number (64) , but a textstring ("64-bit").
Taht makes comparisons different.
Compare variable with a number: if ($variable == 123)
Compare variable with text: if ($variable == "some text")

If you only want to see 32-bit and 64-bit in the cusom column (so no 16-bit, 64-bit Itanium), you can use the following:

Code: Select all

$bits = get("bitness", <cc_item>);
if ($bits == "32-bit") {
  return "32-bit";
} elseif ($bits == "64-bit") {
  return "64-bit";
} else {
  return "unknown";
}
Same results, but less typing:

Code: Select all

$bits = get("bitness", <cc_item>);
if ($bits == "32-bit" OR $bits == "64-bit") {
  return $bits;
} else {
  return "unknown";
}


If you want to see all possible bitnesses (??):

Code: Select all

$bits = get("bitness", <cc_item>);
return $bits;

or even:

Code: Select all

return get("bitness", <cc_item>);

sl23
Posts: 223
Joined: 03 Feb 2015 23:34

Re: Bitness Column

Post by sl23 »

Thanks very much for your help.

I didn't overlook it, I just didn't understand it! :kidding:

So does a string need to be enclosed in double quotes then?

What I'm actually after is to show just 32 or 6I or ?, not the original text. I sort of got there, just need a little adjusting maybe?

Thanks

RalphM
Posts: 1929
Joined: 27 Jan 2005 23:38
Location: Cairns, Australia

Re: Bitness Column

Post by RalphM »

You could try something along the lines of:

Code: Select all

$bits = get("bitness", <cc_item>);
if (left($bits, 2) = "32") {
  return "32";
} elseif (left($bits, 2) = "64") {
  return "64";
} else {
  return "?";
}
Ralph :)
(OS: W11 22H2 Home x64 - XY: Current beta - Office 2019 32-bit - Display: 1920x1080 @ 125%)

highend
Posts: 13260
Joined: 06 Feb 2011 00:33

Re: Bitness Column

Post by highend »

@RalphM

Without a user defined function for left?
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

RalphM
Posts: 1929
Joined: 27 Jan 2005 23:38
Location: Cairns, Australia

Re: Bitness Column

Post by RalphM »

Well, I would have expected that scripting command to exist.
On double check I was wrong, so instead one could use:

Code: Select all

substr($bits, 0, 2)
.
Ralph :)
(OS: W11 22H2 Home x64 - XY: Current beta - Office 2019 32-bit - Display: 1920x1080 @ 125%)

sl23
Posts: 223
Joined: 03 Feb 2015 23:34

Re: Bitness Column

Post by sl23 »

Thank you for your help.

That doesn't work, unless I did it wrong?
Assume you meant this:

Code: Select all

$bits = get("bitness", <cc_item>);
if (substr($bits, 0, 2) = "32") {
  return "32";
} elseif (substr($bits, 0, 2) = "64") {
  return "64";
} else {
  return "?";
}

highend
Posts: 13260
Joined: 06 Feb 2011 00:33

Re: Bitness Column

Post by highend »

It doesn't work because it's NOT a comparison anymore...
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

Post Reply