variables

What does the @ in this code sample mean?

Html.TextBox("ParentPassword", "", new { @class = "required" }) what the gosh darned heck is the @ for the @class. ...

Choosing when to instantiate classes

I recently wrote a class for an assignment in which I had to store names in an ArrayList (in java). I initialized the ArrayList as an instance variable private ArrayList<String> names. Later when I checked my work against the solution, I noticed that they had initialized their ArrayList in the run() method instead. I thought about this ...

PHP Templating

I'm writing a simple templating layer in PHP but I've got myself a little stuck. Here's how it works at the moment: Firstly I use fetch_template to load the template contents from the database - this works (and I collect all the templates at startup if you're interested). I use PHP variables in my template code and in the logic - e.g.:...

Mutability and Reference of PHP5 GET Variables

I have the following in a page e.g. /mypage?myvar=oldvalue $_SESSION['myvar'] = $_GET['myvar']; $myvar = 'a_new_string' Now $_SESSION['myvar'] has the value 'a_new_string' Is this by design? How can I copy the value of 'myvar' rather than a reference to it? ...

can a variable have multiple values

In algebra if I make the statement x + y = 3, the variables I used will hold the values either 2 and 1 or 1 and 2. I know that assignment in programming is not the same thing, but I got to wondering. If I wanted to represent the value of, say, a quantumly weird particle, I would want my variable to have two values at the same time and to...

Performing Interactive queries in MySql (mainly from the GUI)

I mainly use the MySQL GUI tools. This allows me to easily see the results in a table as well as to quick edits and bookmark frequently run queries. This suits my needs far better than the command line. I remember when I used to do this on Oracle DBs years ago I could put variables in the query itself, so that when running the query I g...

Where do you declare variables? The top of a method or when you need them?

Hi, I am in sort of a dilemma (in a geekish way of course). I love to declare variables at the beginning of my methods, and usually order them in some logical way. The problem is, when the list gets long, it sort of gets out of hand. Should I just declare them when I need them? ...

JavaScript Parent variables

I have the following code: var address; getAddress(0,0); function getAddress(latlng) { if (latlng != null) { geocoder.getLocations(latlng, function(addresses) { if(addresses.Status.code == 200) { address = addresses.Placemark[0].address.toString(); alert(address); // Outputs something :...

PHP 3 to PHP 5 Upgrade... Variables in 3 didn't have $ in front... is there a setting for back compat?

OK, this is an odd request, and it might not even be fully true... but I'm upgrading someone's system ... and they are using OSCommerce (from a long time ago). It appears their variables are referrenced without a dollar sign in front of them (which is new to me). I haven't done PHP in about 7 years, and I've always used dollar signs. I...

Static Variables, Separate Compilation

Hi, I wrote a program out, which was all in one file, and the methods were forward declared in a header. The program initially worked perfectly when it was in one file. But when I separated the program, I kept getting random occurrences for the destructor of one of the classes which was declared in the header file. I have a static v...

Java Manifest.mf classpath issues

Hi all - I've been trying to run a jar file - let's call it test.jar - that uses the Sybase jconn3.jar on a Unix system. I have created a MANIFEST.MF file that has the following: Class-Path: $SYBASE/jConnect-6_0/classes/jconn3.jar commons-net-1.3.0.jar This gives a ClassNotFoundError. $SYBASE is the system variable that points to /o...

Check variable type in C++

So I am currently learning C++ and decided to make a program that tests my skills I have learned so far. Now in my code I want to check if the value that the user enters is a double, if it is not a double I will put a if loop and ask them to reenter it. The problem I have is how do I go about checking what type of variable the user enter...

if statement inside a variable

I am building a conditional navigation menu that has 3 levels (the 3rd level added today by business, no worries its not like I launch next week. Oh wait I do:)). I have a javascript var that contains the html for my first conditional level. I am now trying to insert another level inside of the first. var myVar = '<ul class="linksUnit"...

Lambdas with captured variables.

Consider the following line of code: private void DoThis() { int i = 5; var repo = new ReportsRepository<RptCriteriaHint>(); // This does NOT work var query1 = repo.Find(x => x.CriteriaTypeID == i).ToList<RptCriteriaHint>(); // This DOES work var query1 = repo.Find(x => x.CriteriaTypeID == 5).ToList<RptCr...

java session variables

i'm hearing that some people believe storing info on the server in a session is a bad idea, that its not secure. as a result, in a multi-page business process function, the application is writing data to a db, then retrieving the info when its needed. is there something necessarily unsafe about storing private info in a session? ...

Why can't variable names start with numbers?

I was working with a new c++ developer a while back when he asked the question: "Why can't variable names start with numbers?" I couldn't come up with an answer except that some numbers can have text in them (123456L, 123456U) and that wouldn't be possible if the compilers were thinking everything with some amount of alpha characters wa...

when to pass a parameter and when to use an instance variable

How do you guys decide between keeping track of something locally and then just passing it in to every method you call on it, or declaring an instance variable and using it in the methods? I tend to prefer instance variables kept in a list at the end of the Class. But as my programs become more and more complicated, this list gets longe...

How to declare variables

A colleague of mine and I have been discussing how to declare variables in a function. Let's say you have a class called TStrings (using Delphi for the sake of explanation) that has at least one abstract method and a descendant class called TStringList which obviously implements the abstract method, but it introduces nothing else you ne...

Store Variable Name in String in VB.NET

I'm trying to store the names of some variables inside strings. For example: Dim Foo1 as Integer Dim Foo1Name as String ' -- Do something to set Foo1Name to the name of the other variable -- MessageBox.Show(Foo1Name & " is the variable you are looking for.") ' Outputs: ' Foo1 is the variable you are looking for. This would help with...

A small question about python's variable scope

I am a beginner of python and have a question, very confusing for me. If I define a function first but within the function I have to use a variable which is defined in another function below, can I do it like this? Or how can I import the return things of another function into a function? for example: def hello(x,y): good=hi(iy,ix) ...