So I've a string:
string x = "DR\nDC\nDD";
I want to get each line in a separated variable like this:
string y1 = "DR";
String y2 = "DC";
String y3 = "DD";
How can I do that?.
I am trying to pass a variable from one page, load another and enter that information.
something Like this:
When 127.0.0.1/test.html&ID=1234
location.href = "127.0.0.1/newpage.html"
if (location.href == newpage.html){
var e = document.GetElementById("Loginbx");
e.Value = ID
}
I don't have access to modify 127.0.0.1/test.html nor newpage.html but would like to pass variables to them from another. Is this possible?
I have a for loop, and inside it a variable is assigned with var. Also inside the loop a method is called which requires a callback. Inside the callback function I'm using the variable from the loop. I would expect that it's value, inside the callback function, would be the same as it was outside the callback during that iteration of the loop. However, it always seems to be the value from the last iteration of the loop.
Am I misunderstanding scope in JavaScript, or is there something else wrong?
The program in question here is a node.js app that will monitor a working directory for changes and restart the server when it finds one. I'll include all of the code for the curious, but the important bit is the parse_file_list function.
var posix = require('posix');
var sys = require('sys');
var server;
var child_js_file = process.ARGV[2];
var current_dir = __filename.split('/');
current_dir = current_dir.slice(0, current_dir.length-1).join('/');
var start_server = function(){
server = process.createChildProcess('node', [child_js_file]);
server.addListener("output", function(data){sys.puts(data);});
};
var restart_server = function(){
sys.puts('change discovered, restarting server');
server.close();
start_server();
};
var parse_file_list = function(dir, files){
for (var i=0;i<files.length;i++){
var file = dir+'/'+files[i];
sys.puts('file assigned: '+file);
posix.stat(file).addCallback(function(stats){
sys.puts('stats returned: '+file);
if (stats.isDirectory())
posix.readdir(file).addCallback(function(files){
parse_file_list(file, files);
});
else if (stats.isFile())
process.watchFile(file, restart_server);
});
}
};
posix.readdir(current_dir).addCallback(function(files){
parse_file_list(current_dir, files);
});
start_server();
The output from this is:
file assigned: /home/defrex/code/node/ejs.js
file assigned: /home/defrex/code/node/templates
file assigned: /home/defrex/code/node/web
file assigned: /home/defrex/code/node/server.js
file assigned: /home/defrex/code/node/settings.js
file assigned: /home/defrex/code/node/apps
file assigned: /home/defrex/code/node/dev_server.js
file assigned: /home/defrex/code/node/main_urls.js
stats returned: /home/defrex/code/node/main_urls.js
stats returned: /home/defrex/code/node/main_urls.js
stats returned: /home/defrex/code/node/main_urls.js
stats returned: /home/defrex/code/node/main_urls.js
stats returned: /home/defrex/code/node/main_urls.js
stats returned: /home/defrex/code/node/main_urls.js
stats returned: /home/defrex/code/node/main_urls.js
stats returned: /home/defrex/code/node/main_urls.js
For those from the future: node.devserver.js
I've found many definitions of the 'var' statement but most of them are incomplete (usually from introductory guides/tutorials). Should I use 'var' if the variable & scope has been declared in the params list?
someFunc = function(someVar)
{
// Is it considered good practice to use 'var', even if it is redundant?
var someVar = cheese;
};
Okay, I have a ViewController that has 12 UIButtons as instance variables, and they are created in interface builder. I want to access another variable in the viewController from the UIButton's init method. Is that possible?
By the way, I'm writing in Objective-C in the iPhone SDK.
Cheers.
Is there any way in Firebug to search an active variable in Javascript by it's value?
I've looked everywhere and can't find an answer!
Thank you so much in advance!!!!!!
somevar := apple
export somevar
update := $(shell echo "v=$$somevar")
all:
@echo $(update)
I was hoping to apple as output of command, however it's empty, which makes me think export and := variable expansion taking place on different phases. how to overcome this?
I would like to have a FORTRAN write statement formatted to depend on some variable.
For example, I could write:
write(*,'(3f15.3,3f9.2)') x,y,z,(var(i),i=1,nvari)
where nvari = 3
But, what if, in some cases, I actually have 4 variables (i.e. nvari = 4)
I would like to write something like this:
write(*,'(3f15.3,nvari(f9.2))') x,y,z,(var(i),i=1,nvari)
Now, nvari can be anything and the output will work as I like.
How can I make something like this work?
cat test.cpp
#include <iostream>
int main() {
int à;
}
results in:
clang++ test.cpp
test.cpp:4:7: error: expected unqualified-id
int à;
^
1 error generated.
Now, is there a way to get clang to allow unicode variable names?
Thanks!
I have a file that looks something like this:
ABC
DEF
GHI
I have a shell variable that looks something like this:
var="MRD"
What I want to do, is to make my file look like this:
ABC
MRD
DEF
GHI
I was trying to do this:
sed -i -e 's/ABC/&$var/g' text.txt
but it only inserts $var instead of the value. I also tried this:
sed -i -e 's/ABC/&"$var"/g' text.txt
but that didn't work either. Any thoughts?
Thanks!
I'm using silverlight, project structure is similiar to any other .net app. I have a map control that I would like to store what mode it is in (either road or aerial) so that other controls can access this.
Where do I put this enum variable, I plan to use 2 way binding on it so both are updated when either changes.
Thanks.
For some unknown reason I'm running into a problem when passing a variable to a full text search stored procedure performs many times slower than executing the same statement with a constant value. Any idea why and how can that be avoided?
This executes very fast:
SELECT * FROM table
WHERE CONTAINS (comments, '123')
This executes very slowly and times out:
DECLARE @SearchTerm nvarchar(30)
SET @SearchTerm = '123'
SET @SearchTerm = '"' + @SearchTerm + '"'
SELECT * FROM table
WHERE CONTAINS (comments, @SearchTerm)
Does this make any sense???
So I've found out that setting the PATH environment variable affects only the old command prompt, powershell seems to have different environment settings. How do I change the environment variables for powershell (v1)?
Note:
I want to make my changes permanent, so I don't have to set it every time I run powershell. Does powershell have a profile file? Something like bash profile on unix?
Is there anything similar to global variable in SSIS? I have 4 variables (FromAddress, ToAddress,...) which will be used in all packages (32).
So if I can set them only once it will be very easy to use in all packages and will save my time.
Please advise.
In my view, if I have a situation where I need to use a dynamic method (such as Domain.findByName("name")) in multiple places, would it be better to define a variable with and refer to that, rather than have the dynamic method in multiple places? I know this seems like an obvious answer, but I just wanted to make sure Grails doesn't cache it or something, and indeed two DB calls are being made.
I have done urlencode of the variable before passing to the URL
http://example.com/Restaurants?aliasF%26B
But when I try to print like in the page
$alias = rawurldecode($_GET['alias']);
echo $alias;
it prints only F. How to solve this?
Hi.
how can I have a field with variable type in my class? I use hibernate annotation for mapping to DB. I tried to use java.io.Serializable as field's type, but it mapped to database as a 01 amount which is true if I get it's object and cast it to it's true type. but I need to run a query on this objects that needs true amount of field.(right now I can't compare an integer field with a number)
Does anyone have any idea how can I do this?
Thanks in advance.
I have a trigger which deals with some data for logging purposes like so:
CREATE TRIGGER trgDataUpdated
ON tblData FOR UPDATE
AS
BEGIN
INSERT INTO tblLog ( ParentID, OldValue, NewValue, UserID )
SELECT deleted.ParentID, deleted.Value, inserted.Value,
@intUserID -- how can I pass this in?
FROM inserted INNER JOIN deleted ON inserted.ID = deleted.ID
END
How can I pass in the variable @intUserID into the above trigger, as in the following code:
DECLARE @intUserID int
SET @intUserID = 10
UPDATE tblData
SET Value = @x
PS: I know I can't literally pass in @intUserID to the trigger, it was just used for illustration purposes.
For this Java code:
String var;
clazz.doSomething(var);
Why does the compiler report this error:
Variable 'var' might not have been initialized
I thought all variables or references were initialized to null. Why do you need to do:
String var = null;
??
I'm trying to write a Cocoa app that makes it easier for Android developers on Macs to create Android apps.
When a user presses a button on the app, I want it to add a certain directory to the environmental $PATH variable on the Mac.
Is there another way to do this via Cocoa instead of opening up the .bash_profile file and adding the path manually?
Thanks for any help in advance.
Hello
I am using Dreamweaver CS5 with Coldfusion 9 to build a dynamic website. I have a MS Access Database that stores login information which includes ID, FullName, FirstName, LastName, Username, Pawword, AcessLevels.
My question is this:
I currently have session variable to track the Username when it is entered into the login page. However I would like to use that Username to pull the User's FullName to display throughout the web pages and use for querying data. How do I change the session variable to read that when they are not entering their FullName on the login page but only Username and password.
I have listed my login information code below if there is any additional information needed please let me know.
This is the path for which the FullName values reside DataSource "Access" Table "Logininfo" Field "FullName" I want the FullName to be unique based on the Username submitted from the Login page.
I apologize in advance for any rookie mistake I may have made I am new to this but learning fast! Ha.
<cfif IsDefined("FORM.username")>
<cfset MM_redirectLoginSuccess="members_page.cfm">
<cfset MM_redirectLoginFailed="sorry.cfm">
<cfquery name="MM_rsUser" datasource="Access">
SELECT FullName, Username,Password,AccessLevels FROM Logininfo WHERE Username=<cfqueryparam value="#FORM.username#" cfsqltype="cf_sql_clob" maxlength="50"> AND Password=<cfqueryparam value="#FORM.password#" cfsqltype="cf_sql_clob" maxlength="50">
</cfquery>
<cfif MM_rsUser.RecordCount NEQ 0>
<cftry>
<cflock scope="Session" timeout="30" type="Exclusive">
<cfset Session.MM_Username=FORM.username>
<cfset Session.MM_UserAuthorization=MM_rsUser.AccessLevels[1]>
</cflock>
<cfif IsDefined("URL.accessdenied") AND false>
<cfset MM_redirectLoginSuccess=URL.accessdenied>
</cfif>
<cflocation url="#MM_redirectLoginSuccess#" addtoken="no">
<cfcatch type="Lock">
<!--- code for handling timeout of cflock --->
</cfcatch>
</cftry>
</cfif>
<cflocation url="#MM_redirectLoginFailed#" addtoken="no">
<cfelse>
<cfset MM_LoginAction=CGI.SCRIPT_NAME>
<cfif CGI.QUERY_STRING NEQ "">
<cfset MM_LoginAction=MM_LoginAction & "?" & XMLFormat(CGI.QUERY_STRING)>
</cfif>
</cfif>
i want to create a form for users to submit questions in django ..so far the models i have created are
class Question(models.Model):
statement=models.CharField(max_length=100)
class Choice(models.Model):
statement=models.CharField(max_length=100)
value=models.IntegerField()
question=models.ForeignKey(Question)
Now i want to write a Form class for creating a above form but the problem is the number of choices are variable,a user can decide how many choices a question must have .How do i do that in django?
Hi, please, what contains the fstream variable? A can find many tutorials on fstream, but no ona actually says what is the fstream file; declaration in the beginning. Thanks.