Jump to content
Sign in to follow this  
sandman

How to set an optional variable in a UDF?

Recommended Posts

sandman

Hi,

I am making a UDF, and I want the $Port variable to be optional. If it is not specified elsewise, I want $Port to be 16384. I am pretty sure this is how you do it, but I want to make sure:

Func _TCPRespondScreenshot($File, $Address, $Port = 16384)

Also, a little side-question: Why do most UDFs have variables like $nFile, $nAddress, and things like that? Does this make a difference, or is it just a way to make it so the variables $File and $Address can still be used in the function for other things?

Thanks,

SANDMAN!


[center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center]

Share this post


Link to post
Share on other sites
GEOSoft

Hi,

I am making a UDF, and I want the $Port variable to be optional. If it is not specified elsewise, I want $Port to be 16384. I am pretty sure this is how you do it, but I want to make sure:

Func _TCPRespondScreenshot($File, $Address, $Port = 16384)

Also, a little side-question: Why do most UDFs have variables like $nFile, $nAddress, and things like that? Does this make a difference, or is it just a way to make it so the variables $File and $Address can still be used in the function for other things?

Thanks,

SANDMAN!

#1 - Yes

#2 - Yes


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites
sandman

Okay, thanks!

Edited by sandman

[center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center]

Share this post


Link to post
Share on other sites
SpookMeister

Yep thats how its done, the only stipulation is that all parameters preceding the optional one must be specified.

And as to the UDF variables question, yes thats the reason as well


[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Share this post


Link to post
Share on other sites
DaleHohm

There is a document that describes the standards required for UDFs to be submitted to the formal districution here: http://www.autoitscript.com/autoit3/scite/...F_Standards.htm

This includes a description of variable naming conventions.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
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
Sign in to follow this  

×