Jump to content

How to use flags in my own UDFs?


Go to solution Solved by Melba23,

Recommended Posts

Posted

I like the way flags are utilized in AutoIT functions, e.g. stringstripWS("text",flag).  I'm guessing there's a bitwise check on the supplied flag value.

Is there a good example of how to utilize that in my own UDFs?

Posted

BitAND is the clue.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

  • Moderators
  • Solution
Posted

SlowCoder74,

Look at my ChooseFileFolder UDF - the _CFF_Check_Display function does that sort of thing using BitAnd. :)

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:

  Reveal hidden contents

 

Posted

Though there are tricks, classic ASP doesn't internally allow optional arguments.  Flags have been a great way to maintain compatibility with my ASP projects while adding functionality to the subs/functions themselves.

In ASP and VBScript I've used "flags" in a different way, by setting up a string argument with possible values like "[Opt1][Opt2][Opt3]", where each of the "[Optx]" parts was a "flag".  In one way, it makes it fairly easy to add functionality to the subs/functions, and also makes the arguments easily readable.  The downside of using these types of flags, is that if you are supplying a large number of options/flags, the call to the procedure can be long enough to cause readability problems, especially if you are nesting multiple procedures.

e.g. x=ShowNameParts("[Last][First][Middle]")

With the numeric flags, readability of the actual options is decreased, but readability of the line is better.

e.g. x=ShowNameParts(7)

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...