parameter-passing

Passing An Array From One Bash Script to Another

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-29 19:59:44
问题 I am new to writing Shell Scripts and am having some difficulties. What I Want To Achieve I have an array of strings in scriptOne.sh that I want to pass to scriptTwo.sh What I Have Done So Far I can execute the second script from inside the first using ./scriptTwo.sh and I have passed string variables from one to the other using ./scriptTwo.sh $variableOne . The issues are when I try to pass an array variable it doesn't get passed. I have managed to get it to pass the first entry of the array

Bash: pass a function as parameter

这一生的挚爱 提交于 2019-11-29 19:30:44
I need to pass a function as a parameter in Bash. For example, the following code: function x() { echo "Hello world" } function around() { echo "before" eval $1 echo "after" } around x Should output: before Hello world after I know eval is not correct in that context but that's just an example :) Any idea? If you don't need anything fancy like delaying the evaluation of the function name or its arguments, you don't need eval : function x() { echo "Hello world"; } function around() { echo before; $1; echo after; } around x does what you want. You can even pass the function and its arguments

Calling Javascript function in PHP while passing PHP variables into the function

泪湿孤枕 提交于 2019-11-29 17:07:58
I'm experiencing a problem when calling a JavaScript function inside PHP code and trying to pass my PHP variables as parameters into the function. While it seems really simple to me, I can't figure it out by trying different syntax. Here is a sample code which can demonstrate the problem: <?PHP $var1 = 0; $var2 = 1; $var3 = 2; echo '<script type="text/javascript">functionName($var1, $var2, $var3);</script>'; ?> If I try to pass constants (e.g. "123") the function gets called and the value is passed, but when trying to pass the PHP variable, the function doesn't get called at all. How can I do

Passing multiple values in single parameter

有些话、适合烂在心里 提交于 2019-11-29 16:30:45
Let's say I have this function: CREATE OR REPLACE FUNCTION test_function(character varaying) RETURNS integer AS $BODY$ DECLARE some_integer integer; begin Select column2 from test_table where column1 in ($1) into some_integer; end; Return some_integer; $BODY$ LANGUAGE plpgsql VOLATILE COST 100; And I want to call it like this: Select * from test_function ('data1', 'data2','data3'); Of course, it cannot be done this way, because Postgres tries to find function with this name and three parameter which doesn't exists. I tried to put quotes around commas but in that case parameter is interpreted

Optional argument in PL/pgSQL function

依然范特西╮ 提交于 2019-11-29 16:05:44
问题 I am trying to write a PL/pgSQL function with optional arguments. It performs a query based on a filtered set of records (if specified), otherwise performs a query on the entire data set in a table. For example (PSEUDO CODE) : CREATE OR REPLACE FUNCTION foofunc(param1 integer, param2 date, param2 date, optional_list_of_ids=[]) RETURNS SETOF RECORD AS $$ IF len(optional_list_of_ids) > 0 THEN RETURN QUERY (SELECT * from foobar where f1=param1 AND f2=param2 AND id in optional_list_of_ids); ELSE

Default value of parameter is not used in function

本秂侑毒 提交于 2019-11-29 15:52:19
问题 I have a very basic PowerShell script: Param( [string]$MyWord ) function myfunc([string] $MyWord) { Write-Host "$MyWord" } myfunc @PSBoundParameters This is how I execute it: PS C:\> .\test.ps1 -MyWord 'hello' hello All fine. But I want to set a default value if -MyWord isn't specified. I tried this: Param( [string]$MyWord='hi' ) function myfunc([string] $MyWord) { Write-Host "$MyWord" } myfunc @PSBoundParameters But than the output of my script was just empty. It was printing nothing when I

Store Bash script arguments $@ in a variable

試著忘記壹切 提交于 2019-11-29 15:43:31
问题 How can I store $@ in a variable while keeping its properties? I want to obtain exactly the same behavior even if I use $@ or my own variable in all possible situations. The attempts below didn't work: args=$@ args2="$@" # the arguments are combined (see the last output paragraph) I tested them using the following line: s.sh A B=" " C s.sh #!/bin/bash args=$@ args2="$@" #args3 = ? - TODO echo $args echo $args2 echo $@ #echo $args3 echo echo "$args" echo "$args2" echo "$@" #echo "$args3" echo

Passing values between two windows forms

…衆ロ難τιáo~ 提交于 2019-11-29 15:32:39
The case is this, I have two different forms from the same solution/project. What I need to do is to extract the value of a label in Form A and load it into Form B. As much as possible, I am staying away from using this code since it will only conflict my whole program: FormB myForm = new FromB(label.Text); myForm.ShowDialog(); What I am trying right now is a class with a property of get and set for the value I wanted to pass. However, whenever I access the get method from FormB, it returns a blank value. I hope somebody can help me with this. Any other ways to do this is extremely appreciated

How can I pass a PHP variable to javascript?

人走茶凉 提交于 2019-11-29 15:10:00
I want to use a PHP variable as a javascript variable - specifically I want to user the PHP variable session_id(); and use this as a javascript variable. <?php $php_var = session_id(); ?> <script language="JavaScript" type="text/javascript"> js_var = <?php echo($php_var ?>; </script> This seems like it should work for me but it doesnt can anyone suggest a better way? The best method i can think of looks like this: <?php $php_var = session_id(); ?> <script type="text/javascript"> var js_var = <?php echo json_encode($php_var); ?>; </script> PHP's json_encode -function is always producing valid

How to pass array structure between two verilog modules

半城伤御伤魂 提交于 2019-11-29 15:08:58
问题 I am trying to pass a array structure as reg [0:31]instructionmem[0:31] between two modules. I coded it as follows : Module No 1: module module1(instructionmem); output reg [0:31]instructionmem[0:31]; ------------------ ----lines of code--- --------------- endmodule Module No 2: module module2(instructionmem); input [0:31]instructionmem[0:31]; -------------------------------- -----line of code--------------- ------------------------------- endmodule Testbench: module test_bench(); wire [0:31