Jump to content

Convert BitOR value


Recommended Posts

Hello community :D

If i have:

BitOR($SS_CENTER, $SS_CENTERIMAGE)

And i want to use it like a default parameter in a fuction, i think i need to set the "numeric" value like:

Func Test1($param, $param2, $style = 0x00000000) ; 0x00000000 = i need to set here BitOR($SS_CENTER, $SS_CENTERIMAGE)

How to convert the BitOR($variable1, $variable2) to his numeric value? Thanks

Edited by MyEarth
Link to comment
Share on other sites

Check this out

#include <StaticConstants.au3>

ConsoleWrite(BitOR($SS_CENTER, $SS_CENTERIMAGE) & @CRLF)

Func A( $iDefault = 513 )
;The Default value is hard-coded by reading the console.
EndFunc

Func B( $iDefault = -1 )
;Assign the Default value of the variable to anything that is obvious would not be passed by the user.
;Now Direct way
If $iDefault = -1 Then $iDefault = BitOR($SS_CENTER, $SS_CENTERIMAGE)
EndFunc
Regards :)

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Link to comment
Share on other sites

  • Moderators

MyEarth,

Top Tip: Avoid "magic numbers" and use the full descriptive version of the constants as you have been advised above. You will be grateful when you look at the script after a few months (or even days)! ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Perhaps it's a personal thing, but I often find it easier to read the binary rather than constant names. I sometimes prefer to use separate numeric values and BitOR them together in the code, rather than using magic numbers. This way I can see exactly what value is being passed as a parameter. I'm not too keen on having multiple ways of expressing: 0, 1, 2, 4, 8 etc... This isn't always the case and I mix and match methods depending on the situation: trying to get the best of all worlds.

Edited by czardas
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...