variables

final and static in Java

I have read this sentence in a book but I didn't understand it: A field that is both static and final has only one piece of storage that cannot be changed. Can anyone explain it for me? ...

MATLAB: Checking type of table

I want to ask how to check if a variable is table 1x8 or 8x1 of type logical? I know I can check the class of an array for logical like this: strcmp(class(a),'logical') I know I can get the size of table like this: [h w] = size(a); if(w==1 & h==8 | w==8 & h==1) But what if table has more than 2 dimensions? How can I get number of d...

Validating a string in Java

I have a question about validation in Java, I have looked at previous topic and none seem to answer my little problem. What I am trying to do is validate what is put into a string variable in the constructor but also when a set method is used. What I need to is If Mr Miss Mrs or Ms is entered, then to set that in a Variable (title) if ...

jquery variables, the difference between with and without $ prefix

Hi there, I have read another post/question regarding jquery variables and it was useful but I'm still having trouble understanding... Below is a bit of code from a simple tabbed content functionality that I'm modifying. Please could someone explain why this works: $tabMenuItem.click(function() { var activetab = $(this).find(...

Javascript Regex: How to put a variable inside a REGEX?

So for example: function(input){ var testVar = input; string = ... string.replace(/ReGeX + testVar + ReGeX/, "replacement") } But this is of course not working :) Is there any way to do this? ...

Why does "variable = 1" not assign a variable in Python?

Why does Python complain about chrome being referenced before assignment? It does not complain about the dictionary. This is with Python 2.5 if it makes a difference. def f(): google['browser'] = 'chrome' chrome += 1 google = dict() chrome = 1 f() I can make it work with global chrome of course, but I'd like to know why Python do...

Javascript: Building an array with a variable

Is it possible to take the contents of a variable and stick it into an array like so (I've tried to no avail): First I get these values from a database and using php form into a hidden input: {value: '1', name: 'name1'},{value: '2', name: 'name2'} Then collect with javascript document.getElementById("myelement").value Then put the...

Is it bad to declare a page variables in ASP.NET?

Not sure if "page variable" is the right word, but i'm thinking something like this: using System; . . . namespace whatever { public partial class Submit : Page { int id; protected void Page_Load() { id = getid(); } . . . Obviously I will be using id at some point later (not in PageLoad)....

Why is this jQuery not working?

$(function () { var sr = 'section.row'; var fot = 'figure.one_third'; var pA = 'div.portfolio ul li a'; var item = ('sr fot pA'); $item.addClass('blue'); }); http://jsfiddle.net/G8yJj/13/ << ...

How does PHP know what type of variables it uses (or does it)?

I haven't done much programing in many languages, but I know in C(++), you have to declare a variable type (int,char,etc). In PHP you, of course, don't have to do that. You can start with $str = "something"; then later $str = array("something" => "smells"); and she is happy. How does PHP compile? How does it know what the variable typ...

How do I get around not being able to parse a table name into a python sqlite query?

I have a python3 program that I'm making which uses a sqlite database with several tables, I want to create a selector module to allow me to chose which table to pull data from. I have found out that I can't use paramater substitution for a table name as shown bellow, so I'm looking for some alternative methods to accomplish this. c.ex...

How can I pass a url or variable from Perl to PHP?

I have two existing scripts that work fine as individuals. The main script is Perl. I wish to execute the PHP script from a sub in the Perl script. Usually, the PHP script is just run via direct url e.g. http://me.com/phpscript.php?foo=bar I would like to just call the PHP script from the Perl and pass the foo var so, I don't need to ...

WebCab.Libraries.Statistics.dll

hi guys, I wonder if anyone used the library "WebCab.Libraries.StatisticsDemo.dll" before As i want to create an exponential random variable and i don't have any documentation for the library thanks in advance ...

ruby: how to load .rb file in the local context

How this simple task can be done in Ruby? I have some simple config file === config.rb config = { 'var' => 'val' } I want to load config file from some method, defined in main.rb file so that the local variables from config.rb became local vars of that method. Something like this: === main.rb Class App def loader load('co...

How to make JavaScript Math.random Repeat?

Hi, basically i have a page on my site with boxes that slide to reveal a background color. I want this background color to be random on load of page by adding a class to the element, eg .blue, .green etc... I have created this code and as you may notice this randomly sorts the color class and applies to the element, this works for the f...

javascript / jquery using a variable to reference diferent parts of a json/xml object

I'd like to create a function which can cope with JSON in the following nested format. The keys will change ie conditions - could be anything and the subcondition key could be anything but the structure remains the same. My function is defined as populatePageEditorMenu: function (jsonPath, topLevel, childLevel){ and called by ...

Save text from webpage to String variable

Hello! I want to save something from a webpage (loaded into webview) into a Java variable. Is that possible? Example: I have a webpage with written text: HELLO STACK!. How could I save that text into Java var (String foo = ?????)? Could I do it with JavaScript/Java cooperation? ...

SSIS set variable at runtime

Anyone know how I can change a SSIS variable at runtime? I have a variable User:SkipStuff I want to set this based on a condition during a for loop container ...

Dynamic title in php

I am Trying to get the page title (<title>bla..bla..bla..</title>) to be changable in php with a multi-file layout like so: Functions.php is included into index.php, then get_header() is called from functions.php to include the page header.php the title tag is inside the header file. I would like to be able to set the title from index.ph...

Variables in Haskell

Why does the following Haskell script not work as expected? find :: Eq a => a -> [(a,b)] -> [b] find k t = [v | (k,v) <- t] Given find 'b' [('a',1),('b',2),('c',3),('b',4)], the interpreter returns [1,2,3,4] instead of [2,4]. The introduction of a new variable, below called u, is necessary to get this to work: find :: Eq a => a -> [(...