global-variables

Delphi Dynamic Dll - global variable

Hi, I am busy coding a dll that supplies several functions to a host application. This application calls the dll dynamically, loading and freeing it after every function call. I have no control over the host app. I can only work with within the dll. Is there a way I can keep certain variables in memory so that I can reuse them within e...

Retain a random number across different functions in Cocoa?

I know how to do a global variable, but whenever I try to define a global variable with a random number function, xcode says "initializer element is not constant." The compiler doesn't want to make a variable from a random number because the random number function is not constant. How do I generate a random number and then use that s...

How to create a global parameters object

Hi, Here's a common, simple task: Read configuration settings from a configuration file, save the settings (e.g. as a hash) in an object, access this object from various objects that need to access the configuration parameters. I found this implementation for the ConfigFile class implementation and it works. My question is: what is the...

What's the preferred way of dealing with variables in constant use in an iPhone app?

What's the best way of dealing with variables in constant use in an iPhone app, like username/password in a twitter client? ...

What does global:: mean in the .Net designer files?

Here is a question that I have had for some time but never actually got around to asking... In quite a lot of the designer files that Visual Studio generates some of the variables are prefixed with global:: Can someone explain what this means, what this prefix does and where should I be using it? ...

Global variables in Objective-C

In Actionscript you can have global variables like this: var number : Number = 15; And then use it in a method/function. How do you do that in Objective-c, is it possible? ...

[Eclipse] Member variable prefix wrongly added to method name

Hi there, I am using Eclipse to write some Java code and the naming convention that I am following uses an 'm' as a prefix to any member variables for a class. As soon as I write the member variables I like to go to Source -> Generate Getters and Setters. This generates the methods that I require. However, the method and parameter names...

How to construct a static global variable in C++

I'm having some trouble compiling/linking a set of classes, several of them dealing with a common global variable. Basically, I declare and define a extern variable foo in class A and access/update it in classes B and C. The relevant code looks like this: A.h extern string foo; // declare it <=== compiler error "storage class sp...

Can I submit a predefined local variable as a POST w/out putting into a form field?

I have a local variable I'd like to be sent along with the rest of the POST data taken from an HTML form. Is there a function that lets me put more data from the current page into the POST array? ...

PHP Syntax Error in Setting Global Variable

Ok, so my PHP is, to say the least, horrible. I inherited an application and am having to fix errors in it from someone that wrote it over 7 years ago. When I run the page, there is no return, so I checked the logs to see the error and here is what i get: PHP Parse error: syntax error, unexpected '=', expecting ',' or ';' in /http...

Using a global variable in javascript

How do I do this? My code is something like this: var number = null; function playSong(artist,title,song,id) { alert('old number was: '+[number]+''); var number = '10'; alert(''+[number]+''); } The first alert always returns 'old number was: ' and not 10. Shouldn't it return 10 on both alerts on the second function ca...

VBA global variables

I have the following code for handling userforms on my spreadsheet VBA macros: Option Explicit Public saved_vocab As String Public saved_num As String Public saved_def As String Public saved_ex As String Private Sub Save_Click() Dim low As Integer Dim high As Integer Dim selected As Integer low = 1 high = Cells(1, ...

[Objective C] Object sharing in my iPhone App

Hi, I'm currently developping my first iPhone application and I would like to know what is the best way to share an object which is gonna be used in every controller. I was thinking of referencing the controller containing the needed data in other controllers and access this data thanks to properties, is that a good idea or is there a ...

Can an objective-C NSThread access global variables?

Ok, basically I have a run loop going in my application every second or two, while at the same time I have another thread going that is looping through the listenForPackets method; broadcastMessage is only initiated when another action method takes place. The important part of this question is that when the listener thread is running sep...

How a conflict is resolved in dynamic linking

XYZ.dll defines a global variable int x. ABC.c also defines the same global variable int x. How can one link XYZ.dll to ABC.exe? How is this conflict in global namespace resolved? ...

VBA in Excel: Global Constants File

I'm working on some VBA scripts for an Excel worksheet, and I've created a module that contains a whole listing of mostly strings that store the name of each of my database fields. That way, if anyone modifies the database, they can update the VBA variable in the module, and then all my scripts, which reference the global variable instea...

What are the different ways of handling 'Enumerations' in SQL server?

We currently define a list of constants (mostly these correspond to enumerations we have defined in the business layer) at the top of a stored procedure like so: DECLARE @COLOR_RED INT = 1 DECLARE @COLOR_GREEN INT = 2 DECLARE @COLOR_BLUE INT = 3 But these often get repeated for many stored procedures so there is a lot of duplication. ...

Does Zend Framework turns off declaring variables as global?

I am integrating third party code into the web application I am writing in Zend Framework. The code I want to integrate declares variables as global. It works on its own, but not when I include it within Zend Framework. Initially I suspected that there is something in Zend Framework that is disabling the declaration of global variables...

PHP access external $var from within a class function

In PHP, how do you use an external $var for use within a function in a class? For example, say $some_external_var sets to true and you have something like class myclass { bla .... bla .... function myfunction() { if (isset($some_external_var)) do something ... } } $some_external_var =true; $obj = new myclass(); $obj->myfu...

How do I prevent my 'unused' global variables being compiled out?

Hi, I'm using static initialisation to ease the process of registering some classes with a factory in C++. Unfortunately, I think the compiler is optimising out the 'unused' objects which are meant to do the useful work in their constructors. Is there any way to tell the compiler not to optimise out a global variable? class SomeClass {...