Page 1 of 1 1
Topic Options
#36257 - 2003-02-11 08:55 AM Running a batch file to set Variables
bekoz Offline
Fresh Scripter

Registered: 2002-11-07
Posts: 20
I nave an executale that does all the date calculation and creates a batch file to set the environment variables with th edates I need. The executable ryns fine but I cannot see the results of the batch file in th ecurrent or any other dos window. I want to call th ebatch file from the Kix script and use the environment variables in the same window. I know that Set Setl and Setm have been discussed many times, but I'm trying to set variables from a batch file. Is this possible? Here is the contents of the batch file.

@ECHO OFF
SETM "LASTM=12"
SETM YMD=030109
SETM YYYYMMDD=20030109
SETM YYMM=0301
SETM YY=03
SETM MM=01
SETM DD=09
SETM MDY=010903
SETM "YDAY=030108"
SETM YDAYDB4=030107
SETM YDAY2DB4=030106
SETM YDAY3DB4=030105
SETM YDAY4DB4=030104
SETM YDAY5DB4=030103
SETM YDAY6DB4=030102

Top
#36258 - 2003-02-12 12:57 AM Re: Running a batch file to set Variables
Darren_W Offline
Hey THIS is FUN
*****

Registered: 2001-10-10
Posts: 208
Loc: Bristol, England
Hi,

I could suggest to put the values in a text file, read them in a while loop with ReadLine, echo the value with ? , and then call the command with the shell command.

while (values exist)
read line from text file
echo value
run shell with value
loop

Darren
_________________________
I want to share something with you - the three sentences that will get you through life.
Number 1, 'cover for me.'
Number 2, 'oh, good idea, boss.'
Number 3, 'it was like that when I got here'.

Top
#36259 - 2003-02-11 04:43 PM Re: Running a batch file to set Variables
Jack Lothian Offline
MM club member
*****

Registered: 1999-10-22
Posts: 1169
Loc: Ottawa,Ontario, Canada
Kix commands will not run directly in DOS/Command mode. You must envoke kix to use these commands. Note, SETM was broken in some of the later versions of kix so use the latest rc build. I think Darren's solution assumes you will envoke kix. If you want to stay in batch you must use the FOR command to implement Darren's suggestion.

It is a long time since, I worked on this but the utilities PUTENV.EXE & PUTINENV.EXE can access various DOS shells extrenal to the active shell. I suspect there are other utilities that can also do this.

[ 11. February 2003, 16:46: Message edited by: Jack Lothian ]
_________________________
Jack

Top
#36260 - 2003-02-12 03:39 AM Re: Running a batch file to set Variables
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Please take a look at the KiXtart Manual to learn how to call KiXtart scripts. Also, please use KiXtart 4.20 as it contains a SET bug-fix. And read the FAQ Forum, especially Kixtart Starter's Guide
_________________________
There are two types of vessels, submarines and targets.

Top
#36261 - 2003-02-12 10:34 AM Re: Running a batch file to set Variables
bekoz Offline
Fresh Scripter

Registered: 2002-11-07
Posts: 20
Sorry, I pasted a changed batch file the actual btch file has the following in it

@ECHO OFF
SET LASTM=01
SET YMD=030212
SET YYYYMMDD=20030212
SET YYMM=0302
SET YY=03
SET MM=02
SET DD=12
SET MDY=021203
SET YDAY=030211
SET YDAYDB4=030210
SET YDAY2DB4=030209
SET YDAY3DB4=030208
SET YDAY4DB4=030207
SET YDAY5DB4=030206
SET YDAY6DB4=030205

Jens, I know how to call a Kix script, I use a few scripts that I have written successfully. I just can't figure this out.

Top
#36262 - 2003-02-12 05:16 PM Re: Running a batch file to set Variables
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Use SHELL to call the batch file.
_________________________
There are two types of vessels, submarines and targets.

Top
#36263 - 2003-02-13 12:21 AM Re: Running a batch file to set Variables
Jack Lothian Offline
MM club member
*****

Registered: 1999-10-22
Posts: 1169
Loc: Ottawa,Ontario, Canada
Sorry I misunderstood your question. (I do hope that I haven't misunderstood it again.)

I don't think you can do what you want. There are environment shells within shells here & in a sense there there are more than 1 active current shell. If you write to the current DOS shell, I don't think you will see the results until kix completes. I also believe that shelling out to a batch set command writes to a different environment from the kix set command.

Why do you need this? If you need to pass variables within Kix why not use kix's variable space. With global variables, they will be active & clear to all segments of your script. There is no need for kix to store variables in an external space & then try to get them back.

You really only need to write to the environment if you execute 2 separate kix scripts at 2 different times & these scripts must share variables. If this is the case, the various DOS shells will collapse upon completion of the 1st script & the variable definitions will drop into the base environment. A new script starting up will be able to read these variables.

Another point, the environment is defined at start up of the new shell & expanding it to include new variables is not straight forward. If you want your variables to exist in all possible shells you should create dummy values for them before startup.

As you might be able to tell from my comments, I find the mix of kix & environment variables very hard to manage. I avoid using them whenever I can. I have a few scripts that use them but I keep it simple.

[ 13. February 2003, 00:27: Message edited by: Jack Lothian ]
_________________________
Jack

Top
#36264 - 2003-02-14 09:40 AM Re: Running a batch file to set Variables
bekoz Offline
Fresh Scripter

Registered: 2002-11-07
Posts: 20
You guys have been a real help. Thank you.
Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 2419 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.064 seconds in which 0.032 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org