argument-passing

Pass Argument from VBS to VBA

℡╲_俬逩灬. 提交于 2019-12-18 05:12:42
问题 I try to call a VBA subroutine from VBS with passing a string variable from VBS to VBA, but can't find the appropiate syntax: 'VBS: '------------------------ Option Explicit Set ArgObj = WScript.Arguments Dim strPath mystr = ArgObj(0) '? 'Creating shell object Set WshShell = CreateObject("WScript.Shell") 'Creating File System Object Set objFSO = CreateObject("Scripting.FileSystemObject") 'Getting the Folder Object Set ObjFolder = objFSO.GetFolder(WshShell.CurrentDirectory) 'Getting the list

Why do argument lists in certain Cocoa methods end with a nil?

混江龙づ霸主 提交于 2019-12-17 16:58:29
问题 Why do argument list in some methods end with nil ? I have noticed this particularly in the collection classes, for example NSSet : mySet = [NSSet setWithObjects:someData, aValue, aString, nil]; and NSArray : NSArray *objects = [NSArray arrayWithObjects:@"value1", @"value2", @"value3", nil]; 回答1: It has to do with how variable argument lists work ( va_list , seen as ... in the parameters). When the code is trying to extract all of the values in the list, it needs to know when to stop (because

Function arguments (in Python for example)

守給你的承諾、 提交于 2019-12-17 16:31:40
问题 What are [function] arguments? What are they used for? I started learning Python very recently; I'm new to programming and I apologize for this basic question. In every Python tutorial I go through they talk about arguments . I have looked for the answer to this question and have found many answers but they are just a little too hard for me to understatnd. I may just be missing some conceptual background. So... when I define a function, what are the things in parenthesis used for? Example:

How to convert a command-line argument to int?

拟墨画扇 提交于 2019-12-17 08:55:18
问题 I need to get an argument and convert it to an int. Here is my code so far: #include <iostream> using namespace std; int main(int argc,int argvx[]) { int i=1; int answer = 23; int temp; // decode arguments if(argc < 2) { printf("You must provide at least one argument\n"); exit(0); } // Convert it to an int here } 回答1: Since this answer was somehow accepted and thus will appear at the top, although it's not the best, I've improved it based on the other answers and the comments. The C way;

Why is list when passed without ref to a function acting like passed with ref?

江枫思渺然 提交于 2019-12-17 07:47:43
问题 If I did not get this terribly wrong, this behaviour is strange for me. Rather than explaining, I'll post a sample code below and please tell me why does I get output x and not y. private void button1_Click(object sender, EventArgs e) { List<int> l = new List<int>() { 1, 2, 3 }; Fuss(l); MessageBox.Show(l.Count.ToString()); } private void Fuss(List<int> l) { l.Add(4); l.Add(5); } Output should, I assume would be 3. But I get the output as 5. I understand the output can be 5 if I do this:

Is there a way to use two '…' statements in a function in R?

巧了我就是萌 提交于 2019-12-17 03:26:36
问题 I want to write a function that calls both plot() and legend() and it would be ideal if the user could specify a number of additional arguments that are then passed through to either plot() or legend() . I know I can achieve this for one of the two functions using ... : foo.plot <- function(x,y,...) { plot(x,y,...) legend("bottomleft", "bar", pch=1) } foo.plot(1,1, xaxt = "n") This passes xaxt = "n" to plot. But is there a way for example to pass e.g. title = "legend" to the legend() call

Is there a way to use two '…' statements in a function in R?

假如想象 提交于 2019-12-17 03:26:26
问题 I want to write a function that calls both plot() and legend() and it would be ideal if the user could specify a number of additional arguments that are then passed through to either plot() or legend() . I know I can achieve this for one of the two functions using ... : foo.plot <- function(x,y,...) { plot(x,y,...) legend("bottomleft", "bar", pch=1) } foo.plot(1,1, xaxt = "n") This passes xaxt = "n" to plot. But is there a way for example to pass e.g. title = "legend" to the legend() call

Unpack a list in Python?

柔情痞子 提交于 2019-12-16 19:18:09
问题 I think 'unpack' might be the wrong vocabulary here - apologies because I'm sure this is a duplicate question. My question is pretty simple: in a function that expects a list of items, how can I pass a Python list item without getting an error? my_list = ['red', 'blue', 'orange'] function_that_needs_strings('red', 'blue', 'orange') # works! function_that_needs_strings(my_list) # breaks! Surely there must be a way to expand the list, and pass the function 'red','blue','orange' on the hoof? 回答1

Function arguments (in Python for example)

余生长醉 提交于 2019-12-13 11:19:06
问题 What are [function] arguments? What are they used for? I started learning Python very recently; I'm new to programming and I apologize for this basic question. In every Python tutorial I go through they talk about arguments . I have looked for the answer to this question and have found many answers but they are just a little too hard for me to understatnd. I may just be missing some conceptual background. So... when I define a function, what are the things in parenthesis used for? Example:

Incorrect size of array

China☆狼群 提交于 2019-12-13 10:31:44
问题 #include <stdio.h> void Heapify(int num[], int start, int end) { int root = start; while(root*2+1<=end) { // at least one child exists int swap = root; int lchild = root*2+1; int rchild = root*2+2; if(num[swap]<num[lchild]){ swap = lchild; } if(rchild<=end && num[swap]<num[rchild]){ swap = rchild; } if(swap!=root){ // swap here int temp = num[root]; num[root] = num[swap]; num[swap] = temp; root = swap; } else return; } } void buildHeap(int num[]) { int length=sizeof(num)/sizeof(num[0]); int