Search Results

Search found 11238 results on 450 pages for 'miserable variable'.

Page 31/450 | < Previous Page | 27 28 29 30 31 32 33 34 35 36 37 38  | Next Page >

  • Local variable and Try/Catch

    - by 3D-kreativ
    I get an error, a red line below the variable intAge in the if-statement in the code. It says the variable is local, but how could it be local when it is declared in the beginning of the code? Does it have to do with the Try/Catch part? The reason why my code looks like it does, is just beacuse I have to use a Try/Catch in the code for this task. Preciate some suggestions to solve this in a similiar and correct way? Thanks! int intAge; try { intAge = int.Parse(age); } catch (Exception) { MessageBox.Show("Enter an age in numbers!","Error!"); } finally { } // Check input if (intAge < 1) { inputOk = false; errorMessage = "Please enter 1 or higher!"; }

    Read the article

  • Passing a variable that can be updated

    - by Rob Bonner
    This seems like a simple thing, but can't get it to work. I pass a variable into a UIViewController thourgh a standard property: [aViewController setProposedDate:proposedWorkLog.entryDate]; which is retained by the controller, and possible changed. I have verified that in the controller, the data is modified. But, after it is popped off the stack and I look in the calling view, the data has not been updated. Is there a way to pass this variable and have it retain the new value, or a way to pass back a response from a closing view controller? Thanks!

    Read the article

  • how to take input for uint32_t variable

    - by sksingh73
    i have declared a variable as uint32_t num; when i take input for this variable i.e cinnum; cout< when i run this program, i gives num value as 12345678, it works fine & give cout. but when i give input as 1234abcd. it creates problem & displays only 1234. please suggest solution to resolve this problem.

    Read the article

  • [Bash] Save part of matching pattern to variable

    - by Ben
    I want to extract a substring matching a pattern and save it to a file. An example string: Apr 12 19:24:17 PC_NMG kernel: sd 11:0:0:0: [sdf] Attached SCSI removable disk I want to extract the part between the brackets, in this case []. I tried to do something like grep -e '[$subtext]' to save the text in the brackets to a variable. Of course it doesn't work, but I am looking for a way similar to this. It would be very elegant to include a variable in a regex like this. What can I do best? Thanks!

    Read the article

  • woocommerce show attribute description when selecting a variable

    - by user2916995
    I'm trying to figure out a way to display custom text based on the users selection of the variable product. The attribute is 'pricing' and the tag is deposit - which I've added a text description to when adding the attribute. So I'm trying to make this text appear when the user selects 'deposit' But the code I'm using in 'content-single-product.php' is displaying the text all the time no matter what variable is selected or not. <?php $my_taxonomy = 'pa_pricing'; $terms = wp_get_post_terms( $post->ID, $my_taxonomy ); echo term_description($terms[0]->term_id, $my_taxonomy); ?> I only want the text to be displayed after the user has selected pricing 'deposit' Can someone help me with this?

    Read the article

  • Capture variable assignments in a Perl eval

    - by Bruce
    I would like to be able to capture variable assignments from a Perl eval. That is, to determine what variable names have been assigned to within the code and extract their value. For example if I run: eval '$foo=42; $bar=3.14;' The result of the eval is 3.14 (the last value evaluated), but I would also like to be able to determine the names "$foo" and "$bar" and their values (without knowing the names in advance). I have read up on a couple of ways of inserting variables into the eval block, through Safe and Eval::Context, but not yet any way of extracting them. I am more familiar with Python's eval/exec which have built in support for this.

    Read the article

  • PHP and Javascript: Getting file contents with Javascript variable

    - by celliott1997
    Could someone help me to understand why this isn't working? var uname = "<?php echo strtolower($_GET['un']) ?>"; var source = "<?php echo file_get_contents('accounts/"+uname+"') ?>"; console.log(source); I've been trying for a while to get this working and it just doesn't seem to. Before I added in the source variable, it was working fine and displayed the un variable on the page. Thanks.

    Read the article

  • asp.net C# variable as Image1.ImageUrl property

    - by ModS
    I would like to Click "buttonImage1" and have that store "photos/Image1.jpg" into a var called Photo. then have ButtonImage2.ImageUrl = (Photo). I am using an UpdatePanel to refresh the area with the images so the only problem is actually setting the variable correctly and then using it correctly. Reworded: how can I store a path to an image in a variable then set it correctly as a image's URL path? protected void Button2_Click(object sender, ImageClickEventArgs e) { Evt = ("~/events/ev2.jpg"); } protected void Image2_Click(object sender, ImageClickEventArgs e) { Image1.ImageUrl = (Evt); }

    Read the article

  • Save data from array in variable

    - by marcin_poland
    SOLVED! I`m trying save data from array in variable. I have in controller: $data = array('upload_data' => $this->upload->data()); and I know that in this array are data about uploading file. One with this date is "file_name", and I want to save this value in controller at variable. I try with: $image_name= $data['file_name']; But this not working. I use CodeIginter 2.1.3 framework. Good solution is: $data['upload_data']['file_name']; Thanks for help!

    Read the article

  • xsl:variable xsl:copy-of select

    - by user1901345
    I have the following XML: Picture 1 Picture 2 Picture 3 While this XSL does what is expected (output the attr of the first picture): It seems to be not possible to do the same inside the variable declaration using xsl:copy-of: Curious: If I just select "$FirstPicture" instead of "$FirstPicture/@attr" in the second example, it outputs the text node of Picture 1 as expected... Before you all suggest me to rewrite the code: This is just a simplified test, my real aim is to use a named template to select a node into the variable FirstPicture and reuse it for further selections. I hope someone could help me to understand the behavior or could suggest me a proper way to select a node with code which could be easily reused (the decission which node is the first one is complex in my real application). Thanks.

    Read the article

  • php define variable inside str_replace array

    - by john
    I have a template system, that replaces text such as {HEADER} with the appropriate content. I use an array like this, that replaces the key with the value using str_replace. $array = array("HEADER","This is the header"); foreach($array as $var => $content) { $template = str_replace("{" . strtoupper($var). "}", $content,$template); } Now im trying to use a defined variable like this: define("NAME","Site Name"); Inside the value for the header. So I want the defined variable to be inside the array which gets replaced so it would look like this, but it doesn't work. $array = array("HEADER","Welcome to ".NAME."'s website!"); Any ideas? tell me if im not clear

    Read the article

  • Checking variable from a different class in C#

    - by Josh
    Greetings- I have 2 classes. One is called "Programs" and the other is called "Logs". The class called Programs has public const string m_sEnviron = ""; near the top and I need to check what the m_sEnviron variable is set to through my class called Logs. The variable m_sEnviron will get set from a scheduler called Tidal so how can I check its value from a different class. If this is not the best to do this then please let me know what the better ways are. Thanks in advance. Regards,

    Read the article

  • PHP Losing variable data

    - by Conor B
    Hi, I'm having an issue with PHP losing data in a variable. There is quite a bit of data in the variable, because it basically contains a binary file, but I'm wondering if this is cause for it to completely lose it's information. Looking at a snippet from my code which is used to deal with email attachments: var_dump($data) if (array_key_exists('filename', $params) || array_key_exists('name', $params)) { var_dump($data) ... } The first var_dump gives the desired output of the file: "string(283155) " --Apple-Mail-5-930065543 ... etc while the second gives an output of: string(0) "" ... string(0) "" Any idea why this is happening? Does PHP just drop data in variables if they are really large? (I didn't think so, as I've never had this problem before) If so, any workaround? Thanks!

    Read the article

  • Vim: `cd` to path stored in variable

    - by tsyu80
    I'm pretty new to vim, and I'm having a hard time understanding some subtleties with vim scripting. Specifically, I'm having trouble working with commands that expect an unquoted-string (is there a name for this?). For example cd some/unquoted/string/path The problem is that I'd like to pass a variable, but calling let pathname = 'some/path' cd pathname will try to change the current directory to 'pathname' instead of 'some/path'. One way around this is to use let cmd = 'cd ' . pathname execute cmd but this seems a bit roundabout. This StackOverflow question actually uses cd with a variable, but it doesn't work on my system ("a:path" is treated as the path as described above). I'm using cd as a specific example, but this behavior isn't unique to cd; for example, the edit command also behaves this way. (Is there a name for this type of command?)

    Read the article

  • Select value from database and store into a temporary variable

    - by user1616230
    I want to select a stored value from database and then put it into a temporary variable. For example, I have a column called category, one value under it is m, so I want to select this m value from the database, let's say from a table of a database called user_info. Then I want to put it into a variable, let's name it $res. After that, I want to do some condition stuff, such as if $res=="m", Can anyone help me write a simple structure here? Here is the code: <?php $sql = "Select category FROM user_info WHERE user_name = '" .$_SESSION['username']."' and password = '".$_SESSION['password']."'"; $res = mysql_query($sql); if($res == "a"){ include('MPIncomeStrategy.php'); } if($res == "b"){ include('MPIncomeStrategy.php'); } But it seems that the code is not able to detect $res =="category value in database". Did I just use the wrong way to store the category value?

    Read the article

  • Javascript scope chain

    - by Geromey
    Hi, I am trying to optimize my program. I think I understand the basics of closure. I am confused about the scope chain though. I know that in general you want a low scope (to access variables quickly). Say I have the following object: var my_object = (function(){ //private variables var a_private = 0; return{ //public //public variables a_public : 1, //public methods some_public : function(){ debugger; alert(this.a_public); alert(a_private); }; }; })(); My understanding is that if I am in the some_public method I can access the private variables faster than the public ones. Is this correct? My confusion comes with the scope level of this. When the code is stopped at debugger, firebug shows the public variable inside the this keyword. The this word is not inside a scope level. How fast is accessing this? Right now I am storing any this.properties as another local variable to avoid accessing it multiple times. Thanks very much!

    Read the article

  • Which of the following Java coding fragments is better?

    - by Simon
    This isn't meant to be subjective, I am looking for reasons based on resource utilisation, compiler performance, GC performance etc. rather than elegance. Oh, and the position of brackets doesn't count, so no stylistic comments please. Take the following loop; Integer total = new Integer(0); Integer i; for (String str : string_list) { i = Integer.parse(str); total += i; } versus... Integer total = 0; for (String str : string_list) { Integer i = Integer.parse(str); total += i; } In the first one i is function scoped whereas in the second it is scoped in the loop. I have always thought (believed) that the first one would be more efficient because it just references an existing variable already allocated on the stack, whereas the second one would be pushing and popping i each iteration of the loop. There are quite a lot of other cases where I tend to scope variables more broadly than perhaps necessary so I thought I would ask here to clear up a gap in my knowledge. Also notice that assignment of the variable on initialisation either involving the new operator or not. Do any of these sorts of semi-stylistic semi-optimisations make any difference at all?

    Read the article

  • Color variables in photoshop?

    - by Ezdaroth
    I'm doing a lot of website design and I'm looking for a feature that would allow me to set the main colors of website in variables and use the variables in color overlays and such. It would make changing the color scheme of site a lot easier and that would help previewing different possibilities. So, does such feature exists, or is there some kind of plugin for it? I'm using CS3 and I have CS4 available if it's required for this.

    Read the article

  • Highlight identical strings in vi(m)

    - by Boldewyn
    One feature of Notepad++, which I find really useful and haven't found elsewhere, is the highlighting of other text that is identical to the one currently selected. Is there something similar possible with vi(m)? (Of course, there is. But how do I achieve it?) That is, any of those: If I am in Visual Mode and have text selected: Highlight identical text If I have searched /foo, highlight all instances of foo. If I am at the beginning of a string (series of characters, numbers or underscores), highlight all other matching strings (prefered solution). The last one is similar to the closing parentheses matching and IMHO the most useful. Edit: For my second use case, I found a solution (that is, Google found it...): :set hls However, the others remain.

    Read the article

  • Do I need more RAM for programming if I switch to a 64 Bit OS?

    - by Buttercup
    Hi, Given that today (for performance reasons?) variables are usually aligned to the "bit-width" (I wanted to use "word-width" here, but on x86 a "word" is still 16 bits right?) of the processor, would switching from a 32 bit OS to its 64 bit version double the RAM usage? Would this then in turn mean that to do the same work a 32 bit OS can do with 4 GB RAM (well, the 3.x GB actually...) with a 64 bit OS I would need 8 GB of RAM for programming? Please note that I'm only talking about everyday x86 computers here.

    Read the article

  • Variable mysteriously changing value

    - by Eitan
    I am making a simple tcp/ip chat program for practicing threads and tcp/ip. I was using asynchronous methods but had a problem with concurrency so I went to threads and blocking methods (not asynchronous). I have two private variables defined in the class, not static: string amessage = string.Empty; int MessageLength; and a Thread private Thread BeginRead; Ok so I call a function called Listen ONCE when the client starts: public virtual void Listen(int byteLength) { var state = new StateObject {Buffer = new byte[byteLength]}; BeginRead = new Thread(ReadThread); BeginRead.Start(state); } and finally the function to receive commands and process them, I'm going to shorten it because it is really long: private void ReadThread(object objectState) { var state = (StateObject)objectState; int byteLength = state.Buffer.Length; while (true) { var buffer = new byte[byteLength]; int len = MySocket.Receive(buffer); if (len <= 0) return; string content = Encoding.ASCII.GetString(buffer, 0, len); amessage += cleanMessage.Substring(0, MessageLength); if (OnRead != null) { var e = new CommandEventArgs(amessage); OnRead(this, e); } } } Now, as I understand it only one thread at a time will enter BeginRead, I call Receive, it blocks until I get data, and then I process it. The problem: the variable amessage will change it's value between statements that do not touch or alter the variable at all, for example at the bottom of the function at: if (OnRead != null) "amessage" will be equal to 'asdf' and at if (OnRead != null) "amessage" will be equal to qwert. As I understand it this is indicative of another thread changing the value/running asynchronously. I only spawn one thread to do the receiving and the Receive function is blocking, how could there be two threads in this function and if there is only one thread how does amessage's value change between statements that don't affect it's value. As a side note sorry for spamming the site with these questions but I'm just getting a hang of this threading story and it's making me want to sip cyanide. Thanks in advance. EDIT: Here is my code that calls the Listen Method in the client: public void ConnectClient(string ip,int port) { client.Connect(ip,port); client.Listen(5); } and in the server: private void Accept(IAsyncResult result) { var client = new AbstractClient(MySocket.EndAccept(result)); var e = new CommandEventArgs(client, null); Clients.Add(client); client.Listen(5); if (OnClientAdded != null) { var target = (Control) OnClientAdded.Target; if (target != null && target.InvokeRequired) target.Invoke(OnClientAdded, this, e); else OnClientAdded(this, e); } client.OnRead += OnRead; MySocket.BeginAccept(new AsyncCallback(Accept), null); } All this code is in a class called AbstractClient. The client inherits the Abstract client and when the server accepts a socket it create's it's own local AbstractClient, in this case both modules access the functions above however they are different instances and I couldn't imagine threads from different instances combining especially as no variable is static.

    Read the article

  • Problem with sending out variable to serial port using api JAVA

    - by sjaakensjon
    We are developing a java program for school. But we are experiencing problems with sending out a variable created by 3 sliders. The idea is that we have 3 sliders. One slider for every color. Red green and blue. The variable has to have a value between 0 and 255. Everytime the value of the slider changes is has to send a variable for the channel, that value is 1, 2 ,3. And after that it has to send the value of the slider through the serial port. Could you please help us out by creating an example program? Below is our code so far. Thanks in advance. Sjaak package main; import javax.swing.*; import javax.swing.event.*; import java.awt.*; import app.Com; import app.Parameters; public class menu{ JSlider sliderblauw; JLabel hoeveelblauw; JLabel blauw; JLabel rood; JSlider sliderrood; JLabel hoeveelrood; JLabel groen; JLabel hoeveelgroen; JSlider slidergroen; public menu(){ Frame venster = new JFrame("Color control"); JPanel blauwinstel = new JPanel(); ((JFrame) venster).setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); venster.setSize(500, 500); venster.setVisible(true); sliderblauw = new JSlider(JSlider.VERTICAL, 0, 255, 0); sliderblauw.addChangeListener(new veranderingblauw()); hoeveelblauw = new JLabel ("0"); blauwinstel.add(sliderblauw); blauwinstel.add(hoeveelblauw); venster.add(blauwinstel, BorderLayout.WEST); sliderblauw.setMajorTickSpacing(10); sliderblauw.setPaintTicks(true); JPanel roodinstel = new JPanel(); sliderrood = new JSlider(JSlider.VERTICAL, 0, 255, 0); sliderrood.addChangeListener(new veranderingrood()); hoeveelrood = new JLabel ("0"); roodinstel.add(sliderrood); roodinstel.add(hoeveelrood); venster.add(roodinstel, BorderLayout.EAST); sliderrood.setMajorTickSpacing(10); sliderrood.setPaintTicks(true); JPanel groeninstel = new JPanel(); slidergroen = new JSlider(JSlider.VERTICAL, 0, 255, 0); slidergroen.addChangeListener(new veranderinggroen()); hoeveelgroen = new JLabel ("0"); groeninstel.add(slidergroen); groeninstel.add(hoeveelgroen); venster.add(groeninstel, BorderLayout.CENTER); slidergroen.setMajorTickSpacing(10); slidergroen.setPaintTicks(true); } public class veranderingblauw implements ChangeListener{ public void stateChanged(ChangeEvent ce){ int value = sliderblauw.getValue(); String waarde_blauw = Integer.toString(value); hoeveelblauw.setText(waarde_blauw); }} public class veranderingrood implements ChangeListener{ public void stateChanged(ChangeEvent ce){ int value = sliderrood.getValue(); String waarde_rood = Integer.toString(value); hoeveelrood.setText(waarde_rood); }} public class veranderinggroen implements ChangeListener{ public void stateChanged(ChangeEvent ce){ int value = slidergroen.getValue(); String waarde_groen = Integer.toString(value); hoeveelgroen.setText(waarde_groen); }} public static void main( String[] args) { new menu(); } }

    Read the article

< Previous Page | 27 28 29 30 31 32 33 34 35 36 37 38  | Next Page >