variables

Printing Variable names and contents as debugging tool; looking for emacs/Python shortcut

I find myself adding debugging "print" statements quite often -- stuff like this: print("a_variable_name: %s" % a_variable_name) How do you all do that? Am I being neurotic in trying to find a way to optimize this? I may be working on a function and put in a half-dozen or so of those lines, figure out why it's not working, and then cu...

Which is the most accurate way to check variables type JavaScript?

I need to check the type of a variable in JavaScript. I know 3 ways to do it: instanceof operator: if(a instanceof Function) typeof operator: if(typeof a=="function" toString method (jQuery uses this): Object.prototype.toString.call(a) == "[object Function]" Which is the most accurate way to do type checking beetween these solutions?...

update global variable from a function in the javascript

Here is the situation: I have one function which has local variable. I would like to assign that value to global variable and us it's value in another function. Here is the code: global_var = "abc"; function loadpages() { local_var = "xyz"; global_var= local_var; } function show_global_var_value() { alert(global_var); }...

Know if a variable is a native object in javascript

Hi, is there a way to know if a variable passed into a function is a native object? I mean, i have a function that requires only native objects as arguments, for every other type of variable it throws an error. So: func(Array); //works func(String); //works func(Date); //works func(Object); //works ... func([]); //Throwr error func({});...

Javascript, jquery - Call array position by using a variable name

I have 2 arrays: var array1 = [50,60]; var array2 = [120,180]; I am passing a value to a variable like this: var curId = $(this).attr('id'); I want to set the content of #result to a computation like this: $(#result).text(number * curId[0]); Number is a variable predefined by me, and curId[0] shoul actually translate to array1[0]...

Delphi Unit local variables - how to make each instance unique?

Ok, this, I'm sure is something simple that is easy to do. The problem : I've inherited scary spaghetti code and am slowly trying to better it when new features need adding - generally when a refactor makes adding the new feature neater. I've got a bunch of code I'm packing into a single unit which, in different places in the appli...

C++ this as thread parameter, variables unavailable

I have three classes: class Rtss_Generator { int mv_transfersize; } class Rtss_GenSine : Rtss_Generator class Rtss_GenSineRpm : Rtss_GenSine Rtss_GenSine creates a thread in his constructer, it is started immediatly and the threadfunction is off-course declared static, waiting for an event to start calculating. the problem: all t...

Using jquery alerts dialog plugin, how do I send a value in a form to a callback feature? The form is in the alert.

Using jquery alerts dialog plugin, how do I send a value in a form that is displayed in an alert, to a callback feature? The form is in the alert, and the callback happens after I click OK. This is code that works, ignore this code as it is a working example, it basically shows how a form can be serialised. This code is taken from the J...

Working with strings in C++

Hi. I'm working with strings in C++. I recently came across a problem when entering strings. I'm using cin >> string; to get my string as user input. When the user enters a space into the string, the next input is automatically filled out with the remaining letters, or sometimes left blank. As the next input string is often an integer, t...

MYSQL variables - SET @var

I am attempting to create a mysql snippet that will analyse a table and remove duplicate entries (duplicates are based on two fields not entire record) I have the following code that works when I hard code the variables in the queries, but when I take them out and put them as variables I get mysql errors, below is the script SET @tblna...

Problem sending php variables to flash game, on facebook

When I run the app for the first time in a session it works great i get all data form Database(if i logout, and enter with a diffrent account)the swf does not receive the variables. If i run manually the script typing the url address in the browser (typing: http://myserver.com/app/variables.php), and refresh the facebook app, it receives...

Using variables within Attributes in C#

We have some Well-Attributed DB code, like so: [Display(Name = "Phone Number")] public string Phone { get; set; } Since it is quite generic we'd like to use it again, but with a different string in the Name part of the attribute. Since it's an attribute it seems to want things to be const, so we tried: const string AddressType =...

Bash Color Variable Output

I've got a variable, let's say $x and it holds the value of website.com. I want to be able to call the variable and apply shell color to it like so: echo -e '\033[1;32m$x:\033[0m'; The problem is not the color, however, it's how the script it interpretting the output. So the output I'm getting is: $x: I need the output to obvious...

Passing Flash variables to PHP.

Hi, I have a simple standalone application written in Visual Basic that I'm porting to a browser based application using PHP/javascript. The original VB application has some simple embedded flash games with token and point counters. The token and point values are being passed as variables between the application and the game. I'm tryi...

PHP: filter string to work as a function name

what is a quick way to filter a string to work as a function name? note: I'm thinking something like filter_var(). ...

How can I see a variable defined in another php-file?

I use the same constant in all my php files. I do not want to assign the value of this variable in all my files. So, I wanted to create one "parameters.php" file and to do the assignment there. Then in all other files I include the "parameters.php" and use variables defined in the "parameters.php". It was the idea but it does not work. ...

Apply Button() to an element inside a variable

If have a variable data = '<div>... <button id="remember"> ... </button> ...</div>', is it possible to apply the .button(); method to a button inside that variable? I've tried the following: $('#remember', data).button(); but that doesn't work. After that i just do $(data).dialog();, which works. I've come with a workaround and that...

Disabling Text field with Javascript when value in drop down box is from mysql

Hi I have a simple script in HTML, using a dropdown menu. When the value 1 is selected, the user can write in the text field, if value 2 is selected, it disables the text field. However, i changed the values of the dropdown menu, so that one value was from a mysql table(using PHP) and the other remained 'option value='1''. Yet now neit...

Ruby on Rails - Adding variable to params[]

In the controller, how can I add a variable at the end of a params[]? If I try this I get an error: params[:group_] + variable How should it be done? Edit per request Ok, I have a form that sets groups of radio buttons with names like this: group_01DRN0 Obviously I have different groups in the form (group_01AAI0, group_01AUI0, et...

Why are variables set on a page load not available in the document.ready scope?

I have an included javascript file thats initializes an empty array object called "widgets" var Widgets = {}; function Widget(a,b,c){ this.a = a; ... } in the same include a bunch of function prototypes are defined to add widget info to a widget: Widget.prototype.addWidgetInfo(a,b,c){ this.info.a = a; this.info.b = b; ... } the...