Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Three seperate CVRT files into one 2

Status
Not open for further replies.

wlpsyp

IS-IT--Management
Feb 5, 2003
195
US
I have three seperate FoxPro 2.6 DB servers scattered across Alaska. I have created a web page (Thanks to Dave S. and thread184-469531 ) Each of the three files works great and pushes to the web with no problem. Here is my question. The code is the same on each of the three files with the exception of 3 lines (File location, publish location etc) Right now I have to run each cvrt file individually, can I make just one cvrt file with the three seperate code pages and only have to DO TestCVRT once instead of three time? Below is the code for one, what I am trying to say is can I just copy and paste the code from the 2nd and 3rd file into the first one and have it run? How would I pass the parameters from 1-2, 2-3?

SET EXCLUSIVE OFF
USE R:\RTLPAS10\RFMSS35\DATA\REQUEST.DBF

DO WHILE .T.
WAIT WINDOW NOWAIT 'Waiting... <Esc> to exit, any other key to update now.'
x=INKEY(300) &&... 300 seconds = 5 minutes.
IF x = 27 &&... Escape key pressed
EXIT
ENDIF
DO MakeHTML WITH DATE(), DATE() + 90, ;
&quot;X:\Inetpub\
DO MakeHTML WITH DATE() + 91, DATE() + 180, ;
&quot;X:\Inetpub\
DO MakeHTML WITH DATE() + 181, DATE() + 260, ;
&quot;X:\Inetpub\
DO MakeHTML WITH DATE(), DATE() + 365, ;
&quot;X:\Inetpub\
ENDDO
CLOSE ALL


FUNCTION MakeHTML
PARAMETERS UseDate, EndDate, OutFile


SELECT USEDAY, ENDDAY, TRAINING, ;
UnitName, Tra_Area ;
FROM Request ;
WHERE BETWEEN(USEDAY,UseDate, EndDate );
ORDER BY USEDAY;
INTO CURSOR tmp

SELECT tmp
&&... Use 'OutFile' parameter instead of actual file name
SET TEXTMERGE TO (OutFile)
SET TEXTMERGE ON NOSHOW
\\<HTML><HEAD><TITLE>Requests by Date</TITLE></HEAD>
\<BODY>
\<TABLE BORDER=5 ALIGN=CENTER WIDTH=70%>
nCounter = 0
SCAN
IF (nCounter % 20)=0 &&... every 20 rows
\<TR>
\ <TH>Use Day
\ <TH>End Day
\ <TH>Training to be Conducted
\ <TH>Using Unit
\ <TH>Range/Training Area
\</TR>
ENDIF
nCounter = nCounter + 1

\<TR>
\ <TD><<Useday>>
\ <TD><<ENDDAY>>
\ <TD><<Training>>
\ <TD><<UnitName>>
\ <TD><<Tra_Area>>
\</TR>
ENDSCAN
SET TEXTMERGE TO
RETURN

Thanks,

Bill
 
Yup, it's me again.

The simplest would be to clone your current stuff:

SET EXCLUSIVE OFF

DO WHILE .T.
WAIT WINDOW NOWAIT 'Waiting... <Esc> to exit, any other key to update now.'
x=INKEY(300) &&... 300 seconds = 5 minutes.
IF x = 27 &&... Escape key pressed
EXIT
ENDIF
USE R:\RTLPAS10\RFMSS35\DATA\REQUEST.DBF
DO MakeHTML WITH DATE(), DATE() + 90, ;
&quot;X:\Inetpub\
DO MakeHTML WITH DATE() + 91, DATE() + 180, ;
&quot;X:\Inetpub\
DO MakeHTML WITH DATE() + 181, DATE() + 260, ;
&quot;X:\Inetpub\
DO MakeHTML WITH DATE(), DATE() + 365, ;
&quot;X:\Inetpub\
*... next table
USE S:\RTLPAS10\RFMSS35\DATA\REQUEST.DBF
DO MakeHTML WITH DATE(), DATE() + 90, ;
&quot;Y:\Inetpub\.
.
.

*... next table
USE T:\RTLPAS10\RFMSS35\DATA\REQUEST.DBF
DO MakeHTML WITH DATE(), DATE() + 90, ;
&quot;Z:\Inetpub\.
.
.

Substituting of course, the drives, directories, whatever.
Dave S.
[cheers]
 
Hey, Its you again... THANKS, Will try that right now. And post the hole code before I run it.

Thanks,

Bill
 
But I'm not done yet.
The more elegant way would be to pass some input parameters:

*............... TestCVRT.PRG ...................
DO WHILE .T.
WAIT WINDOW NOWAIT 'Waiting... <Esc> to exit, any other key to update now.'
x=INKEY(300) &&... 300 seconds = 5 minutes.
IF x = 27 &&... Escape key pressed
EXIT
ENDIF

DO CVRT WITH ;
&quot;R:\RTLPAS10\RFMSS35\DATA\REQUEST.DBF&quot;,;
&quot;X:\Inetpub\ DO CVRT WITH ;
&quot;S:\RTLPAS10\RFMSS35\DATA\REQUEST.DBF&quot;,;
&quot;Y:\Inetpub\ DO CVRT WITH ;
&quot;T:\RTLPAS10\RFMSS35\DATA\REQUEST.DBF&quot;,;
&quot;Z:\Inetpub\
ENDDO
RETURN

*............... CVRT ...................
PROCEDURE CVRT
PARAMETERS cInTable, cOutDir
SET EXCLUSIVE OFF

USE (cInTable)
DO MakeHTML WITH DATE(), DATE() + 90, ;
cOutDir + &quot;FRA90Day.HTML&quot;

DO MakeHTML WITH DATE() + 91, DATE() + 180, ;
cOutDir + &quot;FRA180Day.HTML&quot;

DO MakeHTML WITH DATE() + 181, DATE() + 260, ;
cOutDir + &quot;FRA260Day.HTML&quot;

DO MakeHTML WITH DATE(), DATE() + 365, ;
cOutDir + &quot;FRAInclusive.HTML&quot;

RETURN

*................................................FUNCTION MakeHTML
PARAMETERS UseDate, EndDate, OutFile


SELECT USEDAY, ENDDAY, TRAINING, ;
UnitName, Tra_Area ;
FROM Request ;
WHERE BETWEEN(USEDAY,UseDate, EndDate );
ORDER BY USEDAY;
INTO CURSOR tmp

SELECT tmp
&&... Use 'OutFile' parameter instead of actual file name
SET TEXTMERGE TO (OutFile)
SET TEXTMERGE ON NOSHOW
\\<HTML><HEAD><TITLE>Requests by Date</TITLE></HEAD>
\<BODY>
\<TABLE BORDER=5 ALIGN=CENTER WIDTH=70%>
nCounter = 0
SCAN
IF (nCounter % 20)=0 &&... every 20 rows
\<TR>
\ <TH>Use Day
\ <TH>End Day
\ <TH>Training to be Conducted
\ <TH>Using Unit
\ <TH>Range/Training Area
\</TR>
ENDIF
nCounter = nCounter + 1

\<TR>
\ <TD><<Useday>>
\ <TD><<ENDDAY>>
\ <TD><<Training>>
\ <TD><<UnitName>>
\ <TD><<Tra_Area>>
\</TR>
ENDSCAN
SET TEXTMERGE TO
RETURN
*........................................................
Dave S.
[cheers]
 
This is what I came up with, seems pretty darn simple. Does it pass the logic test? Also, How do you add a coment line?

SET EXCLUSIVE OFF

DO WHILE .T.
WAIT WINDOW NOWAIT 'Waiting... <Esc> to exit, any other key to update now.'
x=INKEY(300) &&... 300 seconds = 5 minutes.
IF x = 27 &&... Escape key pressed
EXIT
ENDIF

Fort Richardson(Trying to make these a comment line)
USE R:\RTLPAS10\RFMSS35\DATA\REQUEST.DBF
DO MakeHTML WITH DATE(), DATE() + 90, ;
&quot;X:\Inetpub\
DO MakeHTML WITH DATE() + 91, DATE() + 180, ;
&quot;X:\Inetpub\
DO MakeHTML WITH DATE() + 181, DATE() + 260, ;
&quot;X:\Inetpub\
DO MakeHTML WITH DATE(), DATE() + 365, ;
&quot;X:\Inetpub\
Fort Wainwright
USE P:\RTLPAS10\RFMSS35\DATA\REQUEST.DBF
DO MakeHTML WITH DATE(), DATE() + 90, ;
&quot;X:\Inetpub\
DO MakeHTML WITH DATE() + 91, DATE() + 180, ;
&quot;X:\Inetpub\
DO MakeHTML WITH DATE() + 181, DATE() + 260, ;
&quot;X:\Inetpub\
DO MakeHTML WITH DATE(), DATE() + 365, ;
&quot;X:\Inetpub\
Fort Greely
USE T:\RTLPAS10\RFMSS35\DATA\REQUEST.DBF
DO MakeHTML WITH DATE(), DATE() + 90, ;
&quot;X:\Inetpub\
DO MakeHTML WITH DATE() + 91, DATE() + 180, ;
&quot;X:\Inetpub\
DO MakeHTML WITH DATE() + 181, DATE() + 260, ;
&quot;X:\Inetpub\
DO MakeHTML WITH DATE(), DATE() + 365, ;
&quot;X:\Inetpub\
ENDDO
CLOSE ALL


FUNCTION MakeHTML
PARAMETERS UseDate, EndDate, OutFile


SELECT USEDAY, ENDDAY, TRAINING, ;
UnitName, Tra_Area ;
FROM Request ;
WHERE BETWEEN(USEDAY,UseDate, EndDate );
ORDER BY USEDAY;
INTO CURSOR tmp

SELECT tmp
&&... Use 'OutFile' parameter instead of actual file name
SET TEXTMERGE TO (OutFile)
SET TEXTMERGE ON NOSHOW
\\<HTML><HEAD><TITLE>Requests by Date</TITLE></HEAD>
\<BODY>
\<TABLE BORDER=5 ALIGN=CENTER WIDTH=70%>
nCounter = 0
SCAN
IF (nCounter % 20)=0 &&... every 20 rows
\<TR>
\ <TH>Use Day
\ <TH>End Day
\ <TH>Training to be Conducted
\ <TH>Using Unit
\ <TH>Range/Training Area
\</TR>
ENDIF
nCounter = nCounter + 1

\<TR>
\ <TD><<Useday>>
\ <TD><<ENDDAY>>
\ <TD><<Training>>
\ <TD><<UnitName>>
\ <TD><<Tra_Area>>
\</TR>
ENDSCAN
SET TEXTMERGE TO
RETURN
 
Ok.... You lost me on that last post
 
To answer your first post, looks good to me. Comments are made by using '*', '&&', or the word 'NOTE'.
Using '*' or 'NOTE', they must be the first non-whitespace character on the line:

* Fort Richardson
-or-
*... Fort Richardson
-or-
NOTE Some comment

'&&' can be used after another command.
SET EXCLUSIVE OFF && Share Tables

*... Next line will cause an error
SET EXCLUSIVE OFF * Share Tables

Next:
Take another look. You'll see what I was doing was substituting the actual path name with a variable which holds the path name you send it (cInFile). However, you are needing to output to different file names as well, not just directories. That takes a little more tweaking.
Same scenario with cOutDir, which is prepended to the actual file name.
Dave S.
[cheers]
 
Got the comment to work I was trying to use REM or ' but it works now with what you provided. I will look deeper at the other code you provided and give that a shot. All for making it easier but mainly learning. How can I make it to where it does not ask me if I want to over wright the file? When I DO USARAKCVRT it comes back with blah blah blah File already used, over right. Now instead of saying yes 4 times, I get to do it a astounding 12 times...

I am thinking take out the Wait Window NOWAIT line and Time. I am wanting not to have to answer yes and perferably have it auto run say every 12 hours.
 
Opps.... This is not going to work. Have to do some more digging in and see what is going on. The usarakcvrt file runs fine, and makes the 12 web pages. however it is all showing up with just the FRA data and no FWA or DTA data. So... digging away I go
 
Use:

SET SAFETY OFF

To eliminate the '...Exists. Overwrite?...' stuff.


SET EXCLUSIVE OFF
SET SAFETY OFF

DO WHILE .T.
.
.
.

As for the other part, now you've lost me. You sure you're using different 'request' files?

Dave S.
[cheers]
 
Here we go.......

I now have 4 cvrt files. One for each post and the one we did that combined the 3 posts. If I run the 3 individually they run fine, they each make there appropriate web page and files excute fine. However, if I run the 4th one which is is the cvrt file that is combined ( I will post the code below) It runs fine as well. It asks me if I want to overwrite etc, no problem there. It produces the 12 web pages fine. The issue is that if I open up say FRA90day html it shows what it should, and then if I open up FWA90day or DTA90day they are showing FRA90day data. This is the case with all of them, i.e. 90day, 120day, 260day, Allinclusive

How this is laid out is. I have three seperate servers, each located at the perspective places throughout Alaska. The FRA one is here in my office. I map a drive the the proper drive/folder/file location etc.

Again, this all works great if I do the seperate cvrt files, just not when I run the combined one.

Bill
 
Forgot.... This is the combined coded one.

SET EXCLUSIVE OFF

DO WHILE .T.
WAIT WINDOW NOWAIT 'Waiting... <Esc> to exit, any other key to update now.'
x=INKEY(300) &&... 300 seconds = 5 minutes.
IF x = 27 &&... Escape key pressed
EXIT
ENDIF

*...Fort Richardson
USE R:\RTLPAS10\RFMSS35\DATA\REQUEST.DBF
DO MakeHTML WITH DATE(), DATE() + 90, ;
&quot;X:\Inetpub\
DO MakeHTML WITH DATE() + 91, DATE() + 180, ;
&quot;X:\Inetpub\
DO MakeHTML WITH DATE() + 181, DATE() + 260, ;
&quot;X:\Inetpub\
DO MakeHTML WITH DATE(), DATE() + 365, ;
&quot;X:\Inetpub\
*...Fort Wainwright
USE P:\RTLPAS10\RFMSS35\DATA\REQUEST.DBF
DO MakeHTML WITH DATE(), DATE() + 90, ;
&quot;X:\Inetpub\
DO MakeHTML WITH DATE() + 91, DATE() + 180, ;
&quot;X:\Inetpub\
DO MakeHTML WITH DATE() + 181, DATE() + 260, ;
&quot;X:\Inetpub\
DO MakeHTML WITH DATE(), DATE() + 365, ;
&quot;X:\Inetpub\
*...Fort Greely
USE T:\RTLPAS10\RFMSS35\DATA\REQUEST.DBF
DO MakeHTML WITH DATE(), DATE() + 90, ;
&quot;X:\Inetpub\
DO MakeHTML WITH DATE() + 91, DATE() + 180, ;
&quot;X:\Inetpub\
DO MakeHTML WITH DATE() + 181, DATE() + 260, ;
&quot;X:\Inetpub\
DO MakeHTML WITH DATE(), DATE() + 365, ;
&quot;X:\Inetpub\
ENDDO
CLOSE ALL


FUNCTION MakeHTML
PARAMETERS UseDate, EndDate, OutFile


SELECT USEDAY, ENDDAY, TRAINING, ;
UnitName, Tra_Area ;
FROM Request ;
WHERE BETWEEN(USEDAY,UseDate, EndDate );
ORDER BY USEDAY;
INTO CURSOR tmp

SELECT tmp
&&... Use 'OutFile' parameter instead of actual file name
SET TEXTMERGE TO (OutFile)
SET TEXTMERGE ON NOSHOW
\\<HTML><HEAD><TITLE>Requests by Date</TITLE></HEAD>
\<BODY>
\<TABLE BORDER=5 ALIGN=CENTER WIDTH=70%>
nCounter = 0
SCAN
IF (nCounter % 20)=0 &&... every 20 rows
\<TR>
\ <TH>Use Day
\ <TH>End Day
\ <TH>Training to be Conducted
\ <TH>Using Unit
\ <TH>Range/Training Area
\</TR>
ENDIF
nCounter = nCounter + 1

\<TR>
\ <TD><<Useday>>
\ <TD><<ENDDAY>>
\ <TD><<Training>>
\ <TD><<UnitName>>
\ <TD><<Tra_Area>>
\</TR>
ENDSCAN
SET TEXTMERGE TO
RETURN
 
Cant get the three to pass to the next without over wirtting the first one. So, I will stick with just manually doing each cvrt file individually, no big deal. Thanks Dave S.

Bill
 
Looking over your combined code, it looks good...
( Add a SET SAFETY OFF at the beginning by SET EXCLUSIVE OFF and it won't ask to overwrite anymore )

What happens when you run it that you don't want to happen?

BTW: you can use the full UNC path names to avoid having to have the drives mapped: eg:

USE \\servername\sharename\RTLPAS10\RFMSS35\DATA\REQUEST.DBF

instead of mapping the P: drive then:
USE P:\RTLPAS10\RFMSS35\DATA\REQUEST.DBF

This might remove some ambiguity about where exactly the P: drive is mapped to, for example, which can break code that used to work.

You can also use the full path name to the REQUEST.DBF file in the SELECT statement (pass it in as a parameter instead of USEing it before calling MakeHTML).
 
wgcs, Thanks for the interest. When I run the above code, it runs fine, however somewhere it is over writting itself. In other words, I run DO USARAK which is the above code name. It runs, it makes the correct 12 web pages and I see the pages in the directory where they should be. But when I open say FRA90day it shows what it should, but when I open FWA90day or FGA90day it is showing me FRA90day data, not the data from the perspective databse. This is the same with all 12 pages. the 4 pages for FRA are fine, but the other 8 pages show FRA data and not FWA or FGA data.

However, if I run three seperate cvrt files (Not a combined one as above) the data shows correctly for each Army post and all is well. What I was trying to accomplish was to just have to run one file as above to execute the 12 pages and not three files. It seems to me that as the code is run, it is not passing on correctly and is just pulling the data from the FRA side.

My next move was to try the UNC issue and see if that helps, but really should not matter as the drives maintain their mappings correctly and never get disconnected.

Thanks,

Bill
 
I believe it relates to the fact that all the DBF files are named &quot;REQUEST.DBF&quot; and are never explicitly closed...

The first time you USE ....\Request.dbf it gets the alias &quot;REQUEST&quot;

With the first SELECT, the &quot;Tmp&quot; alias gets created and selected, and used, then the MakeHTML routine exits, leaving &quot;Tmp&quot; selected.

Now, the next USE ....\Request.dbf opens the right file, but gives it the alias &quot;B&quot;, since &quot;Request&quot; is still taken, and the next SELECT statement takes the data from the same, original &quot;Request&quot; alias.

Just add this before each &quot;USE ....\Request.dbf&quot;:
Code:
USE IN (select('REQUEST'))

and add this at the end of &quot;MakeHTML&quot;:
Code:
USE IN (select('TMP'))

This will explicitly close those two aliases so they are then available for the next operation.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top