Search Results

Search found 13794 results on 552 pages for 'variable scope'.

Page 98/552 | < Previous Page | 94 95 96 97 98 99 100 101 102 103 104 105  | Next Page >

  • PHP Variable Passing in Foreach on same page

    - by tooly228
    I've been struggling this for a while and I simply can't figure this out. Here is my code: <?php foreach($list as $id =>$name) { echo("<td style=\"vertical-align:middle;\"> <a href=\"item=$id#confirm\" role=\"button\" data-toggle=\"modal\"> Buy</a></td></tr>"); }?> <html> <div class="modal small hide fade" id="confirm" tabindex="-1" role="dialog" aria- labelledby="myModalLabel" aria-hidden="true"> <a href="redeem.php?item=<?php echo $id; ?>"><button class="btn btn-danger"> Buy</button></a></div> The main issue here is that the $id from the foreeach is not the same as the $id in the div class link. Instead the link is the end value of the foreach list.

    Read the article

  • Removing Unused (Unreferenced) Static Global Variable Constants in C++

    - by Synetech inc.
    Hi, I have a header file with a few common constants like names and stuff that are automatically included in each project (an example follows). The thing is that they are included in the compiled binary (EXE) whether they are used (referenced) or not. If I use DEFINEs instead, then naturally they are not included if they are not used, but of course consts are better than defines so… I tried Googling it, but the closest thing I could find was a question right here on SO that did not quite help. Matters of i18n aside, how can I keep the ones that are not used out of the binary, while still keeping it easy to use like this? Thanks. //COMMON.H: static const CString s_Company _T("Acme inc."); //etc. static const CString s_Digits _T("0123456789"); //TEST.CPP: #include common.h int main() { AfxMessageBox(s_Company); } //s_Company should be in the final EXE, but s_Digits should not be, but is

    Read the article

  • Use of unassigned local variable

    - by Bob
    ... ... ... try { string Tags_collect; SqlDataReader Data1 = cmd.ExecuteReader(); Data1.Read(); lbl_q_title.Text = Data1["subject"].ToString(); Data1.NextResult(); while (Data1.Read()) { Tags_collect = Data1.GetString(0); Tags_collect= Tags_collect+ Tags_collect; } lbl_tags.Text = Tags_collect; ..... .... .... not sure why i get this error what do i miss?

    Read the article

  • Access location variable in another process

    - by user295944
    I have a locationmanager in my main program which is called HomeViewController which I get the latitude and longitude and store them in LAT and LON. I can use LAT and LON in HomeViewController just fine. Once I go to another controller which is sending pictures and setting properties on flicker I want to use LAT and LON, how do I do this? I tried putting HomeViewController.LAT but obviously that does not work, I'm pretty new to the language so I am confused.

    Read the article

  • Parallel.For(): Update variable outside of loop

    - by TSS
    I'm just looking in to the new .NET 4.0 features. With that, I'm attempting a simple calculation using Parallel.For and a normal for(x;x;x) loop. However, I'm getting different results about 50% of the time. long sum = 0; Parallel.For(1, 10000, y => { sum += y; } ); Console.WriteLine(sum.ToString()); sum = 0; for (int y = 1; y < 10000; y++) { sum += y; } Console.WriteLine(sum.ToString()); My guess is that the threads are trying to update "sum" at the same time. Is there an obvious way around it?

    Read the article

  • What Design Pattern To Replace 'CurrentStep' Variable

    - by Rob P.
    Tried to search but didn't know how to phrase it. I've got some code that is essentially... Private CurMajorStep as Integer = 0 Private CurMinorStep as Integer = 0 Public Sub PerformNextStep() Select Case iMajorStep Case 0 ThingOne() Case 1 ThingTwo() Case 2 ThingThree() Case 3 ThingFour() Case 4 AnythingElse() Case 5 Finish() End Select End Sub And then, in some of those, the CurMinorStep keeps track of the current state of that particular 'step'. I hope that all makes sense. The code is messy and I know it's going to be problematic to maintain. Can someone point me to a clean OO pattern to handle this?

    Read the article

  • simple question: Difficulty in declaring and using variable

    - by user281180
    What is wrong with the following code: I`m having the error message Error 1 ; expected <%if (Model.ReferenceFields != null) {%> <%int count = 1; %> <%foreach (var referenceName in Model.ReferenceFields) {%> <%var value = "value"; %> <%count++; %> <%value = value + count.ToString(); %> <tr> <td><input type="hidden" name="Tests.Index" value='<%value%>' /></td> <td><input type="text" name="Tests['<%value%>'].Value"/></td> <td><input type="button" value= "Add" /></td></tr> <%} %> <%} %>

    Read the article

  • Variable text in links with knockout

    - by Gepser
    I'm generating a list of links and they have not the same text but I don't know how to put a text with knockout. This is what I have: <a data-bind="attr: { href: 'Controller/Method/' + Id, 'Title': CurrentTask }"> <!-- I need the name of the CurrentTask here--> CurrentTask </a> So, the text I want to show appears only in the "alt" property but not in the text of the link. It works but I need that the name of the CurrentTask be the link and now it's just showing me everything like this: <a href...>CurrentTask</a> <a href...>CurrentTask</a> <a href...>CurrentTask</a> <a href...>CurrentTask</a> and I need this <a href...>I get this data from de controller</a> <a href...>Sometext</a> <a href...>OtherText</a> <a href...>Anything</a>

    Read the article

  • Monitor multiple variable amounts of processes' start and exit

    - by ron975
    I need some code to monitor the start and exit of processes. For example, assume I have a config file with 3 processe names, lets say, foo.exe, bar.exe and abc.exe. How I imagine this be done would be to create 3 threads and somehow listen to each process individually with a timer in each thread, and then do something afterwards. However, I would need to dynamically create threads and timers, as the config file is meant to be modifiable. I can work with VB.NET or C# Code. Thanks.

    Read the article

  • Cannot get variable.replace working properly.

    - by chrissygormley
    Hello, I am trying to replace a string with a new string in a python file and write the new string permanently to it. When I run the below script it removes part of the string and not all of it. The string in the file is: self.id = "027FC8EBC2D1" And the script I have to replace the string is: def edit(): o = open("test.py","r+") #open for line in open("test.py"): line = line.replace("027FC8EBC2D1","NewValue") o.write(line) o.close() edit() Thanks for any help.

    Read the article

  • Pass, edit and return variable in C

    - by Supertecnoboff
    I am new to C programming and recently I have been playing around with functions in C programming. But I have a simple problem: Basically I want to pass an integer to a function, have the function edit it and then pass back the integer to the main function. I am working on this but it isn't working..... Here is my code: int update_SEG_values(int DIGIT_1, int DIGIT_2) { // How many tens in the "TEMP_COUNT". DIGIT_2 = ((TEMP_COUNT) / 10); // How much is left for us to display. TEMP_COUNT = TEMP_COUNT - ((DIGIT_2) * 10); // How many ones. DIGIT_1 = ((TEMP_COUNT) / 1); return(DIGIT_1, DIGIT_2); } What am I doing wrong here?

    Read the article

  • Javascript: Inherit method from base class and return the subclass's private variable

    - by marisbest2
    I have the following BaseClass defined: function BaseClass (arg1,arg2,arg3) { //constructor code here then - var privateVar = 7500; this.getPrivateVar = function() { return privateVar; }; } I want to have the following subclass which allows changing privateVar like so: function SubClass (arg1,arg2,arg3,privateVar) { //constructor code here then - var privateVar = privateVar; } SubClass.prototype = new BaseClass(); Now I want SubClass to inherit the getPrivateVar method. However, when I try this, it always returns 7500 which is the value in the BaseClass and not the value of privateVar. In other words, is it possible to inherit a BaseClass's public methods but have any references in them refer to the SubClass's properties? And how would I do that?

    Read the article

  • access javascrip variable in java

    - by chetan
    function test(custId){ List<Account> list=accountDelegate.findAccountEntityByGroupId((long)%> custId<%)%>; <script> } Here my question is how to send custId to java method as parameter from java script.where java method takes long argument.

    Read the article

  • C++, strange behavior reusing variable name

    - by aaa
    hello. I have following snippet: { double scale = 3; // not used? { double scale = 4*scale; // what is RHS scale? for (...) { // scale is 0 here, using g++ } } } moreover, g++ reports first scale is not used. how is second scale initialize? What should be correct behavior? thanks

    Read the article

  • Accessing class variable with string name?

    - by coure06
    I have a class like this $.fn.dimeBar = function(custom) { var var1 = 'test1'; var var2 = 'test2'; if(sometest){ //how can i access var1 or var2 here by using string name of variables //some thing like alert(this['var1']) -- should alert: 'test1' } }

    Read the article

  • C/C++ variable length automatic array performance

    - by aaa
    hello. Is there significant cpu/memory overhead associated with using automatic arrays with g++/Intel on 64-bit x86 linux platform? int function(int N) { double array[N]; overhead compared to allocating array before hand (assuming function is called multiple times) overhead compared to using new overhead compared to using malloc range of N maybe from 1kb to 16kb roughly, stack overrun is not a problem Thank you

    Read the article

  • Symfony: trying to retrieve a variable saved using sfContext::getInstance()

    - by user248959
    Hi, i have these methods in module1/actions/actions.class.php: public function executeMethod1(sfWebRequest $request){ $a = 10; sfContext::getInstance()->set('a', $a); return $this->redirect('module1/method2'); } public function executeMethod2(sfWebRequest $request){ echo sfContext::getInstance()->get('a'); } When i execute module1/method1 i get this error: "The "a" object does not exist in the current context." Any idea? Javi

    Read the article

  • Access php multidimensional array key based on a variable string

    - by ggirtsou
    I have stored the XML path to items in a string like this: response->items->item. What I need to do is to access an array called $xml_array like this: $xml_array['response']['items']['item'] When I write it in the code it works. The thing is that I want it to be done on the fly. I use this to convert response->items->item to ['response']['items']['item']: $xml_path = 'response->items->item'; $explode_path = explode('->', $xml_path); $correct_string = false; foreach($explode_path as $path) { $correct_string .= '[\''.$path.'\']'; } the problem is that I can't access $xml_array by doing this: $xml_array[$correct_string] So I end up with this: $xml_tag = 'title'; $xml_path = 'response->items->item'; $correct_string = '$items = $xml2array'; $explode_path = explode('->', $xml_path); foreach($explode_path as $path) { $correct_string .= '[\''.$path.'\']'; } $correct_string .= ';'; eval($correct_string); foreach($items as $item) { echo $item[$xml_tag].'<br />'; } and access the $xml_array array through $items array. Is there any way I can do this and avoid using eval()? Thanks in advance!

    Read the article

  • Javascript jQuery .click() callback references local variable from the calling method instead of cop

    - by Eric Freese
    The following jQuery Javascript code is included on an otherwise empty page. $(function() { for (var i = 0; i < 10; i++) { element = $('<div>' + i + '</div>'); element.click(function() { alert(i); }); $('body').append(element); } }); The desired behavior is that this code should generate 10 div elements numbered from 0 to 9. When you click on a div element, an alert popup will show the number of the div element you clicked on (i.e. if a user clicks on the div element labeled '4', the alert popup should show the number 4). The alert popup instead shows the number 10 regardless of which div element is clicked on. How can I modify this code to make it behave in the desired way?

    Read the article

  • sort list(of string()) using a variable index into string() as key - vb.net

    - by tullynyguy
    I have a List(of String()). I have written a custom comparer (implements IComparer(of string)) to do an alphanumeric sort. Is there a way to sort the List using a given index to determine which position in the String() to sort by? In other words one time I might sort by Index = 0 and another time by Index = 3. The length of all String() in the list is the same. For reference this question is similar to Sort List<String[]> except I am using VB.net and that question is hardwired to Index=0.

    Read the article

  • Python: Open() using a variable

    - by nuustik
    Good day, I've ran into a problem with opening a file with randomly generated name in Python 2.6. import random random = random.randint(1,10) localfile = file("%s","wb") % random Then I get an error message about the last line TypeError: unsupported operand type(s) for %: 'file' and 'int' I just couldn't figure this out by myself nor with Google, but there has to be a cure for this, I believe. Thanks.

    Read the article

  • Extract rows for the first occurrence of a variable in a data frame

    - by user2614883
    I have a data frame with two variables, Date and Taxa and want to get the date for the first time each taxa occurs. There are 9 different dates and 40 different taxa in the data frame consisting of 172 rows, but my answer should only have 40 rows. Taxa is a factor and Date is a date. For example, my data frame (called 'species') is set up like this: Date Taxa 2013-07-12 A 2011-08-31 B 2012-09-06 C 2012-05-17 A 2013-07-12 C 2012-09-07 B and I would be looking for an answer like this: Date Taxa 2012-05-17 A 2011-08-31 B 2012-09-06 C I tried using: t.first <- species[unique(species$Taxa),] and it gave me the correct number of rows but there were Taxa repeated. If I just use unique(species$Taxa) it appears to give me the right answer, but then I don't know the date when it first occurred. Thanks for any help.

    Read the article

  • Why do @synthesize variable names begin with an _?

    - by mcjoejoe0911
    I'm just starting to use Objective-C and I need to clarify something When I @synthesize a @property, it is common convention to do the following: @interface Class : ParentClass @property propertyName @end @implementation @synthesize propertyName = _propertyName; @end I've seen plenty of questions and answers suggesting that "_propertyName" is widely accepted as the "correct" way to synthesize properties. However, does it serve ANY purpose? Or is it merely to increase readability and identify instance variables?

    Read the article

  • When designing a job queue, what should determine the scope of a job?

    - by Stuart Pegg
    We've got a job queue system that'll cheerfully process any kind of job given to it. We intend to use it to process jobs that each contain 2 tasks: Job (Pass information from one server to another) Fetch task (get the data, slowly) Send task (send the data, comparatively quickly) The difficulty we're having is that we don't know whether to break the tasks into separate jobs, or process the job in one go. Are there any best practices or useful references on this subject? Is there some obvious benefit to a method that we're missing? So far we can see these benefits for each method: Split Job lease length reflects job length: Rather than total of two Finer granularity on recovery: If we lose outgoing connectivity we can tell them all to retry The starting state of the second task is saved to job history: Helps with debugging (although similar logging could be added in single task method) Single Single job to be scheduled: Less processing overhead Data not stale on recovery: If the outgoing downtime is quite long, the pending Send jobs could be outdated

    Read the article

< Previous Page | 94 95 96 97 98 99 100 101 102 103 104 105  | Next Page >