Jump to content
Sign in to follow this  
czardas

Strange Syntax

Recommended Posts

This project is slowly progressing at the current rate of opportunity (the rover). I have wrapped all the functions I plan to use in cascading error code (cascading because it forces the failure of subsequent functions), which will (theoretically) enable up to as many nested functions as the AutoIt interpreter can handle (I don't know what the limit is for nested functions, but I imagine it's big). Ignore the error return values for now (they are irrelevant anyway and liable to change). The first function is shown below:

Global $_KickBack_ = 0 ; Cascading error count for nested functions

; #FUNCTION# ====================================================================================================================
; Name...........: _Abs
; Description ...: Returns absolute value of expression.
; Syntax.........: _Abs($nExpression)
; Parameters ....: $nExpression - Any valid numeric expression.
; Return values .: Success   - Returns absolute value.
;                Failure   - Sets @error and returns 'NaN'.
; Author ........: ???
; Modified.......: czardas
; Remarks .......: Also works with 32-bit integers in hex string format as in the example
; Related .......:
; Link ..........:
; Example .......: MsgBox(0, "_Abs", _Abs("FFFFFFF6")) ; Returns 10 because 0xFFFFFFF6 = -10
; ===============================================================================================================================

Func _Abs($nExpression)
    If $_KickBack_ > 0 Then Return SetError(1, __HardError(), "NaN") ; Cascading error

    ; Force numeric params - strict implimentation for nested functions
    If Not IsNumber($nExpression) Then $nExpression = Dec($nExpression)
    If @error Then Return SetError(2, __HardError(), "NaN")

    Return Abs($nExpression)
EndFunc ;==>_Abs

Func __HardError()
    $_KickBack_ += 1
    Return $_KickBack_
EndFunc ;==>__HardError

The only problem I'm having is with the documentation: I don't know who to attribute the following native AutoIt functions to. I thought of setting AutoIt Dev Team or Jonathan Bennett as the authors (the only thing I'm adding are the error checks - more or less).

Who wrote the following functions?

Abs, ACos, ASin, ATan, BitAND, BitNOT, BitOR, BitRotate, BitShift, BitXOR, Ceiling, Cos, Dec, Exp, Floor, Hex, Log, Log10, Mod, Random, Round, Sin, Sqrt, Tan.

If not known, what name do you think I should put?

Edited by czardas

Share this post


Link to post
Share on other sites

AutoIt Development Team would be fine but since they are all core functions; I would say that no attribution is necessary.


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

Thanks, I was thinking that I should leave the author field blank (unless the author is known). :)

The functions are not really designed to be used as a UDF, but rather to be used internally (In the language itself, the function names will not include underscore). I thought I'd stick with the standard UDF format for now in case someone wanted to make use of the final code.

Edited by czardas

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...