Search Results

Search found 6805 results on 273 pages for 'variables'.

Page 10/273 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • Ruby class instance variables and inheritance

    - by rlandster
    I have a Ruby class called LibraryItem. I want to associate with every instance of this class an array of attributes. This array is long and looks something like ['title', 'authors', 'location', ...] Note that these attributes are not really supposed to be methods, just a list of attributes that a LibraryItem has. Next, I want to make a subclass of LibraryItem called LibraryBook that has an array of attributes that includes all the attributes of LibraryItem but will also include many more. Eventually I will want several subclasses of LibraryItem each with their own version of the array @attributes but each adding on to LibraryItem's @attributes (e.g., LibraryBook, LibraryDVD, LibraryMap, etc.). So, here is my attempt: class LibraryItem < Object class << self; attr_accessor :attributes; end @attributes = ['title', 'authors', 'location',] end class LibraryBook < LibraryItem @attributes.push('ISBN', 'pages'] end This does not work. I get the error undefined method `push' for nil:NilClass

    Read the article

  • Global variables in Python

    - by rejinacm
    A global variable created in one function cannot be used in another function directly. Instead I need to store the global variable in a local variable of the function which needs its access. Am I correct? Why is it so?

    Read the article

  • Using Session Variables inside an ajax document

    - by Pete Herbert Penito
    Hi, For some reason I've having problems reading this session variable within an ajax document, I've got this inside online.php: ` session_start(); if (isset($_SESSION['username'])) { $username = $_SESSION['username']; } ` For some Reason this is not setting username even when the session var is being used on the host page, i call on the php file every second using this ` $(document).ready(function() { var refreshId = setInterval(function() { $('#timeval').load('online.php'); }, 1000); $("#stop").click(function() { clearInterval(refreshId); }); }); ` Am I doing something wrong, or is this not even possible?? Any advice would really help thanks alot!

    Read the article

  • How can I set environment variables depending on directory

    - by kjs3
    If I have 'export BLA="hey there"' in .profile in my home directory, how can I change this later in other directories just by cd into the other directory? Also, is there a way to just set a new environment variable when I cd into a directory. My first attempt was to just make another .bashrc file in the directory where I want the change but apparently that proved less than effective. I'm on OS X btw.

    Read the article

  • Define variables outside the PHP class.

    - by Muhammad Sajid
    Hello, I m using zend. I want to define the below code outside the controller class & access in different Actions. $user = new Zend_Session_Namespace('user'); $logInArray = array(); $logInArray['userId'] = $user->userid; $logInArray['orgId'] = $user->authOrgId; class VerifierController extends SystemadminController { public function indexAction() { // action body print_r($logInArray); } } How it is possible.

    Read the article

  • Java accessing variables using extends

    - by delo
    So here I have two classes: Customer Order Class and Confirmation Class. I want to access the data stored in LastNameTextField (Customer Order Class) and set it as the text for UserLastNameLabel (Confirmation Class) after clicking a "Submit" button. For some reason however, the output displays nothing. Snippet of my code: package customer_order; public class customer_order extends Frame{ private static final long serialVersionUID = 1L; private JPanel jPanel = null; private JLabel LastNameLabel = null; protected JTextField LastNameTextField = null; private JButton SubmitButton = null; public String s; public customer_order() { super(); initialize(); } private void initialize() { this.setSize(729, 400); this.setTitle("Customer Order"); this.add(getJPanel(), BorderLayout.CENTER); } /** * This method initializes LastNameTextField * * @return javax.swing.JTextField */ public JTextField getLastNameTextField() { if (LastNameTextField == null) { LastNameTextField = new JTextField(); LastNameTextField.setBounds(new Rectangle(120, 100, 164, 28)); LastNameTextField.setName("LastNameTextField"); } return LastNameTextField; } /** * This method initializes SubmitButton * * @return javax.swing.JButton */ private JButton getSubmitButton() { if (SubmitButton == null) { SubmitButton = new JButton(); SubmitButton.setBounds(new Rectangle(501, 225, 96, 29)); SubmitButton.setName("SubmitButton"); SubmitButton.setText("Submit"); SubmitButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed() //THE STRING I WANT s = LastNameTextField.getText(); java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new confirmation().setVisible(true); } }); } }); } return SubmitButton; } package customer_order; public class confirmation extends customer_order{ private static final long serialVersionUID = 1L; private JPanel jPanel = null; // @jve:decl-index=0:visual-constraint="58,9" private JLabel LastNameLabel = null; private JLabel UserLastNameLabel = null; // @jve:decl-index=0: /** * This method initializes frame * * @return java.awt.Frame */ public confirmation() { super(); initialize(); } private void initialize() { this.setSize(729, 400); this.setTitle("Confirmation"); this.add(getJPanel(), BorderLayout.CENTER); } /** * This method initializes jPanel * * @return javax.swing.JPanel */ private JPanel getJPanel() { if (jPanel == null) { UserLastNameLabel = new JLabel(); UserLastNameLabel.setBounds(new Rectangle(121, 60, 167, 26)); //THE PROBLEM? UserLastNameLabel.setText(s); } return jPanel; }

    Read the article

  • PHP question about global variables and form requests

    - by user220201
    Hi, This is probably a stupid question but will ask anyway sine I have no idea. I have written basic php code which serve forms. Say I have a login page and I serve it using the login.php page and it will be called in the login.html page like this - <form action="login.php" method="post"> By this it is also implied that every POST needs its own php file, doesn't it? This kind of feels weird. Is there a way to have a single file, say code.php, and just have each of the forms as functions instead? EDIT: Specifically, say I have 5 forms that are used one after the other in my application. Say after login the user does A, B, C and D tasks each of which are sent to the server as a POST request. So instead of having A.php, B.php, C.php and D.php I would like to have a single code.php and have A(), B(), C() and D() as functions. Is there a way to do this? Also on the same note, how do I deal with say a global array (e.g. an array of currently logged in users) across multiple forms? I want to do this without writing to a DB. I know its probably better to write to a DB and query but is it even possible to do it with a global array? The reason I was thinking about having all the form functions in one file is to use a global array. Thanks, - Pav

    Read the article

  • Whats the best way to send multiple variables in a query string within a URL

    - by Andy
    I have a client who is wanting to create a link which contains product codes so that his customers hit a page with just those products displayed in an attempt to increase conversion rates from affilliate sites. My question is whats the best way to send these multiple products in a single URL For example: http://www.mydomain.co.uk/bespoke-list.php?catNo=234-324-232-343 Obviously then the site would grab the codes from the string and display them... We're going to be using PHP! Thanks in advance.

    Read the article

  • php troubles with coding variables

    - by user342391
    I am trying to echo certain values if the variable $cardtype == $paymentmethod = if( $cardtype == 'visa' ) echo 'VSA'; elseif ( $cardtype == 'mastercard' ) echo 'MSC'; elseif ( $cardtype == 'mastercard' ) echo 'MSC'; elseif ( $cardtype == 'maestro' ) echo 'MAE'; elseif ( $cardtype== 'amex' ) echo 'AMX'; How would I do this???

    Read the article

  • Global variables in java

    - by zachary
    I want to make a class in java that is assessable to all other classes in my project. I created this in the default package and now it cannot be seen. What is the best way to do this in java?

    Read the article

  • C# Inherited member variables behaving undexpectedly

    - by Nilbert
    If I have a class like this: class A { public string fe = "A"; } And a class that inherits from it like so: class B : A { public string fe = "B"; } Visual C++ will tell me that B.fe hides A.fe so I should use the new keyword. So I change class B to look like: class B : A { public new string fe = "B"; } And then I have a function that takes an A (but, by virtue of inheritance, will also take a B) like this: class D { public static void blah(A anAObject) { Console.Writeline(A.fe); } } Even when I pass it an instance of a B object, which it will take without question, it will print "A"! Why is this, and how can I make it work how I want without setting the variable in the constructor?

    Read the article

  • When are static class variables initialized during runtime?

    - by Jake
    Hi, I have the following: class Thing { static Thing PREDEFINED; type _private; Thing() { _private = initial_val; } } Thing Thing::PREDEFINED = redefined_val; in global scope, i have this Thing mything = Thing::PREDEFINED; but it does not have the desired effect. mything is still initial_value and there were no errors too. So, may I ask when is the static class variable initialized during runtime?

    Read the article

  • foo and _foo - about variables inside a class

    - by kame
    class ClassName(object): """ """ def __init__(self, foo, bar): """ """ self.foo = foo # read-write property self.bar = bar # simple attribute def _set_foo(self, value): self._foo = value def _get_foo(self): return self._foo foo = property(_get_foo, _set_foo) a = ClassName(1,2) #a._set_foo(3) print a._get_foo() When I print a._get_foo() the function _get_foo prints the variable self._foo . But where does it come from? self._foo and self.foo are different, aren't they?

    Read the article

  • Passing variables from SQL proceedure to PHP

    - by Sam Corbet
    I am trying to create an sql proceedure that will return the results back to the php page. I want to be able to call the procedure as follows from the php call procedure_name($var1) which will run this script: -- --------------------------------------------------------------------------------- -- pUIGetCliStmtGenFlag -- -- This procedure returns the status of the Trading Period: -- -- --------------------------------------------------------------------------------- drop procedure if exists pUIGetCliStmtGenFlag; delimiter // create procedure pUIGetCliStmtGenFlag( IN pTradingPeriodMonth DATE ) MODIFIES SQL DATA COMMENT 'Checks if the TP has been closed' begin SELECT trading_period_month, dt_end, amt_traded_system_ccy FROM ca_trading_period WHERE trading_period_month=$var1 -- If amt_traded_system_ccy is NULL give the TP an open status otherwise mark as closed IF amt_traded_system_ccy is NULL $tpstatus='open' ELSE $tpstatus='closed' end; // delimiter ; I then want to be able to use $tpstatus in the rest of the php script. I know this is simple but this is completely new to me and I cant find the correct method

    Read the article

  • Javascript Anonymous Functions and Global Variables

    - by Jonathan Swift
    I thought I would try and be clever and create a Wait function of my own (I realise there are other ways to do this). So I wrote: var interval_id; var countdowntimer = 0; function Wait(wait_interval) { countdowntimer = wait_interval; interval_id = setInterval(function() { --countdowntimer <=0 ? clearInterval(interval_id) : null; }, 1000); do {} while (countdowntimer >= 0); } // Wait a bit: 5 secs Wait(5); This all works, except for the infinite looping. Upon inspection, if I take the While loop out, the anonymous function is entered 5 times, as expected. So clearly the global variable countdowntimer is decremented. However, if I check the value of countdowntimer, in the While loop, it never goes down. This is despite the fact that the anonymous function is being called whilst in the While loop! Clearly, somehow, there are two values of countdowntimer floating around, but why?

    Read the article

  • Creating PHP strings using other variables...works manually, can't figure out how automatically

    - by Matt
    Hello, I'm trying to get a variable to be formed automatically using data pulled from a mysql database. I know the data is being pulled from the database in some form resembling its original form, but that data does not act the same as data that is manually typed and assigned to a string. For example, if a cell in a mysql table says... I said "goodbye" before I left. She also said "goodbye." ...and I manually copy/paste it and add the necessary escapes... $string1 = " I said \"goodbye\" before I left. She also said \"goodbye.\" "; ...that does not equal... $string1 = $mysqlResultArray['specificCellWithQuoteShownAbove'] Interestingly, if I echo both versions of $string1 and view the output, they appear to be exactly the same. But they do not function the same when put through various functions I've created. The functions only work if I do the manual copy/paste method--which is not what I want, obviously. I'm not sure if it has to do with the line breaks or the escapes--or some combination of the two. But while both strings are superficially the same, they are apparently functionally different and I don't know why. So how can I create $string1 without manually copy/pasting the contents from the mysql entry and instead querying for the data and assigning it to $string1 in such a way that it's exactly functionally equivalent as the manual copy/pasted string?

    Read the article

  • How to use Mysql variables with Hibernate ?

    - by Jerome C.
    Hello, I need to use a native sql query in Hibernate with use of variable. But hibernate throws an error saying: Space is not allowed after parameter prefix So there is a conflict with the := mysql variable assignment and hibernate variable assignment. Here is my sql query: SET @rank:=0; UPDATE Rank SET rank_Level=@rank:=@rank+1 ORDER BY Level; I can't use a stored procedure because my sql query is dynamically generated ('Level' can be 'int' or 'force'...) How can I do this ? thanks

    Read the article

  • Adding Variables to JavaScript in Joomla

    - by Vikram
    Hello friends! This is the script I am using to display an accordion in my Joomla site: <?php defined('JPATH_BASE') or die(); gantry_import('core.gantryfeature'); class GantryFeatureAccordion extends GantryFeature { var $_feature_name = 'accordion'; function init() { global $gantry; if ($this->get('enabled')) { $gantry->addScript('accordion.js'); $gantry->addInlineScript($this->_accordion()); } } function render($position="") { ob_start(); ?> <div id="accordion"> <dl> <?php foreach (glob("templates/rt_gantry_j15/features/accordion/*.php") as $filename) {include($filename);} ?> </dl> </div> <?php return ob_get_clean(); } function _accordion() { global $gantry; $js = " jQuery.noConflict(); (function($){ $(document).ready(function () { $('#accordion').easyAccordion({ slideNum: true, autoStart: true, slideInterval: 4000 }); }); })(jQuery); "; return $js; } } I want to call these three values in the templateDetails.XML file as a user input. slideNum: true, autoStart: true, slideInterval: 4000 Like this in the templateDetails.xml file: <param name="accordion" type="chain" label="ACCORDION" description="ACCORDION_DESC"> <param name="slideNum" type="text" default="true" label="Offset Y" class="text-short" /> <param name="autoStart" type="text" default="true" label="Offset Y" class="text-short" /> <param name="autoStart" type="text" default="4000" label="Offset Y" class="text-short" /> </param> How can I do so? What will be the exact syntax for the same. I am very new to programming ans specially to JavaScript. Kindly help.

    Read the article

  • Passing variables from Model to Model in codeigniter

    - by Craig Ward
    Hi, I need to pass a variable to model, that model needs to send another back and use that variable to query a different model. EG: I have a product_ID which I send to the product model, From that I find out the supplier_ID. I want to grab that supplier_ID to the supplier model to get the supplier name. How do you implement this in codeigniter?

    Read the article

  • java objects, shared variables

    - by raven
    hello, I have a simple question here. If I declare a variable inside an object which was made [declared] in the main class, like this: public static int number; ( usually I declare it like this : private int number; ) can it be used in a different object which was also made [declared] in the main class? btw I do not care about security atm, I just want to make something work, don't care about protection)

    Read the article

  • Variables variable and inheritance

    - by Xack
    I made code like this: class Object { function __get($name){ if(isset($this->{$name})){ return $this->{$name}; } else { return null; } } function __set($name, $value){ $this->{$name} = $value; } } If I extend this class (I don't want to repeat this code every time), it says "Undefined variable". Is there any way to do it?

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >