473,787 Members | 2,881 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

global variables???

Hi All,

Not sure if this is possible or not. How can I have a global constant
as a part of my variable names. As an example, I want all the ZZZ to
equal "C10" in the snippet of code below.

Why do I want to do this you ask? We are going to have anywhere from 60
to 100 drifters in the ocean sending back gps data and a table of that
data will be on a webpage. I am going to have separate text files with
PHP in them for includes to build the table. I thought rather than
having to create each file and assign the unique variables throughout
the file for each unit I could just tell it once that it is unit C10
save the page and then change the global and save as the next unit name.
I hope I didn't present this query in a confusing manner. Any help or
ideas you can give me are greatly appreciated.

Regards,
Patrick
$ZZZdataFile = "/DATA2/BUOY/ZZZdata.dat";
if (!($fpZZZa = fopen($ZZZdataF ile, "r")))
exit("Unable to open $ZZZdataFile.") ;
while (!feof($fpZZZa) )
{
// Assign variables to optional arguments
$buffer = fscanf($fpZZZa, "%s %s %s %s %s %s",
$ZZZdate $ZZZtime, $ZZZlat, $ZZZlon);
}
fclose ($fpZZZa);


--
Patrick A. Smith Assistant System Administrator
Ocean Circulation Group – USF - College of Marine Science
http://ocg6.marine.usf.edu Phone: 727 553-3334

The trouble with doing something right the first time is that nobody
appreciates how difficult it was. - La Rochefoucauld
Sep 17 '05 #1
3 1103
Patrick wrote:
Hi All,

Not sure if this is possible or not. How can I have a global constant as
a part of my variable names. As an example, I want all the ZZZ to equal
"C10" in the snippet of code below.

Why do I want to do this you ask? We are going to have anywhere from 60
to 100 drifters in the ocean sending back gps data and a table of that
data will be on a webpage. I am going to have separate text files with
PHP in them for includes to build the table. I thought rather than
having to create each file and assign the unique variables throughout
the file for each unit I could just tell it once that it is unit C10
save the page and then change the global and save as the next unit name.
I hope I didn't present this query in a confusing manner. Any help or
ideas you can give me are greatly appreciated.

Regards,
Patrick
$ZZZdataFile = "/DATA2/BUOY/ZZZdata.dat";
if (!($fpZZZa = fopen($ZZZdataF ile, "r")))
exit("Unable to open $ZZZdataFile.") ;
while (!feof($fpZZZa) )
{
// Assign variables to optional arguments
$buffer = fscanf($fpZZZa, "%s %s %s %s %s %s",
$ZZZdate $ZZZtime, $ZZZlat, $ZZZlon);
}
fclose ($fpZZZa);

I'd use a databaswe instead.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Sep 17 '05 #2
"Patrick" <ps****@marine. usf.edu> escreveu na mensagem
news:dg******** **@news1.usf.ed u...


$ZZZdataFile = "/DATA2/BUOY/ZZZdata.dat";
if (!($fpZZZa = fopen($ZZZdataF ile, "r")))
exit("Unable to open $ZZZdataFile.") ;
while (!feof($fpZZZa) )
{
// Assign variables to optional arguments
$buffer = fscanf($fpZZZa, "%s %s %s %s %s %s",
$ZZZdate $ZZZtime, $ZZZlat, $ZZZlon);
}
fclose ($fpZZZa);


I can't try it out here (no PHP installed), but as far as I remember:

$ZZZ = "C10";

${$ZZZ."dataFil e"} = "/DATA2/BUOY/".$ZZZ."data.da t";
if (!(${"fp".$ZZZ. "a"} = fopen(${$ZZZ."d ataFile"}, "r")))
etc.

Was this your question?

---
lex
Sep 21 '05 #3
i pray to undrstand you Patrick what you want to do
?????
are you lose any file or somthing in some other planet

but it is seem to be nice project

but you may create some function and define your new file as GLOBAL
or store all the zzz's in the DB
pleas xplain again (:

Sep 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
17882
by: Matt | last post by:
Greetings, What are people's thoughts on global variables in C++? Why are we taught not to use them in programming? Is it true that if you are running two copies of the C program one copy can overwrite another copies global variable? I know that you could overwrite a value in a global variable from a function, but you could also do that if you pass the variable in and then out again... so how is that any different?
4
24185
by: Andrew V. Romero | last post by:
I have been working on a function which makes it easier for me to pull variables from the URL. So far I have: <script language="JavaScript"> var variablesInUrl; var vArray = new Array(); function loadUrlVariables() { varString = location.search;
12
5884
by: David WOO | last post by:
Hi, I am a newbie on C++, I need to define some global variables which should be accessible to most classes. In the mean time, I don't won't the global variables be modified freely at most of these classes. I know there is a pattern called singleton can more or less do such a trick. I am wondering is this the best way to do it (regarding the convenience and safety), as this is such a fundamental thing, I believe most of you have a say...
2
5189
by: Bryan Parkoff | last post by:
….I would like to know which is the best optimization to use global variable or global struct. I always tell C/C++ Compiler to turn on optimization. ….I use underscore between first name and second name for better readable. After optimization, global variables might be misaligned because each global variables must be converted to 32 bits, but I do see that C/C++ Compiler do padding between variables. Struct does the same to do padding....
17
5631
by: MLH | last post by:
A97 Topic: If there is a way to preserve the values assigned to global variables when an untrapped runtime error occurs? I don't think there is, but I thought I'd ask. During development, I'm constantly running tests on imperfect code. On of the cumbersome jobs encountered is reassigning global vars their values after a close encounter with an untrapped runtime error. Rather than writing a procedure to simply reassign them all with a...
33
3051
by: MLH | last post by:
I've read some posts indicating that having tons of GV's in an Access app is a bad idea. Personally, I love GVs and I use them (possibly abuse them) all the time for everything imaginable - have been for years. If the machine has memory to spare and windows can use it - I'm thinking "Why not?" I was wondering what some of you have to say about that, particularly any severe "gotchas" you've had the unfortunate experience to contend with.
9
8659
by: CDMAPoster | last post by:
About a year ago there was a thread about the use of global variables in A97: http://groups.google.com/group/comp.databases.ms-access/browse_frm/thread/fedc837a5aeb6157 Best Practices by Kang Su Gatlin, casual mention was made about using static variables as an alternative to using global variables. This caused me to think of the following: '-----Begin module code
5
11830
by: Sandman | last post by:
I dont think I understand them. I've read the section on scope in the manual inside out. I'm running PHP 5.2.0 Here is the code I'm working on: //include_me.php <?php $MYVAR = array(); global $MYVAR, $a; ?>
1
29382
weaknessforcats
by: weaknessforcats | last post by:
C++: The Case Against Global Variables Summary This article explores the negative ramifications of using global variables. The use of global variables is such a problem that C++ architects have called it polluting the global namespace. This article explores what happens when the global namespace becomes polluted and how to avoid this condition. The opinions expressed in this article are those of the author alone although many have...
112
5482
by: istillshine | last post by:
When I control if I print messages, I usually use a global variable "int silent". When I set "-silent" flag in my command line parameters, I set silent = 1 in my main.c. I have many functions that may print some messages. foo(...) { if (!silent)
0
9497
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8993
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7517
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6749
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.