Alpha Video Training
Results 1 to 4 of 4

Thread: Trapping a NUL Parameter in a Function

  1. #1
    Member
    Real Name
    Keith Weatherhead
    Join Date
    Nov 2004
    Location
    Braceville, IL
    Posts
    427

    Default Trapping a NUL Parameter in a Function

    Greetings,

    I an working on a funtion that accepts a single numeric parameter. What I want to do is to prevent either a null paramer: function() or a parameter of zero, as in: function(0).

    It works OK with the (0) but not the ()

    The function head looks like....
    Code:
    FUNCTION Lib_Error AS C (LibErr AS N )
    
    ' This gives me and argument type error		
    	if LibErr = "" then
    	    EXIT function
    	end if
    
    'This gives me a "not an executable file" error
    	if LibErr < 1 then
    	    EXIT function
    	end if
    I want the function to exit doing nothing if that condition occurs, how should I properly test for this condition in A5?

    Regards,
    Keith
    Last edited by AaronBBrown; 08-02-2006 at 01:51 PM.
    Keith Weatherhead
    Discus Data, Ltd
    kweatherhead@gmail.com

  2. #2
    VAR csda1's Avatar
    Real Name
    Ira J Perlow
    Join Date
    Apr 2000
    Location
    Boston, Massachusetts, USA
    Posts
    3,530

    Default

    Keith,

    Try something like this

    Code:
    FUNCTION Lib_Error AS C (LibErr=.t. AS A)
    
    IF typeof(Liberr)=="N"
        IF Liberr<1
            Exit function
        END IF
    ELSE
           EXIT function
    end if
    
    ' otherwise process number
    
    END
    Last edited by AaronBBrown; 08-02-2006 at 01:51 PM.
    Regards,

    Ira J. Perlow
    Computer Systems Design


    CSDA A5 Products
    New - Free CSDA DiagInfo - v1.39, 30 Apr 2013
    CSDA Barcode Functions

    CSDA Code Utility
    CSDA Screen Capture



  3. #3
    Member
    Real Name
    Keith Weatherhead
    Join Date
    Nov 2004
    Location
    Braceville, IL
    Posts
    427

    Default Thanx, Ira !!

    Thats a winner !!
    Wonder how long that would have taken to figure out, hmm?

    Regards,
    Keith
    Keith Weatherhead
    Discus Data, Ltd
    kweatherhead@gmail.com

  4. #4
    Member abackstrom's Avatar
    Real Name
    Adam Backstrom
    Join Date
    Apr 2005
    Posts
    84

    Default "Not an executable file"

    I got the "Not an executable file" error as well. Turned out to be my function definition:
    Code:
    function myfunc AS L ( myvar AS C = "t" )
    That is bad syntax. The proper way is:
    Code:
    function myfunc AS L ( myvar = "t" AS C)
    Adam Backstrom <adam@sixohthree.com>

Similar Threads

  1. Table value is Nul Aaargh!
    By cellboy in forum Alpha Five Version 7
    Replies: 4
    Last Post: 11-19-2005, 04:54 AM
  2. X-Dialog Trapping Function Keys
    By Louis Nickerson in forum Alpha Five Version 6
    Replies: 2
    Last Post: 02-04-2005, 08:02 AM
  3. Function Parameter calling bug?
    By csda1 in forum Alpha Five Version 5
    Replies: 0
    Last Post: 07-29-2004, 09:48 AM
  4. logic and nul value append
    By Chris.Tanti in forum Alpha Five Version 5
    Replies: 2
    Last Post: 02-01-2003, 06:32 PM
  5. Bad parameter?
    By Reese Fletcher in forum Alpha Five Version 4
    Replies: 2
    Last Post: 10-17-2001, 03:30 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •