Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    New to the CF scene
    Join Date
    Dec 2004
    Thanked 0 Times in 0 Posts

    KSH help! passing variables to functions

    okay, I have the following code. (korn shell script in unix).

    function abc
    print $1

    #main starts here

    for((i=1; i<$#; i++))
    abc $i
    #end of program

    #the $# variable is a count of the number of vars #passed to main from the command line.

    #here, $i is the first command line variable. I want to #pass that variable to function abc. then i want the
    #value of $2, then value of $3, etc.

    when i do this, it actually passes $i rather than the value of $i. i have tried every type of syntax modification to the function call, but can't seem to make this work. any help would be GREATLY appreciated. thank you!
    Last edited by Nevermore84; 12-04-2004 at 10:20 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