parameter-passing

How to pass parameters to query?

谁都会走 提交于 2019-12-16 20:06:08
问题 I'm trying to write a query for my application, but I'm having some troubles. I need to pass as a parameter one field of my database, like: SELECT name, phone, email FROM company WHERE $P{clause} = $P{key} ORDER BY $P{order} Because WHERE clause and ORDER BY clause are dynamic for the user to select. Using $P{} it didn't work. 回答1: There are two syntax expressions for parameter referencing in JasperReports : $P{} and $P!{} . $P{paramName} syntax is using mostly for setting WHERE input

How to change value of variable passed as argument?

一曲冷凌霜 提交于 2019-12-16 19:56:21
问题 How to change value of variable passed as argument in C? I tried this: void foo(char *foo, int baa){ if(baa) { foo = "ab"; } else { foo = "cb"; } } and call: char *x = "baa"; foo(x, 1); printf("%s\n", x); but it prints baa why? thanks in advance. 回答1: You're wanting to change where a char* points, therefore you're going to need to accept an argument in foo() with one more level of indirection ; a char** (pointer to a char pointer). Therefore foo() would be rewritten as: void foo(char **foo /*

Dynamic memory access only works inside function

∥☆過路亽.° 提交于 2019-12-16 19:05:26
问题 This question is meant to be used as a canonical duplicate for this FAQ: I am allocating data dynamically inside a function and everything works well, but only inside the function where the allocation takes place. When I attempt to use the same data outside the function, I get crashes or other unexpected program behavior. Here is a MCVE: #include <stdlib.h> #include <stdio.h> void create_array (int* data, int size) { data = malloc(sizeof(*data) * size); for(int i=0; i<size; i++) { data[i] = i

Dynamic memory access only works inside function

末鹿安然 提交于 2019-12-16 19:05:23
问题 This question is meant to be used as a canonical duplicate for this FAQ: I am allocating data dynamically inside a function and everything works well, but only inside the function where the allocation takes place. When I attempt to use the same data outside the function, I get crashes or other unexpected program behavior. Here is a MCVE: #include <stdlib.h> #include <stdio.h> void create_array (int* data, int size) { data = malloc(sizeof(*data) * size); for(int i=0; i<size; i++) { data[i] = i

Loop over matrix elements applying variable function

爷,独闯天下 提交于 2019-12-14 03:59:48
问题 In my matrix class there are too many instances of for(size_t i = 1 ; i <= rows ; i++){ for(size_t j = 1 ; i <= cols ;j++){ //Do something } } Keeping in mind the DRY principle , I was wondering whether I could matrix<T>::loopApply(T (*fn) (T a)){ // changed T to T a for(size_t i = 1 ; i <= rows ; i++){ for(size_t j = 1 ; i <= cols ;j++){ _matrix[(i-1)*_rows + (j-1)] = fn(a) // changed T to a } } } So that when I want to loop over and apply something to the matrix I just have to call

Passing variables in classic ASP

余生长醉 提交于 2019-12-14 03:28:19
问题 I am dealing with legacy code where there is an include of another ASP page. <!--#INCLUDE virtual="/PAGE1.ASP"--> to get a variable, say x, from that page, I beleive I would do: x = Request.Form("x") is that correct? Also, are the variable names case sensitive for classic .ASP files? Thanks so much. 回答1: You should think of the page as being built into one contiguous page, so that if you include a number of .asp files they will build up your finished page. For instance, if you have three

Python parameter list with single argument

白昼怎懂夜的黑 提交于 2019-12-14 03:25:56
问题 When testing Python parameter list with a single argument, I found some weird behavior with print . >>> def hi(*x): ... print(x) ... >>> hi() () >>> hi(1,2) (1, 2) >>> hi(1) (1,) Could any one explain to me what the last comma mean in hi(1) 's result (i.e. (1,) ) 回答1: Actually the behavior is only a little bit "weird." :-) Your parameter x is prefixed with a star, which means all the arguments you pass to the function will be "rolled up" into a single tuple, and x will be that tuple. The

passing checkbox ID to another php file

China☆狼群 提交于 2019-12-14 03:25:52
问题 let's say i'm generating some sort of html table (from mysql queried data) with a checkbox at each row with something like $display_string = "<form action=\"delete.php\" method=\"post\">"; $display_string .= "<div><input type=\"button\" VALUE=\"Button1\"></div>"; $display_string .= "<div><input type=\"button\" VALUE=\"Button2\"></div>"; while($row = mysql_fetch_array($qry_result)){ $display_string .= "<tr onmouseover=\"this.className = 'hlt';\" onmouseout=\"this.className = '';\">"; $display

Kotlin methods with Vararg as First Parameter

让人想犯罪 __ 提交于 2019-12-14 02:03:11
问题 Note I've looked at the following questions/answers to solve the problem without any luck. Call Java Varargs Method from Kotlin - this one has the varargs parmeter at the end of the parameter list, but my question deals with varargs at the start of the parameters list. Kotlin: Convert List to Java Varargs - the same. Other searches yield the same thing. These were the closest I could find. I am calling the Kotlin String.split method with a single character delimiter. This is a vararg method

Include sub-element inside JSF 2.0 component

纵然是瞬间 提交于 2019-12-14 00:44:03
问题 This must be simple. I am trying to pass sub-element into a JSF component. I have my component declared as: <?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:composite="http://java.sun.com/jsf/composite"> <composite:interface> </composite:interface> <composite:implementation> <div style=