I'm using drupal 6
Suppose I have
$items['path/yo'] = array(
'page callback' => 'callback_function',
'page arguments' => array(1),
'type' => MENU_CALLBACK,
);
It will instead pass in the part of the path that is in the 1-th position (in this case it will pass 'yo') into the callback_function function...
But what if I'm actually TRYING to pass in the integer 1 into the function? How would I do that without casting it as string first and then reconverting to integer...
php type conversion is very well done, you have to be careful with type casting however especially with 0 and 1 as they can be strings, numbers or booleans.
You can use type checks in your conditionals (such as === !==). In your current example it isn't a string first it's a number. It would pass 1 into callback_function.
function callback_function($args) {
print_r($args);
}
Will give you the arguments passed. In this case $args[0] would be the number 1. You shouldn't have to worry if it's a number or a string in 99% of cases because if you use it as a number php will convert it to a number and if you use it as a string php will treat it as a string. Just be careful with conditional statements and be sure to read this: http://php.net/manual/en/language.operators.comparison.php
For example to see if it is the number 1:
if(1 === $args[0]) echo "Numbah one!";
Will only print "Numbah one!" if it's a number type and the number 1. You can typecast it if you like with
(int)$args[0];
(string)$args[0];
(boolean)$args[0];
respectively.
You might also check out this article:
http://drupal.org/node/1473458
$items['path/yo'] = array(
'page callback' => 'callback_function',
'page arguments' => array("1"),
'type' => MENU_CALLBACK,
);
See Wolfe's answer as well. If you enter (int) 1, it will be arg(1). Enter strings to be passed to the page callback as-is.
Related
I have a Set of String that contains words . The the Set can be of length 15 in average.
Am wondering if i can query the entries that contains either these words with moor's operand | efficiently without having to loop the Set like i have done here.
Future<List<Upload>> search(Set keys, List<Upload> result) async {
keys.forEach( (term) => (select(uploads)..where((tbl) => tbl.title.contains(term))) .get() .then((value) => result.addAll(value)), );
return SomeResult;
}
I can see that am running a single query multiple times.
Any help?
Thanks
I somehow found the solution here for anyone looking for same scenario
https://moor.simonbinder.eu/docs/getting-started/expressions/#in-and-not-in using .isIn list
Future<List<Upload>> search(List keys) => (select(uploads)..where((tbl) => tbl.title.isIn(keys))).get();
This section of my program is supposed to list all files within the directory containing ".txt" in the name but it's not returning anything when run. If I delete ".txt" and leave it as an empty string "" then it works perfectly and returns all file names including the .txt files so I can't figure out what I'm doing wrong here.
procedure Search_Directory is
use Ada.Directories;
procedure Write_Search_Item(Search_Item : in Directory_Entry_Type) is
begin
Put(Item => Simple_Name(Directory_Entry => Search_Item));
New_Line;
end Write_Search_Item;
Filter : Constant Filter_Type := (Ordinary_File => True,
Special_File => False,
Directory => True);
begin
Search(Directory => Current_Directory,
Pattern => (".txt"),
Filter => Filter,
Process => Write_Search_Item'Access);
end Search_Directory;
The Search function, defined in the package Ada.Directories, takes a pattern argument which is either a null string or a form that is implementation-defined RM A.16 (111/ 2). In GNAT, this pattern is supposed to be a regular expression (see also here) described in System.Regexp (see also here, second grammar, a "globbing pattern").
I am using PhpExcel 1.8.0 and I have faced with the problem. PhpExcel can't calculate formula OFFSET() with 4 arguments:
"Price Sheet!A27 -> Program Settings!H2 -> Formula Error: Wrong number
of arguments for OFFSET() function: 4 given, either 3 or 5 expected"
But in description of this formula i have found that this argument "width"
is optional:
"It is the number of columns that you want the returned range to be.
If this parameter is omitted, it is assumed to be the width of range."
Can someone tell me how to fix this problem?
Open the file Classes/PHPExcel/Calculation.php and find the entry in the $PHPExcelFunctions array for OFFSET which looks like:
'OFFSET' => array(
'category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE,
'functionCall' => 'PHPExcel_Calculation_LookupRef::OFFSET',
'argumentCount' => '3,5',
'passCellReference' => true,
'passByReference' => array(true)
),
and change the argumentCount block to
'argumentCount' => '3-5',
I've been using Ada.Containers.Indefinite_Hased_Maps to create my own custom hashed maps, and it worked quite well until I tried to use a vector as the element type. Here is an example of the problematic code:
package String_Vectors is new Ada.Containers.Vectors(Element_Type => Unbounded_String, Index_Type => Natural);
subtype String_Vector is String_Vectors.Vector;
package Positive2StringVector_HashMaps is new Ada.Containers.Indefinite_Hashed_Maps --Compiler fails here
(Element_Type => String_Vector,
Key_Type => Positive,
Hash => Positive_Hash,
Equivalent_Keys => Positive_Equal);
Basically, I cannot Positive2StringVector_HashMaps package, because the compiler comes up with:
no visible subprogram matches the specification for "="
From what I understand, it isn't finding the equality operator for the String_Vector , am I correct? If I am, what is the proper way of implementing it? And if I'm not, what am I doing wrong??
You don’t need to implement
function “=“ (L, R : String_Vectors.Vector) return Boolean
yourself, because there already is one in String_Vectors; see ALRM A.18.2(12). So you write
package Positive2StringVector_HashMaps is new Ada.Containers.Indefinite_Hashed_Maps
(Element_Type => String_Vector,
Key_Type => Positive,
Hash => Positive_Hash,
Equivalent_Keys => Positive_Equal,
“=“ => String_Vectors.”=");
By the way, is there some reason you used Ada.Containers.Vectors on Unbounded_String rather than Indefinite_Vectors on String? (wanting to change the length of a contained string would count as a Good Reason!)
I'm building a job chain in Oracle (11R2) DBMS Scheduler. The chain has two steps. Each step runs the same program, but with different arguments. I can see how how to define the chain, the steps, the rules, etc - but I cannot figure how to set the argument values for the steps.
When I build jobs that are single calls to programs, I set the arguments like this:
dbms_scheduler.set_job_argument_value(
job_name => 'MY_JOB',
argument_position => 1,
argument_value => 'foo');
My question is: Which dbms_scheduler func/proc would I call to set the arguments for a job step? Using the examples below, how would set an argument for 'STEP_1' in 'MY_CHAIN'?
Thanks,
John
DBMS_SCHEDULER.CREATE_CHAIN (
chain_name => 'MY_CHAIN',
rule_set_name => NULL,
evaluation_interval => NULL,
comments => 'Chain calls 2 steps. Same program but with different arg values.');
DBMS_SCHEDULER.DEFINE_CHAIN_STEP (
chain_name => 'MY_CHAIN',
step_name => 'STEP_1',
program_name => 'MY_PROGRAM');
DBMS_SCHEDULER.DEFINE_CHAIN_STEP (
chain_name => 'MY_CHAIN',
step_name => 'STEP_2',
program_name => 'MY_PROGRAM');
DBMS_SCHEDULER.CREATE_JOB (
job_name => 'MY_CHAIN_JOB',
job_type => 'CHAIN',
job_action => 'MY_CHAIN',
repeat_interval => 'freq=daily;byhour=12;byminute=0;bysecond=0',
enabled => TRUE);
I believe that you'd have to define two different programs for this, although they can of course reference the same stored procedure or executable.
In the case o the former unless I'm going to be modifying the argument values I tend to use anonymous block program types to specify the arguments to stored procedures -- it's complex enough without adding in all that program argument stuff.