variables

how do i create a variable from another variable name?

ok...in php how do i do this? given the following scenario: // array of letters var $letters = array('a', 'b', 'c'); // loop through array and create empty arrays with names like $a, $b, $c foreach($letters as $letter) { var $$letter = array(); } ...

In Javascript, <int-value> == "<int-value>" evaluates to true. Why is it so?

If I do 0 == "0" it evaluates to true. Try, if( -777 == "-777" ) alert("same"); alert happens. And, it's also noticeable that true == "true" doesn't evaluate to true. Try, if( false == "false" ) alert("same"); alert doesn't happen. Why is it so? ...

How to expand variables in vim commands?

I'm trying to get a variable expanded in a command call. Here's what I have in my .vimrc: command! -nargs=1 -complete=dir TlAddPm call s:TlAddPm(<f-args>) function! s:TlAddPm(dir) let flist = system("find " . shellescape(a:dir) . " -type f -name '*.pm' | sort") TlistAddFiles `=flist` endfun At the : prompt, the `=flist` syntax...

Consecutive SQL statements with state

I'm writing a simple messaging program, where there is a table of messages, which can be claimed by users and have stuff done to them by that user. It isn't predestined which user will claim a given message and so I want a query to select the first of all the available messages, which I have, and then one to mark that message as take, wh...

Constant server variables?

What's the easiest way of storing a single number on a server so that any script can access it, using PHP? Currently, I have a number stored in a file, but this seems somewhat inelegant. ...

Using variable name as array index

Hi everyone, I have few files which I put in array. I shuffle the files so that it can be displayed in random order. How to know that array index 0 is actually image1.txt or image2.txt or image3.txt? Thanks in advance. String[] a = {"image1.txt","image2.txt","image3.txt"}; List<String> files = Arrays.asList(a); Collections.shuffle(fi...

Variables that work everywhere

How can I set variables that work everywhere? My .bashrc has: Questions='/Users/User/Stackoverflow/Questions' Address='My address' My file has: $Questions $Addres The command "$ cat my_file" in Shell prints "$Questions" and "$Address", instead of "/Users/User/Stackoverflow/Questions" and "My address". Other places where I would li...

Initialize final variable before constructor in Java

Is there a solution to use a final variable in a Java constructor? The problem, if I init. a final var. like: private final String name = "a name"; then I cannot use it in the constructor, while java first runs the constructor an then the fields... Is there a solution to get in contact with the final var. in the constructor? ...

SQL server name of columns as variables

I have the following statement in a stored procedure. I am passing the name of the column as parameter and also the value to be checked in another variable. Is it possible to accomplish this in SQL server. Please let me know. SELECT CaseId FROM app_Case where @SearchCat=@keywords ORDER BY CreatedDate DESC ...

Use XSLT Variable as Field Name

Hi .... I have an XSLT variable that I'm creating and populating with the value of an attribute at the top of the style sheet like so ... <xsl:variable name="MyAttributeValue" select="/Source/Fields/Field[@SpecialAttribute]/@MyAttributeValue" /> Later on in the processing, I want to use $MyAttributeValue as a field name just lik...

sql variables

Can somebody help me figure out why the sql statement doesn't like the following line ' and ' + @SearchCat + 'like '%'+@Keywords+'%''. It has to do with the number of single quotes but I can't figure out. How do the quotes work. What's the logic? DECLARE @strStatement varchar(550) declare @state as varchar(50) declare @district as varc...

Python: How to extract variable name of a dictionary entry?

I'm wondering how I would go about finding the variable name of a dictionary element: For example: >>>dict1={} >>>dict2={} >>>dict1['0001']='0002' >>>dict2['nth_dict_item']=dict1 >>>print dict2 {'nth_dict_item': {'0001': '0002'}} >>>print dict2['nth_dict_item'] {'001': '002'} How can I go about making...

getting external variables via file - eval/include

This should be fairly simple from what I can find online, but I can't seem to get it to work. I've got a widget which I want to enable others to edit (text, images, css, etc). so I've provided them the ability to pass an external page in via a url variable. The problem is that I can't then access the values they provide via the page...

Query will not run with variables, will work when variable's definitions are pasted in.

This is a Query in VBA (Access 2007) I have 3 strings defined: str_a = "db.col1 = 5" str_b = " and db.col2 = 123" str_c = " and db.col3 = 42" Then I use these in the WHERE part of my Query: "WHERE '" & str_a & "' '" & str_b & "' '" & str_c & "' ;" This fails, but If I paste in the strings like this: "WHERE db.col1 = 5 and db.col2 ...

How can I capture the text between specific delimiters into a shell variable?

Hello, I have little problem with specifying my variable. I have a file with normal text and somewhere in it there are brackets [ ] (only 1 pair of brackets in whole file), and some text between them. I need to capture the text within these brackets in a shell (bash) variable. How can I do that, please? ...

img src won't work with php variables

<a href="'.$productLink.'" alt="'.$productName.'"> <img src="'.$productImg1URL.'" alt="'.$productName.' '.$productType.' "> </a> Hello the img src is actually in a different directory /images I know this is probably super easy but Ive spent an hour on it and nothing. The page works but doesn't show the directory. Please help the roo...

Declaring Multiple Variables in JavaScript

Hello, In JavaScript, it is possible to declare multiple variables like this: var variable1 = "Hello World!"; var variable2 = "Testing..."; var variable3 = 42; ...or like this: var variable1 = "Hello World!", variable2 = "Testing...", variable3 = 42; Is one method better/faster than the other? Thanks, Steve ...

load values from textfile in matlab

I would like to load variabless from an textfile. e.g my text file varA varB varC In Matlab I would like to give these variables values so that every var is a 2x2 matrix so from the textfile containing the above information i would get an matrix that looks like this: [ 1 2 3 4 5 6; 1 2 3 4 5 6] Is this possible? added a second ex...

Variable Scope issue in C#

Here is the deal. I have a Master-Detail Grid scenario. The Master GridView is loaded when the page is loaded. I am using a DataView of same DataTable which loads the Master to load the Detail GridView, by filtering what I need to show in the DetailGridView. Everything works fine when I view the first row of the MasterGridView. When I tr...

"Large multiple variable echo's" way to make simpler?

Hey, Say I am echoing a large amount of variables in PHP and I wont to make it simple how do i do this? Currently my code is as follows but it is very tedious work to write out all the different variable names. echo $variable1; echo $variable2; echo $variable3; echo $variable4; echo $variable5; You will notice the variable name is th...