GodForsakenSoul Posted July 29, 2009 Share Posted July 29, 2009 (edited) i'm having small trouble understanding this particular line of the TCP server made by sloppyprogrammer (or... something like that). If $pack <> "" Then _payload($pack) ; open them and check if they are empty. If they are NOT empty, run the payload function. for me it looks like if $pack IS empty, then do _payload. where is the NOT part? ^UNDERSTOOD^ vANSWER THIS NOW PLEASEv also, instead of making two topics, i couldn't find an explanation in the help file about the variable in the (). couldn't anyone explain this? edit: perhaps i'll understand better with some code included. Edited July 29, 2009 by GodForsakenSoul Link to comment Share on other sites More sharing options...
oMBRa Posted July 29, 2009 Share Posted July 29, 2009 If $pack <> ""if $pack is not equal to "", that is, if its not empty then... Link to comment Share on other sites More sharing options...
Valuater Posted July 29, 2009 Share Posted July 29, 2009 You are saying.. If $pack is 'different' than "" then... do this You can use If statements anywhere If Not $Pack = "10" then... do something It will not do anything if $pack = "10" otherwise, it will do something Hope that helps See If, Then, Else in help 8) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 29, 2009 Moderators Share Posted July 29, 2009 GodForsakenSoul,The statement 'If $pack <> "" ' Then translates as 'If $pack is not equal to an empty string'. So if $pack is not an empty string, the _payload function is run.The variable $pack in parentheses behind the _payload function is a parameter being passed to the function. Look in the Help file under 'AutoIt -> Function Reference -> Function Notes'.I hope that clears up any misunderstanding.M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
GodForsakenSoul Posted July 29, 2009 Author Share Posted July 29, 2009 om... thank you for the explanation about the <> part. however, i'm having trouble understanding the function notes. i mean literally. english is not my first language, so if they DO provide an explanation, it's too subtle for me to understand. please try to explain it in your own words. preferably, as if you were explaining this to a complete idiot. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 30, 2009 Moderators Share Posted July 30, 2009 GodForsakenSoul,Here goes:All the following assumes you are in GUIGetMsg mode.Firstly, a short excursion to explain the idea of Global/Local variables.- Any variable that is set (that is given a value: $variable = something) in the main part of the script is automatically a Global variable and available to any other function within the script.- Any variable that is set in a function is automatically a Local variable and is lost when the function ends.- This can be overidden by the Global/Local keywords, but ignore that for a moment.Now we have that squared away, let us discuss variables within functions. Good programming practise is to code in modules - that is using standard blocks of code which can be easily reused. An example would be the following:; This is not working code! Func _Double() $Input = $Input * 2 EndFuncNow as it stands that function is pretty useless as although it doubles $Input, there is no way for it to know what value it is to double! Furthermore, the $Input variable is Local and will be lost when the function ends! We need to tell the function the initial value. We can do this in 2 ways:1. Make a Global variable $Input which is available to the function.2. Pass a parameter to the function when we call it.Option 1 has some disadvantages - not least the need to use the same name for every variable we need to double! Option 2 allows you to use the same function for many different variables - all we have to do is tell the function what to double when we call it - and get the function to return the new value once it has been calculated:$var1 = 1 $var1 = _Double($var1) ConsoleWrite($var1 & @CRLF) $var2 = 10 $var2 = _Double($var2) ConsoleWrite($var2 & @CRLF) Func _Double($Input) $Input = $Input * 2 Return $Input EndFuncNow the function knows what it has to double and the main code gets the new value returned - and the same function doubled both variables. That is the modular bit - you can reuse the function many times in many scripts without changing it!There are a couple of other points to remember about parameters.1. The function can preset a default value for a parameter - this way you can have extended options for the function which you do not have to set if you only require a basic version. An simple example is the _SoundPlay function in the Sound.au3 UDF. If you look in the Help file you will see:_SoundPlay ( $sSnd_id [, $fWait ] )Parameters$sSnd_id Sound ID (the 'alias') as returned by _SoundOpen or a file $fWait [optional] This flag determines if the script should wait for the sound to finish before continuing:1 = wait until sound has finished0 = continue script while sound is playing (default) If you were to look into the function itself you would see:Func _SoundPlay($aSndID, $iWait = 0)The function will automatically set $iWait to 0 unless that code specifically sets another value. The coder does not have to specify a value unless it is other than the default.2. A parameter can be passed using the keyword ByRef. This means that the function can alter the variable without having to return a value;$var1 = 1 $var3 = 100 $var1 = _Double($var1, $var3) ConsoleWrite($var1 & @CRLF & $var3 & @CRLF) Func _Double($Input_A, $Input_B) $Input_A = $Input_A * 2 $Input_B = 200 Return $Input_A EndFunc $var2 = 10 $var3 = 100 $var2 = _Triple($var2, $var3) ConsoleWrite($var2 & @CRLF & $var3 & @CRLF) Func _Triple($Input_A, ByRef $Input_B) $Input_A = $Input_A * 3 $Input_B = 300 Return $Input_A EndFuncHere we can see that in function _Double, $var3 is passed normally (technically known as By Value) and so when it is changed within the function, there is no change in the real variable - the change in value made within the function is lost when the function ends.However, in function _Triple, $var3 is passed ByRef (short for By Reference) and its real value is altered by the function.There you have function parameters in a nutshell. Play about with the 2 examples until you are happy with what is going on.Good luck!M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now