Sign in to follow this  
Followers 0
Blue_Drache

Badly Formatted Function

3 posts in this topic

#1 ·  Posted (edited)

Is there a way to set a recursive optional parameter? Example follows.

;===============================================================================
; Function Name:    Inelg
;
; Description:    Finding the inelgible reason codes on the GDSV
;                  screens.
;
; Parameter(s):  $sScreen - Window to screen scrape.  Required.
;                  $sCode1 - First code to search for.  Required.
;                  $sCode2 - Second code to search for.  (optional)
;
; Format Examples:  Inelg("T42")
;                  Inelg("T42","285")
;
; Requirement(s):   Control-Insert must be able to copy all screen text
;                  into the clipboard.  This is usually the default on the
;                  standard AS400 Emulator keyboard setup.
;
; Return Value(s):  Returns 1 if ANY of the paramaters is found
;                  Returns 2 if end of lines and NO parameters are found.
;                  Returns 0 if error
;
; Author(s):        Me!
;===============================================================================

Func Inelg($sScreen, $sCode1, $sCode2 = $sCode1)
;~  GetScreen($sScreen)
   GetScreen2($s_clip, $sScreen)
   Local $inel
   
   If @error Then Return 0
   
   $inel = StringStripWS($s_clip, 8)
   $inel = StringMid($inel, StringInStr($inel, "INELRSNS:"), 30)
   $inel = StringTrimLeft($inel, 9)
   $inel = StringLeft($inel, 9)
   
;DEBUG start ---------------------
;~ MsgBox(0,$dcn,$inel)
;DEBUG end -----------------------
   Select
      Case StringRight($inel, 3) = $sCode1 Or StringLeft($inel, 3) = $sCode1 Or StringTrimLeft(StringLeft($inel, 6), 3) = $sCode1
         Return 1
      Case StringRight($inel, 3) = $sCode2 Or StringLeft($inel, 3) = $sCode2 Or StringTrimLeft(StringLeft($inel, 6), 3) = $sCode2
         Return 1
      Case StringInStr($s_clip, "NO MORE SERVICES FOR CLAIM") > 0
         Return 2
   EndSelect
   Return 0
EndFunc;==>Inelg

Above code produces following SciTE output:

>"C:\Documents and Settings\User\Desktop\AutoIt\autoit3.exe" /ErrorStdOut "C:\Documents and Settings\User\Desktop\AutoIt\User Scripts\AutoLock.au3" 
C:\Documents and Settings\User\Desktop\AutoIt\Include\SupportFunctions.au3 (301) : ==> Badly formatted "Func" statement.: 
Func Inelg($sScreen, $sCode1, $sCode2 = $sCode1) 

>Exit code: 1   Time: 0.723

Problem is, I don't want to set the second parameter to a null string as that gives me a false positive. Also, setting the second parameter to something that's hard-coded (non-optional) would be undesirable, but workable.

I'm guessing that my problem lies within the way I'm re-formatting the screen output I'm testing for. Especially when the 9 characters I'm looking for come back as "T42......" The dots being null space.

EDIT: FYI: Adding the same parameter in [example: Inelg ($a, "273", "273")] fixes the problem of false positives when the original code of Func Inelg($sScreen, $sCode1, $sCode2 = "") is used.

EDIT 2: OK, I've fixed my problem (simple *doh* solution) was to set the optional parameter to something that is an impossible situation to find (like the word "blank"). But the question still remains about recursive optional parameters. Could it be feasable?

Edited by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites



What about:

Func Inelg($sScreen, $sCode1, $sCode2 = "")
If $sCode2 = "" Then $sCode2= $sCode1

Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs

Share this post


Link to post
Share on other sites

What about:

Func Inelg($sScreen, $sCode1, $sCode2 = "")
If $sCode2 = "" Then $sCode2= $sCode1

<{POST_SNAPBACK}>

That's just as simple as my solution.... That's why I didn't think of it!

Hehe. Thanks, that one makes more sense then setting the optional one to an impossible.


Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

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  
Followers 0