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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to specify a day is Monday

Status
Not open for further replies.

Gelane

Programmer
Oct 16, 2000
8
US
I need to automatically run a report from a basic program on Monday mornings. Can anyone help me with what I need to add to my code? How do I check for Monday? [sig][/sig]
 
I guess this question must've been too easy for everyone, but for me it was a problem. I finally through a lot of time-consuming trial and error I figured out the problem. You need to include in the bas module the DATIM.BI header file which contains the necessary function declarations so you can use the date/time functions. I used DateValue# and Weekday& to get the results I needed. Here's a snippet of the code:

OPTION BASE 1
DEFINT A-Z
' $INCLUDE: 'DATIM.BI'

DIM DAYOFWEEK(7) AS STRING
DATA "SUNDAY","MONDAY","TUESDAY","WEDNESDAY","THURSDAY","FRIDAY","SATURDAY"
'Initialize the array
FOR i = 1 TO 7
READ DAYOFWEEK$(i)
NEXT i
AUTODATE# = DateValue#(DATE$)
THISDAY$ = DAYOFWEEK$(Weekday&(AUTODATE#))
PRINT THISDAY$
END

I used the quick library reference (dtfmter.qlb) when doing my source code development. Here is the bat file I execute when I am developing QBasic code:

set _path=%path%
call m:\bc7\bin\new-vars
qbx /L dtfmter.QLB /AH %1
path %_path%
set _path=
set include=
set lib=
set helpfiles=

You also need to link to the appropriate library, when you compile your program. Here is the bat file I use to compile my basic code:

set _path=%path%
call m:\bc7\bin\new-vars
BC %1,,NUL/X/O/Ot/Fs/Lr/AH/S/C:2048
LINK %1,,NUL,M:\BC7\LIB\DTFMTER.LIB;
DEL %1.OBJ
DIR %1.*
path %_path%

Hope this may help someone else. [sig][/sig]
 
Based on what you've shown, its seems to be a little too much work on your part. Why not have QB 7 do most of the grunt work for you? All you'll need to add in your AUTOEXEC.BAT file is the link to run the program...ex

@echo off
CALL c:\miggyD\QBX.exe /run FINDDATE.BAS
.
. rest of autoexec codeing
.


Then have QB do the work (see example below)

[tt]'******start of program******
'FILENAME: finddate.bas
'PURPOSE: Runs a set of instructions if the current day
' is a MONDAY.
'
CLS

'declare variables
TempFile$ = "MyEnter.txt"
DateFile$ = "MiggyD.txt"

'write to one file
OPEN TempFile$ FOR OUTPUT AS 10
PRINT #10, CHR$(10)
CLOSE 10

SLEEP 3 'let system write to file and close before
'attempting to open the file with the DAY

'call the date function from DOS and direct output to DATEFILE$
SHELL &quot;date < &quot; + TempFile$ + &quot; > &quot; + DateFile$

'read 1st line of output
OPEN DateFile$ FOR INPUT AS 11
LINE INPUT #11, CurDate$
CLOSE 11

'comparative logic structure
IF INSTR(CurDate$, &quot;Mon&quot;) > 0 THEN
PRINT &quot;Today is Monday, need to do the follow:&quot;
PRINT : PRINT &quot;Nothing in Queue&quot;
ELSE
PRINT &quot;It's not Mon, it is &quot;; MID$(CurDate$, 17, 4)
END IF

'erase un-needed files
KILL TempFile$
KILL DateFile$
END

'****** End of program ******[/tt]

Of course you may need to adjust the MID$ func. in accordance to your date/time line, but this should work just as good as yours and without loading libruaries.

--MiggyD [sig]<p> <br><a href=mailto: > </a><br><a href= > </a><br>English is too hard to learn, the vowles change too much like come/home, comb/tomb, book/school, high/bye/sty, etc., etc. So should I say Geez or Sheez or Cheeze? hehe.[/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top