variables

bash variable capture stderr and stdout separately or get exit value

Hi, I need to capture the output and error of a command in my bash script and know whether the command succeeded or not. At the moment, I am capturing both like this: output=$(mycommand 2>&1) I then need to check the exit value of mycommand. If it failed, I need to do some stuff with the output, if the command succeeded, I don't nee...

var keyword runtime or compile time?

var keyword gets the type at the runtime or compile time? or depends? ...

C Macro Token Concatenation involving a variable - is it possible?

Hello, I'm trying to define a macro to generate a token name, containing a variable. Basically, what I'm trying is this: #define GLUER(x,y,z) x##y##z #define PxDIR(x) GLUER(P,x,DIR) int main() { int port; port = 2; PxDIR(port) |= 0x01; } I'm hoping to generate the token P2DIR in the above statement, but according to my compile...

PHP include Problem

hey everyone i'm trying to apply some module system on my web, using get and include, here's some of my code on my index.php $section = 'user'; if(isset($_GET) && !empty($_GET) && $_GET !== ''){ $module = $_GET['module'].".php"; load_module($section, $module); } load_module function function load_module($s...

jQuery passing variabile to .css({})

I have the following function: $("#myId").css({left: leftVal+"px", top:topVal+"px"}); this works. I am looking for a way to add left: leftVal+"px", top:topVal+"px" as a variable and make my function: $("#myId").css({myCSSstuff}); I've tryed var myCSSstuff= "left: "+leftVal+"px, top:"+topVal+"px" but it does not work. Is there...

How can I make a program wait for a variable change in javascript?

I want to force a JavaScript program to wait in some particular points of its execution until a variable has changed. Is there a way to do it? I have already found an extension that is called "narrative JavaScript" that force the program to wait until an event to happen. Is there a way to create a new event, a "variable change event" for...

Efficient Declaration/Creation of variables/controls.

I'm working on cleaning up an app I'm almost finished with and I noticed something that made me curious as to why it's being done that way. While you can edit the .Designer.cs in your project for a form, there is a lot of autogenerated stuff in there, such as the creation of variables and controls. They have the Windows Form Designer g...

C++: how to create thread local/global variable

Hi, in this code: int foo() { static int x; } is the x global to all threads or local in each thread? Or does that depends on a compiler flag and/or the compiler, so I cannot really know what it is from the code? Several questions (all of them independent from compiler and compiler flags and OS): How can I create a static varia...

How to declare a variable name consisting of other varables (MATLAB)?

I have a Variable that needs to be dependent on another variable inside a loop: for n=1:100 newfilename="NEW_FILE_1.txt" end where the "1" needs to be what ever n is: So 1 for the first loop and 2 for the second loop and so on and so forth. How do you set up declaring "newfilename" to have the variable "n" variable inside its name?...

Passing Variables from Flash to PHP

Creating a flash project where users can visit the site, and turn off/on objects in a house (ie. lights, tv, computer, etc.) The next user who will visit the house in the website, will see what lights or house appliances were left on. Flash variables are passed to PHP, and those variables are saved in an XML file. (For testing to see wha...

global variable in R function

I created a function for processing some of my data, like this: a <- "old" test <- function (x) { assign(x, "new", envir = .GlobalEnv) } test(a) But I can't see the a change from "old" to "new", I guess this is some of the "global variable", any suggestion? Thanks! ...

Overrible predefined Bash variables with arguments

Can someone point me out what is the problem when I want to overrible a default value in a variable with an argument in Bash? The following code doesn't work: #!/bin/bash VARIABLE1="defaultvalue1" VARIABLE2="defaultvalue2" # Check for first argument, if found, overrides VARIABLE1 if [ -n $1 ]; then VARIABLE1=$1 fi # Check for seco...

Reuse Variable across Wordpress Templates

Hi, I query some information in my wordpress blog's header. How can I reuse the variable say in the sidebar of the blog? If I try something like this in the sidebar, the output stays blank: <?php if(isset($my_header_variable)) echo $my_header_variable; ?> ...

storing file path using windows explorer browser in python

Dear All, I have written some encryption code in python that takes raw input message from user and then encrypts and decrypts it using AES. Now i want to enhance the working and i want that i can open the windows explorer from my code and browse to any file on my computer, select it and when i press OK button the path to file is stored ...

Returning a variable value to a rake script

I'm executing a rake script that calls a powershell function. The function returns a value, how can i get this value and provide it to my rake template file? Thanks for any suggestions ...

How to return a class variable as a reference (&/ampersand) in PHP?

This is sample of my code. class SomeClass extends SomeOtherClass { function __construct($input) { parent::__construct($input); $this->conn = new mysqli('a','b','c','d'); } function getConnection() { return &$this->conn; } } My main object is that i want to return the MySQLi connection by referencing it instead of creating another ...

How can you use variables or references in SQL?

In the following: (running a query on the Stack Exchange Data Explorer, which uses an SQL Azure implementation of OData. The FAQ says it supports most of the TSQL commands): DECLARE @MinPosts int = ##MinNumberOfPosts## SELECT Id AS [User Link], Reputation, (SELECT COUNT(*) FROM posts WHERE posts.OwnerUserId = Users.I...

JavaScript: Can you substitute variables into anonymous functions on creation?

Possible Duplicate: Javascript closure inside loops - simple practical example Rather than explaining the question, I'll give an example: for (var i = 0; i < 100; i ++) { get_node(i).onclick = function() { do_something_very_important(i); } } Is there any way to have the value of i substituted into the function upon ...

Filling in a docvariable in Word docx using C#

I've done this a hundred times in VB 6 but it's driving me nuts using C# 2008 and Word 2007. I created a docx file with two docvariables: Some text here.... {docvariable replace1} {docvariable replace2} More text here...... I created a macro first to do it and it works: Sub FillDocVariable() ' ' FillDocVariable Macro ' ' Active...

Regex that matches valid Ruby local variable names

Does anyone know the rules for valid Ruby variable names? Can it be matched using a RegEx? UPDATE: This is what I could come up with so far: ^[_a-z][a-zA-Z0-9_]+$ Does this seem right? ...