🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #1848

Re: Help needed for sharing common data between programs

#1848
From: Jeff MUZZY
Date: Sat, 11 Aug 1990 01:29
33 lines
1803 bytes


>From: klg0582@uxa.cso.uiuc.edu (Ken-Huang Lin)
| I would like to have some "global variables" remain alive even after the
| program ends so that the next program can access them. I tried to set
| environment variables inside the program using
| system("set v=...");
| in Turbo C. Unfortunately, the effect is only local to that program. Is
| there any way to set the global environment variables in a program? Or is
| there a better way to serve the same purpose?


Here is how I would solve the problem. This is like our config files for
Windows and Lanman. 

I would create a file called GLOBAL.INI which is pointed to by an
ENV variable called HOME or INIT. I would write generic routine to
read and write from the tags in the file. The structure of the file 
would be like.

[Program-1]
   var1=szTag
   var2=1
   var3=Color

Then when you run your program you can use your routine to access from
init file. If you ever port your software to windows or PM your code won't
have to change much. Look at the call GetProfileString() in a book
about windows program to give you an idea. 
-- 
jeffmu@microsoft or uunet!microsoft!jeffmu    MaBellNet: (206) 882-8080
<Insert your favorite disclaimer about opinions and companies here>
Technical Details
Message-ID: <56479@microsoft.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!mailrus!wuarchive!zaphod.mps.ohio-state.edu!samsung!uunet!microsoft!jeffmu
References: <13685@lucid.megatest.UUCP> <1990Aug9.042244.6@ux1.cso.uiuc.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!mailrus!wuarchive!zaphod.mps.ohio-state.edu!samsung!uunet!microsoft!jeffmu
From: jeffmu@microsoft.UUCP (Jeff MUZZY)
Newsgroups: comp.os.msdos.programmer
Subject: Re: Help needed for sharing common data between programs
Message-ID: <56479@microsoft.UUCP>
Date: 11 Aug 90 01:29:24 GMT
References: <13685@lucid.megatest.UUCP> <1990Aug9.042244.6@ux1.cso.uiuc.edu>
Reply-To: jeffmu@microsoft.UUCP (Jeff MUZZY)
Distribution: usa
Organization: Microsoft Corp., Redmond WA
Lines: 33