Returning and capturing multiple return values from a function
Hi
I am pretty confused in returning and capturing multiple values
i have defined a function which should return values "total, difference"
i have used as
I have invoked this function as
calc 5 8
Now i need the value of $total and $diff after the function is being invoked..
Please help..
Last edited by vbe; 04-09-2013 at 06:43 AM..
Reason: code tags
hi
how can I return multiple values from a C function. I tried the following:
#include <stdio.h>
void foo(int id, char *first_name, char *last_name)
{
/*
this is just an example to illustrate my problem... real code makes
use of the "id" parameter.
*/
first_name = (char... (8 Replies)
I am working on a C/Unix application from last 2 years which communicates with other systems using proprietary format of my client. We have a function written in C which returns integer, which is response from other system to the request message initiated by my system. This return value is then... (1 Reply)
i have an oracle function which returns two values, one is the error message if the function encounters anything and another one which returns a number
i need to capture both
and pass it on to unix shell script
how to do it (2 Replies)
Hi,
I have a script which does something like the below:
execute_some_script.sh $arg1 $arg2 `exec-some-cmd`
if then;
do something
else
do something else
fi
However, during some cases, there is an error saying:
line xxx: [: too many arguments
at the line number which has... (5 Replies)
Hi,
I need to retrun multiple values
function errorFileCreation
{
echo "Before"
return -1 "Siva";
echo "Aftyer"
}
echo ${?} - This can be used to getting first value.
how can i get second one.
Advance Thanks...
Shiv (3 Replies)
I am using a for loop to copy files from say DIR1 and DIR2 to DIR3.I have to check whether files are copied from DIR1 and DIR2 and print the respective message.
@path=("$DIR1","$DIR2");
foreach (@path) {
$rc=system("cp $_/*xml $DIR3");
if ($rc == 0)
{
print "Files were copied... (1 Reply)
Hello,
I need to capture multiple values from user input and do not know how to do it. I'm writing a script to delete old files, but want to give the option to keep some by asking the user.
This is what my output looks like...
Old files to be deleted...
1 file1
2 file2
Then this bit of... (3 Replies)
I've been trying to write a command-line function to grab a website's MX records and their ip addresses. The code below works with domains that only have one MX record:
function kmx { mx=`host -t MX $1 | awk '{ print $7 }'`;
ip=`host $mx | sed '/IPv6/d;/handled/d' | awk '{ print $4 }'`; ... (8 Replies)
Hi
I have a code as the following
#!/usr/bin/ksh
set -x
row()
{
a=$1
b=$2
c=$(($a + $b))
d=$(($a * $b))
echo $a $b
}
e=`row 2 3`
set $e
echo "The value of c is $c"
echo "The value of d is $d"
My requirement is I need to pass two arguments to a function and return two values... (5 Replies)
Hi,
I have a small part of a project which is done as a bash script. bash was selected as an portability issue that works out of the box. In this script I have an exec shell-function, a wrapper around arbitrary commands. I want to have STDOUT, as an addon STDERR and the EXIT-CODE of a specified... (5 Replies)
Discussion started by: stomp
5 Replies
LEARN ABOUT PHP
xdiff_string_diff
XDIFF_STRING_DIFF(3) 1 XDIFF_STRING_DIFF(3)xdiff_string_diff - Make unified diff of two stringsSYNOPSIS
string xdiff_string_diff (string $old_data, string $new_data, [int $context = 3], [bool $minimal = false])
DESCRIPTION
Makes an unified diff containing differences between $old_data string and $new_data string and returns it. The resulting diff is human-
readable. An optional $context parameter specifies how many lines of context should be added around each change. Setting $minimal parameter
to true will result in outputting the shortest patch file possible (can take a long time).
PARAMETERS
o $old_data
- First string with data. It acts as "old" data.
o $new_data
- Second string with data. It acts as "new" data.
o $context
- Indicates how many lines of context you want to include in the diff result.
o $minimal
- Set this parameter to TRUE if you want to minimalize the size of the result (can take a long time).
RETURN VALUES
Returns string with resulting diff or FALSE if an internal error happened.
EXAMPLES
Example #1
xdiff_string_diff(3) example
The following code makes unified diff of two articles.
<?php
$old_article = file_get_contents('./old_article.txt');
$new_article = $_REQUEST['article']; /* Let's say that someone pasted a new article to html form */
$diff = xdiff_string_diff($old_article, $new_article, 1);
if (is_string($diff)) {
echo "Differences between two articles:
";
echo $diff;
}
?>
NOTES
Note
This function doesn't work well with binary strings. To make diff of binary strings use xdiff_string_bdiff(3)/xdiff_string_rabd-
iff(3).
SEE ALSO xdiff_string_patch(3).
PHP Documentation Group XDIFF_STRING_DIFF(3)