Search Results

Search found 12106 results on 485 pages for 'variable operators'.

Page 5/485 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • How to permanently change a variable in a Python game loop

    - by Wehrdo
    I have a game loop like this: #The velocity of the object velocity_x = 0.09 velocity_y = 0.03 #If the location of the object is over 5, bounce off. if loc_x > 5: velocity_x = (velocity_x * -1) if loc_y > 5: velocity_y = (velocity_y * -1) #Every frame set the object's position to the old position plus the velocity obj.setPosition([(loc_x + velocity_x),(loc_y + velocity_y),0]) Basically, my problem is that in the if loops, I change the variable from its original value to the inverse of its old value. But because I declare the variable's value at the beginning of the script, the velocity variables don't stay on what I change it to. I need a way to change the variable's value permanently. Thank you!

    Read the article

  • How to change a variable type in C#?

    - by Mosho Mulan
    I wanted to use something like this: if(x==5) { var mydb= ........ ; } else { var mydb = ........ ; } but it didn't work because I can't declare a variable inside if statement. So I tried to do this: var mydb; if (x==5) { mydb= ............. ; } else { mydb=.............; } but id didn't work either because I had to initialize the variable (mydb). So the question is: I don't necessarily know the type of the variable, can I declare it anyway and then change the type inside the if statement?

    Read the article

  • Correct syntax for matching a string inside a variable against an array

    - by Jamex
    Hi, I have a variable, $var, that contains a string of characters, this is a dynamic variable that contains the values from inputs. $var could be 'abc', or $var could be 'blu', I want to match the string inside variable against an array, and return all the matches. $array = array("blue", "red", "green"); What is the correct syntax for writing the code in php, my rough code is below $match = preg_grep($var, $array); (incorrect syntax of course) I tried to put quotes and escape slashes, but so far no luck. Any suggestion? TIA

    Read the article

  • Please explain this php expression "!$variable"

    - by DogBot
    What does an exclamaton mark in front of a variable mean? And how is it being used in this piece of code? EDIT: From the answers so far I suspect that I also should mention that this code is in a function where one of the parameters is $mytype ....would this be a way of checking if $mytype was passed? - Thanks to all of the responders so far. $myclass = null; if ($mytype == null && ($PAGE->pagetype <> 'site-index' && $PAGE->pagetype <>'admin-index')) { return $myclass; } elseif ($mytype == null && ($PAGE->pagetype == 'site-index' || $PAGE->pagetype =='admin-index')) { $myclass = ' active_tree_node'; return $myclass; } elseif (!$mytype == null && ($PAGE->pagetype == 'site-index' || $PAGE->pagetype =='admin-index')) { return $myclass; }`

    Read the article

  • Variable scope problem in JavaScript

    - by dfjhdfjhdf
    I declare a variable with the var word inside a function that handles Ajax requests, then later on in the function I have another function that should change the value of the variable but - my problem - it fails. How to settle the problem down? Here's similiar code I use: function sendRuest(someargums) { /* some code */ var the_variable; /* some code */ //here's that other function request.onreadystatechange = function() { if (request.readyState == 4) { switch (request.status) { case 200: //here the variable should be changed the_variable = request.responseXML; /* a lot of code */ //somewhere here the function closes } return the_variable; } var data = sendRequest(someargums); //and trying to read the data I get the undefined value

    Read the article

  • Android Static Variable Scope and Lifetime

    - by Edison
    I have an application that has a Service uses a ArrayList to store in the background for a very long time, the variable is initialized when the service started. The service is in the background and there will be frequent access to the variable (that's why i don't want to use file management or settings since it will be very expensive for a file I/O for the sake of battery life). The variable will likely to be ~1MB-2MB over its life tie. Is it safe to say that it will never be nulled by GC or the system or is there any way to prevent it? Thanks.

    Read the article

  • Working with Reporting Services Filters – Part 3: The TOP and BOTTOM Operators

    - by smisner
    Thus far in this series, I have described using the IN operator and the LIKE operator. Today, I’ll continue the series by reviewing the TOP and BOTTOM operators. Today, I happened to be working on an example of using the TOP N operator and was not successful on my first try because the behavior is just a bit different than we find when using an “equals” comparison as I described in my first post in this series. In my example, I wanted to display a list of the top 5 resellers in the United States for AdventureWorks, but I wanted it based on a filter. I started with a hard-coded filter like this: Expression Data Type Operator Value [ResellerSalesAmount] Float Top N 5 And received the following error: A filter value in the filter for tablix 'Tablix1' specifies a data type that is not supported by the 'TopN' operator. Verify that the data type for each filter value is Integer. Well, that puzzled me. Did I really have to convert ResellerSalesAmount to an integer to use the Top N operator? Just for kicks, I switched to the Top % operator like this: Expression Data Type Operator Value [ResellerSalesAmount] Float Top % 50 This time, I got exactly the results I expected – I had a total of 10 records in my dataset results, so 50% of that should yield 5 rows in my tablix. So thinking about the problem with Top N some  more, I switched the Value to an expression, like this: Expression Data Type Operator Value [ResellerSalesAmount] Float Top N =5 And it worked! So the value for Top N or Top % must reflect a number to plug into the calculation, such as Top 5 or Top 50%, and the expression is the basis for determining what’s in that group. In other words, Reporting Services will sort the rows by the expression – ResellerSalesAmount in this case – in descending order, and then filter out everything except the topmost rows based on the operator you specify. The curious thing is that, if you’re going to hard-code the value, you must enter the value for Top N with an equal sign in front of the integer, but you can omit the equal sign when entering a hard-coded value for Top %. This experience is why working with Reporting Services filters is not always intuitive! When you use a report parameter to set the value, you won’t have this problem. Just be sure that the data type of the report parameter is set to Integer. Jessica Moss has an example of using a Top N filter in a tablix which you can view here. Working with Bottom N and Bottom % works similarly. You just provide a number for N or for the percentage and Reporting Services works from the bottom up to determine which rows are kept and which are excluded.

    Read the article

  • Python large variable RAM useage

    - by PPTim
    Hi, Say there is a dict variable that grows very large during runtime- up into millions of key:value pairs. Does this variable get stored in RAM,effectively using up all the available memory and slowing down the rest of the system? Asking the interpreter to display the entire dict is a bad idea, but would it be okay as long as one key is accessed at a time? Tim

    Read the article

  • Accessing MasterPage variable in content page

    - by mattgcon
    I am trying to reference a variable within my MasterPage but I am receiving errors. I have tried <%@ MasterType" %: which gives the following error: `Compiler Error Message: CS0030: Cannot convert type 'IPAMIntranet.IPAMIntranetMaster' to 'ASP.ipamintranetmaster_master' and "string tVar = ((MyNamespace.MyMasterPage)Master).variable" which gives the following error: `Unable to cast object of type 'ASP.ipamintranetmaster_master' to type 'IPAMIntranet.IPAMIntranetMaster'.` Does anyone know what is happening or am I missing something.

    Read the article

  • PHP: Assigning values to a variable inside IF statement

    - by Matt
    Hi guys, I was wondering if i could assign values to a variable inside an IF statement. My code is as follows: <?php if ((count($newArray) = array("hello", "world")) == 0) { // do something } ?> So basically i want assign the array to the $newArray variable, then count newArray and check to see if it is an empty array. I know i can do this on several lines but just wondered if i could do it on one line Thanks M

    Read the article

  • Variable within variable possible?

    - by JM4
    I am trying to create a loop statement for some of my code and am wondering how I can put a variable within another variable. For example: <?php $j=1; while ($j <= 9): { $f$jfname = $_SESSION['F$jFirstName']; $f$jmi = $_SESSION['F$jMI']; $f$jlname = $_SESSION['F$jLastName']; } $j++; endwhile; ?> Where the goal is to have the j variable increase during the loop and change the values as: $f1fname $f2fname $f3fname and so on. Any ideas?

    Read the article

  • FORTRAN: determine variable type

    - by tibbs
    hello, GOOGLE has yet to find an answer for me, so here goes: In FORTRAN, is there a way to determine the TYPE of a variable? E.G., pass the variable type as an argument in a function, to then be able to call type-specific code with that fuction; eliminating the need to have seperate similar functions for each data type. thanks.

    Read the article

  • send javaScript variable to php variable

    - by mrbunyrabit
    First i thought that i had to convert javascript to php, but then i found out that cant because of server and client side executions. So now I simply want to send ONE variable <script type="text/javascript"> function scriptvariable() { var theContents = "the variable"; } </script> to a php variable <?php $phpvariable ?> That function in the javascript executes when lets say i click on a button. Now i have Nooo idea how to get that phpvariable Equal to the javascript one so i can use that phpvariable to look up stuff in my Database. I know i can add it to my url or some thing, and just refresh the page.. But id like to do it with AJAX as further in my webpage i might have to use this Ajax method.. So is there an easy way to do this without having to dump pages of code on my page to do one simple thing?

    Read the article

  • t-sql get variable value from string with variable name

    - by Markus
    Hi. Is there a way to convert '@my_variable' string into a value of @my_variable? I have a table which stores names of variables. I need to get the value of this variable. Something like this: DECLARE @second_variable AS NVARCHAR(20); DECLARE @first_variable AS NVARCHAR(20); SET @first_variable = '20'; SET @second_variable = SELECT '@first_variable'; --here I want that @second variable be assigned a value of "20".

    Read the article

  • Logical value of an assignment in C

    - by Andy Shulman
    while (curr_data[1] != (unsigned int)NULL && ((curr_ptr = (void*)curr_data[1]) || 1)) Two part question. What will (curr_ptr = (void*)curr_data[1]) evaluate to, logically. TRUE? Also, I know its rather hack-ish, but is the while statement legal C? I would have to go through great contortions to put the assignment elsewhere in the code, so I'd be really nice if I could leave it there, but if it's so egregious that it makes everyone's eyeballs burst into flames, I'll change it.

    Read the article

  • PHP Variable Variable inside []'s

    - by Homer_J
    Hi all, I hope there is a simple solution! I have a variable: $results['q1']; Is it possible to have the 'q1' element as a variable, something like this: $results['$i[question]']; Have not been able to find a solution on Google and researching the PHP manuals... Anyone got a suggestion/ solution? Thanks, Homer.

    Read the article

  • How to increment variable names/Is this a bad idea

    - by tom
    In Python, if I were to have a user input the number X, and then the program enters a for loop in which the user inputs X values, is there a way/is it a bad idea to have variable names automatically increment? ie: user inputs '6' value_1 = ... value_2 = ... value_3 = ... value_4 = ... value_5 = ... value_6 = ... Can I make variable names increment like that so that I can have the number of variables that the user inputs? Or should I be using a completely different method such as appending all the new values onto a list?

    Read the article

  • .htaccess add hidden php get variable for language selection

    - by Eric Di Bari
    I have a multiple language website, and I use a php get variable to set the cookie for the language setting. I have multiple subfolders (http://www.site.com/es and http://www.site.com/de) that each have a respective .htaccess file. When accessing these folders, the .htaccess file does this to "silently" redirect the user and add the appropriate php variable: ------- Options +FollowSymlinks RewriteEngine on RewriteOptions MaxRedirects=10 rewriterule ^http://www.site.com/es/$ http://www.site.com/?l=es [P,R=301] rewriterule ^(.*)$ http://www.site.com/$1?l=es [P,R=301] ------- When someone accesses the root directory: http://www.site.com, I want to add a ?l=en suffix "silently" to the url. How do I do that? Thanks.

    Read the article

  • assign operator to variable in python?

    - by abhilashm86
    Usual method of applying mathematics to variables is a * b Is it able to calculate and manipulate two operands like this? a = input('enter a value') b = input('enter a value') op = raw_input('enter a operand') then how do i connect op and two variables a and b?? i know i can compare op to +, -, %, $ and then assign and compute.... but can i do something like a op b , how to tell compiler that op is an operator?? any tweaks possible?

    Read the article

  • What's the diffrence btw System property and system environment variable

    - by khue
    Hi all I am not clear about this. When I run a java App or run an Applet in applet viewer,( in the IDE environment), System.getProperty("java.class.path") give me the same as System.getenv("CLASSPATH"), which is the CLASSPATH env variable defined. But when I deploy my applet to webserver and access it from the same computer as a client, I get different result for the two (System.getProperty("java.class.path") only point to jre home and System.getenv("CLASSPATH") return null). And here is some other things that make me wonder: For the applet part, the env var JAVA_HOME, i get the same result when deploying the applet in a browser as well as Applet Viewer. And if I define myself a env variable at system level, and use getenv("envName") the result is null. Is there anyway I can define one and get it in my java program? Thanks a lot Regards K.

    Read the article

  • Ruby on Rails - Adding variable to params[]

    - by miligraf
    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, etc.) and the value is set according to the radio button selected within the group: Radio button "group_01DRN0" could have value of "21" or "22" or "23", radio button "group_01AAI0" could have value of "21" or "22" or "23", etc. In the DB I have every code (01DRN0, 01AAI0, 01AUI0, etc) so I want to select them from DB and iterate in the params value so I can get the radio button group value, I've tried this with no luck: @codes=Code.get_codes for c in @codes @all=params[:group_] + c.name end Thanks.

    Read the article

  • Java: Checking contents of char variable with if condition

    - by Troy
    Hello, I have a char variable that is supposed to contain either a Y,y,n or N character, I want to test if it does not contain it, then display an error message and exit the program. This is the code I am using; if (userDecision != 'Y' || userDecision != 'y' || userDecision != 'n' || userDecision != 'N') { System.out.println("Error: invalid input entered for the interstate question"); System.exit(0); } Irregardless of what is in the variable it always returns true and executes the command to exit the program, what am I doing wrong?

    Read the article

  • Basic Python: Exception raising and local variable scope / binding

    - by SuperJdynamite
    I have a basic "best practices" Python question. I see that there are already StackOverflow answers tangentially related to this question but they're mired in complicated examples or involve multiple factors. Given this code: #!/usr/bin/python def test_function(): try: a = str(5) raise b = str(6) except: print b test_function() what is the best way to avoid the inevitable "UnboundLocalError: local variable 'b' referenced before assignment" that I'm going to get in the exception handler? Does python have an elegant way to handle this? If not, what about an inelegant way? In a complicated function I'd prefer to avoid testing the existence of every local variable before I, for example, printed debug information about them.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >