Indigo Rose Software

Professional Software Development Tools

 
Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2005
    Posts
    4

    Grin function calling error

    please can any one help me to find the reason of the error in my function calling example which i did?

    this function calling example hase been attached..

    please i want quikly respond..

    thanks ..
    Attached Files

  2. #2
    Join Date
    Nov 2006
    Posts
    233
    remove the "local" from your global function and it works... so use

    Code:
     01 -- A function that accepts one value and returns one value 
    02 function mntestfunction(testvalue) 
    03  -- Put function script here 
    04 mnvalue = testvalue;  -- Access testvalue 
    05  -- if statment test 
    06 if (mnvalue==1) then 
    07  -- Do something here 
    08 result_value= "OK"; 
    09 elseif (mnvalue==2) then 
    10  -- Do something else here 
    11 result_value= "Very Good"; 
    12 elseif (mnvalue~=1 or mnvalue~=2 ) then 
    13  -- Do something else here 
    14 result_value= "Not Good"; 
    15 end -- end if statment 
    16  --------- 
    17 return result_value;  -- Return result_value 
    18 end 
    19

    output enhanced with AMS Code Pretty



    instead of


    Code:
    01 -- A function that accepts one value and returns one value
    02 function mntestfunction(testvalue) 
    03 	-- Put function script here
    04 	local mnvalue = testvalue;  -- Access testvalue
    05 	-- if statment test
    06 	if (mnvalue==1) then 
    07 	 	-- Do something here
    08 		local result_value= "OK"; 
    09 	elseif (mnvalue==2) then 
    10 	 	-- Do something else here
    11 		local result_value= "Very Good"; 
    12 	elseif (mnvalue~=1 or mnvalue~=2 ) then 
    13 	 	-- Do something else here
    14 		local result_value= "Not Good";	 
    15 	en d-- end if statment
    16 	---------
    17 	return result_value;  -- Return result_value
    18 end 
    19
    output enhanced with AMS Code Pretty

  3. #3
    Join Date
    Jul 2004
    Location
    Denmark
    Posts
    336
    You could also do this:
    Code:
    -- A function that accepts one value and returns one value
    function mntestfunction(testvalue)
    	-- Put function script here
    	local mnvalue = testvalue; -- Access testvalue
    	-- if statment test
    	
            if mnvalue==1 then
    		-- Do something here
    		 result_value="OK";
    	elseif mnvalue==2 then
    		-- Do something else here
    		 result_value="Very Good";
    	elseif mnvalue ~= 1 or 2 then
    		-- Do something else here
    		 result_value="Not Good";	
    	end-- end if statment
    	---------
    	return result_value;  -- Return result_value
    end
    The difference is I removed the () around the declaration of variables like
    (mnvalue = 1) becomes mnvalue = 1

    you dont need the () also the mnvalue ~= 1 or 2. you can easaly compare the same variable to more then one value, you dont need to test the variable twice.

    Thise are just design notes, they have no effect on the executet script but as saied above all you have to do is remove the local from the variable name.

    cheers,
    Jonas

Similar Threads

  1. Problem Calling Dll Function
    By gustavoAUDACES in forum Setup Factory 7.0
    Replies: 0
    Last Post: 05-05-2006, 11:22 AM
  2. help with ftp connect
    By CAI in forum AutoPlay Media Studio 6.0
    Replies: 0
    Last Post: 09-29-2005, 07:13 PM
  3. Another tough one... Interaction between Web and AMS
    By Agent Jones in forum AutoPlay Media Studio 5.0
    Replies: 13
    Last Post: 08-18-2005, 02:10 PM
  4. Function: Blowfish Encrypt/Decrypt Strings
    By Lorne in forum AutoPlay Media Studio 5.0 Examples
    Replies: 0
    Last Post: 05-31-2004, 03:16 PM
  5. SUF6.0.0.2 -- installer hangs.
    By jassing in forum Setup Factory 6.0
    Replies: 4
    Last Post: 12-19-2001, 11:28 PM

Posting Permissions

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