No one knows how to do this?
No one knows how to do this?
I need to be able to extrapulate the current number of days that have transpired in the current year in qbasic. Today for instance would be 244 I believe. Does anyone know how or have a piece of code to do this?
Sounds like homework, and homework will not be done for you by any of the guys here. The only thing I can do for you is push in the right direction.
First of all, you need to determine if the year we are in has 365 or 366 days (i.e. is a leap year):
Then you ask the user to input the day and month, and you check how much months have passed. You can add the number of days in these months together, and then add the current day and subtract one.
For instance:
Now is 2004, leap year -> February has 29 days.
User inputs: Now it's April 23rd.
You count: January + February + March + 23 - 1 = 31 + 29 + 31 + 22
= 62 + 51 = 113.
Hope you can do something with this.
First of all, you need to determine if the year we are in has 365 or 366 days (i.e. is a leap year):
Code: Select all
FUNCTION IsLeapYear (Z) STATIC
' If the year is evenly divisible by 4 and not divisible
' by 100, or if the year is evenly divisible by 400, then
' it's a leap year:
IsLeapYear = (Z MOD 4 = 0 AND Z MOD 100 <> 0) OR (Z MOD 400 = 0)
END FUNCTION
'moneo's code
For instance:
Now is 2004, leap year -> February has 29 days.
User inputs: Now it's April 23rd.
You count: January + February + March + 23 - 1 = 31 + 29 + 31 + 22
= 62 + 51 = 113.
Hope you can do something with this.
Hey, don't be so rude. I am not a Qbasic guy and am not very knowledgable about it at all. I came here to ask the pro's and for a little professional courtesy. I am an info systems manager but have a program in QB I put together and was needing this little piece of code. I scoured the net looking for examples but the date$ in qbasic is limited which is why I asked here. I didn't realize you thought helping out by providing the answer was a bad thing. I won't bother you further
I wasn't being rude, sorry if I made you think that.
The only thing is that people at school sometimes get QB assignments, of which they think they can easily get the answer by posting on this forum. However, here, on QBasicNews, on QBNZ and much more, they've seen through this trick and answer the questions only by having them think as well. Almost no one over there gives an answer to a homework assignment immediately.
Sorry if I misunderstood. If this problem of yours is not homework, I will answer it for you, don't be upset about it. But as usually (what everyone asks before answering), did you try yourself? And if so, what have you come up with? This way we can better see what you're doing wrong and you'll learn much more from it than just getting an answer. Do you understand?
So, apologies for the miscommunication, but let's get on with your problem.
The only thing is that people at school sometimes get QB assignments, of which they think they can easily get the answer by posting on this forum. However, here, on QBasicNews, on QBNZ and much more, they've seen through this trick and answer the questions only by having them think as well. Almost no one over there gives an answer to a homework assignment immediately.
Sorry if I misunderstood. If this problem of yours is not homework, I will answer it for you, don't be upset about it. But as usually (what everyone asks before answering), did you try yourself? And if so, what have you come up with? This way we can better see what you're doing wrong and you'll learn much more from it than just getting an answer. Do you understand?
So, apologies for the miscommunication, but let's get on with your problem.
Thank-you. No It's not homwork. I am an Info Systems Manager for a seafood packing plant in Florida. I have a Qbasic routine that is polling electronic scales in a harsh enviroment and using the weight from those scales to imprint on case labels. Due to new regulations I have to now incorporate the day of the year on the labels. I was able to write the code for the case labels using my limited knowledge of qbasic, but I can find nothing on doing this task with the date as the date$ is limited and the logic is over my expertise for this in QB. I can determine the month and I can determine the day, I can even write logic to just assume a 30 day month and get a general number of days, but I need it to be accurate.
I assure you I am not a student. I am just a professional looking for an answer to a problem. Thanks for any help you can provide. I figured since this was a forum dedicated to qbasic solutions, someone here would definately be able to help if it could be done. Thanks again. If you do not wish to post the answer, I can provide an email addy
I assure you I am not a student. I am just a professional looking for an answer to a problem. Thanks for any help you can provide. I figured since this was a forum dedicated to qbasic solutions, someone here would definately be able to help if it could be done. Thanks again. If you do not wish to post the answer, I can provide an email addy
here is my simplistic routine
REM - PROGRAM TO POLL EXTERNAL SCALE FOR A WEIGHT AND PRINT WEIGHT AND NUMERIC DAY ON SATO LABEL PRINTER
CLEAR
D$ = DATE$
DAY = VAL(MID$(D$, 4, 2))
COM(1) ON
OPEN "COM1:9600,N,8,1" FOR INPUT AS #1
CLOSE #1
CNTR = 0
CTWGT = 0
CCNTR = 0
PALLET = 1
KILL "C:\CSCNTOT.TXT"
OPEN "C:\CSCNTOT.TXT" FOR APPEND ACCESS WRITE LOCK READ WRITE AS #3
KILL "C:\CSCNT.TXT"
OPEN "C:\CSCNT.TXT" FOR APPEND ACCESS WRITE LOCK READ WRITE AS #2
PRINT #2, ""
PRINT #3, ""
5 PRINT CHR$(12)
INPUT "ENTER LINE # FOR RUN :"; LINE$
IF LINE$ = "EX" THEN END
IF LINE$ = "ex" THEN END
INPUT "ENTER PRODUCT CODE FOR RUN :"; PRODUCT$
IF PRODUCT$ = "EX" THEN END
IF PRODUCT$ = "ex" THEN END
INPUT "ENTER PRODUCT DESCRIPTION :"; PDESC$
IF PDESC$ = "EX" THEN END
IF PDESC$ = "ex" THEN END
PRINT #2, " LINE # "; LINE$
PRINT #2, " "
PRINT #2, DATE$; " PALLET COUNT SUMMARY REPORT FOR PRODUCT "; PRODUCT$
PRINT #2, " "; PDESC$
PRINT #2, "--------------------------------------------------------------------"
PRINT #3, " LINE # "; LINE$
PRINT #3, " "
PRINT #3, DATE$; " PALLET RUN COUNT SUMMARY REPORT FOR PRODUCT "; PRODUCT$
PRINT #3, " "; PDESC$
PRINT #3, "--------------------------------------------------------------------"
CLOSE COM1
10 SLEEP 1
SHELL "c:\setcom2.bat"
SLEEP 1
COM(1) ON
OPEN "COM1:9600,N,8,1" FOR INPUT AS #1
PRINT CHR$(12)
CNTR = CNTR + 1
PRINT " PRODUCT :"; PRODUCT$; " "; PDESC$; " LINE # "; LINE$; " PALLET NUMBER :"; PALLET
PRINT
PRINT
COLOR 12
PRINT " PLACE CASE NUMBER "; CNTR; "ON SCALE AND PRESS PRINT"
COLOR 15
PRINT
PRINT
PRINT
PRINT " IF PALLET IS COMPLETE, REMOVE CASE FROM SCALE AND PRESS PRINT"
PRINT
PRINT " WHEN RUN IS COMPLETE, ZERO OUT SCALE AND PRESS PRINT TO END RUN"
wgt$ = INPUT$(50, #1)
I = 1: Sppos = 0
DO WHILE I > 0
I = INSTR(Sppos + 1, wgt$, " ") 'Get position of next space.
IF I > 0 THEN Sppos = I
LOOP
'SPPOS now points to the position of the last space.
IF Sppos = 0 THEN
REM PRINT WGT$ 'WGT ONLY INPUT
ELSE
'Everything after last space.
wgt1$ = RIGHT$(wgt$, LEN(wgt$) - Sppos +
'Everything to the left of that
wgt1$ = LEFT$(wgt1$,
wgt$ = wgt1$
END IF
COM(1) OFF
wgt$ = LTRIM$(wgt$)
wgt$ = RTRIM$(wgt$)
wgt# = VAL(wgt$)
IF wgt# = 0 THEN GOTO 30
11 IF wgt# < 0 THEN GOTO 20
TWGT# = TWGT# + wgt#
PRINT #2, CNTR; "- "; wgt$
LPRINT CHR$(27); "A";
LPRINT CHR$(27); "E#5";
LPRINT CHR$(27); "A3H0100V0001";
LPRINT CHR$(27); "%2";
LPRINT CHR$(27); CHR$(27); "H000"; CHR$(27); "V150"; CHR$(27); "XM"; DAY
LPRINT CHR$(27); "A3H0230V0001";
LPRINT CHR$(27); "%2";
LPRINT CHR$(27); CHR$(27); "H000"; CHR$(27); "V090"; CHR$(27); "L0204"; CHR$(27); "XM"; wgt$
LPRINT CHR$(27); "Q1";
LPRINT CHR$(27); "Z";
CCNTR = CCNTR + 1
CLOSE #1
GOTO 10
20 TWGT# = TWGT# + .005
TWGT# = TWGT# * 100
TWGT# = INT(TWGT#)
TWGT! = (TWGT# / 100)
TWGT = TWGT!
PRINT #2, " "
PRINT #2, " TOTAL WEIGHT FOR PALLET NUMBER "; PALLET
PRINT #2, TWGT
PRINT #3, " TOTAL CASES FOR PALLET # :"; PALLET; " - "; CNTR - 1; " TOTAL WEIGHT :"; TWGT
CLOSE #1
CLOSE #2
LPRINT CHR$(27); "A";
LPRINT CHR$(27); "A3H0240V0001";
LPRINT CHR$(27); "%2";
LPRINT CHR$(27); CHR$(27); "H300"; CHR$(27); "V090"; CHR$(27); "L0103"; CHR$(27); "XM CASES"; CNTR - 1
LPRINT CHR$(27); CHR$(27); "H000"; CHR$(27); "V085"; CHR$(27); "L0103"; CHR$(27); "XM"; TWGT
LPRINT CHR$(27); "Q1";
LPRINT CHR$(27); "Z";
OPEN "c:\CSCNT.txt" FOR INPUT AS #2
PRINT
PRINT " TOTAL WEIGHT FOR PALLET "; TWGT
PRINT " NOW PRINTING PALLET SHEET FOR PALLET :"; PALLET
PRINT CCNTR
SLEEP 1
PALLET = PALLET + 1
CNTR = 0
SHELL "c:\labels.bat"
CLOSE #2
KILL "C:\CSCNT.TXT"
OPEN "C:\CSCNT.TXT" FOR APPEND ACCESS WRITE LOCK READ WRITE AS #2
PRINT #2, " LINE # "; LINE$
PRINT #2, " "
PRINT #2, DATE$; " PALLET COUNT SUMMARY REPORT FOR PRODUCT "; PRODUCT$
PRINT #2, " "; PDESC$
PRINT #2, "--------------------------------------------------------------------"
CTWGT = CTWGT + TWGT
TWGT# = 0
TWGT = 0
SLEEP 1
GOTO 10
30 PRINT
PRINT
INPUT "End of complete run requested, are you sure? <Y> OR <N> :"; J$
IF J$ = "N" THEN
CNTR = 0
TWGT# = 0
TWGT = 0
COM(1) OFF
CLOSE #1
GOTO 10
END IF
IF J$ = "n" THEN
CNTR = 0
TWGT# = 0
TWGT = 0
COM(1) OFF
CLOSE #1
GOTO 10
END IF
PRINT CCNTR; " "; CTWGT
PRINT #3, ""
PRINT #3, " TOTAL CASES FOR RUN :"; CCNTR; " TOTAL WEIGHT FOR RUN :"; CTWGT
CLOSE #3
SHELL "c:\labels1.bat"
CLOSE
SYSTEM
END
Where it is printing the numeric value for the day of the month, I need it to print the number of days transpired in the year so far.
CLEAR
D$ = DATE$
DAY = VAL(MID$(D$, 4, 2))
COM(1) ON
OPEN "COM1:9600,N,8,1" FOR INPUT AS #1
CLOSE #1
CNTR = 0
CTWGT = 0
CCNTR = 0
PALLET = 1
KILL "C:\CSCNTOT.TXT"
OPEN "C:\CSCNTOT.TXT" FOR APPEND ACCESS WRITE LOCK READ WRITE AS #3
KILL "C:\CSCNT.TXT"
OPEN "C:\CSCNT.TXT" FOR APPEND ACCESS WRITE LOCK READ WRITE AS #2
PRINT #2, ""
PRINT #3, ""
5 PRINT CHR$(12)
INPUT "ENTER LINE # FOR RUN :"; LINE$
IF LINE$ = "EX" THEN END
IF LINE$ = "ex" THEN END
INPUT "ENTER PRODUCT CODE FOR RUN :"; PRODUCT$
IF PRODUCT$ = "EX" THEN END
IF PRODUCT$ = "ex" THEN END
INPUT "ENTER PRODUCT DESCRIPTION :"; PDESC$
IF PDESC$ = "EX" THEN END
IF PDESC$ = "ex" THEN END
PRINT #2, " LINE # "; LINE$
PRINT #2, " "
PRINT #2, DATE$; " PALLET COUNT SUMMARY REPORT FOR PRODUCT "; PRODUCT$
PRINT #2, " "; PDESC$
PRINT #2, "--------------------------------------------------------------------"
PRINT #3, " LINE # "; LINE$
PRINT #3, " "
PRINT #3, DATE$; " PALLET RUN COUNT SUMMARY REPORT FOR PRODUCT "; PRODUCT$
PRINT #3, " "; PDESC$
PRINT #3, "--------------------------------------------------------------------"
CLOSE COM1
10 SLEEP 1
SHELL "c:\setcom2.bat"
SLEEP 1
COM(1) ON
OPEN "COM1:9600,N,8,1" FOR INPUT AS #1
PRINT CHR$(12)
CNTR = CNTR + 1
PRINT " PRODUCT :"; PRODUCT$; " "; PDESC$; " LINE # "; LINE$; " PALLET NUMBER :"; PALLET
COLOR 12
PRINT " PLACE CASE NUMBER "; CNTR; "ON SCALE AND PRESS PRINT"
COLOR 15
PRINT " IF PALLET IS COMPLETE, REMOVE CASE FROM SCALE AND PRESS PRINT"
PRINT " WHEN RUN IS COMPLETE, ZERO OUT SCALE AND PRESS PRINT TO END RUN"
wgt$ = INPUT$(50, #1)
I = 1: Sppos = 0
DO WHILE I > 0
I = INSTR(Sppos + 1, wgt$, " ") 'Get position of next space.
IF I > 0 THEN Sppos = I
LOOP
'SPPOS now points to the position of the last space.
IF Sppos = 0 THEN
REM PRINT WGT$ 'WGT ONLY INPUT
ELSE
'Everything after last space.
wgt1$ = RIGHT$(wgt$, LEN(wgt$) - Sppos +
'Everything to the left of that
wgt1$ = LEFT$(wgt1$,
wgt$ = wgt1$
END IF
COM(1) OFF
wgt$ = LTRIM$(wgt$)
wgt$ = RTRIM$(wgt$)
wgt# = VAL(wgt$)
IF wgt# = 0 THEN GOTO 30
11 IF wgt# < 0 THEN GOTO 20
TWGT# = TWGT# + wgt#
PRINT #2, CNTR; "- "; wgt$
LPRINT CHR$(27); "A";
LPRINT CHR$(27); "E#5";
LPRINT CHR$(27); "A3H0100V0001";
LPRINT CHR$(27); "%2";
LPRINT CHR$(27); CHR$(27); "H000"; CHR$(27); "V150"; CHR$(27); "XM"; DAY
LPRINT CHR$(27); "A3H0230V0001";
LPRINT CHR$(27); "%2";
LPRINT CHR$(27); CHR$(27); "H000"; CHR$(27); "V090"; CHR$(27); "L0204"; CHR$(27); "XM"; wgt$
LPRINT CHR$(27); "Q1";
LPRINT CHR$(27); "Z";
CCNTR = CCNTR + 1
CLOSE #1
GOTO 10
20 TWGT# = TWGT# + .005
TWGT# = TWGT# * 100
TWGT# = INT(TWGT#)
TWGT! = (TWGT# / 100)
TWGT = TWGT!
PRINT #2, " "
PRINT #2, " TOTAL WEIGHT FOR PALLET NUMBER "; PALLET
PRINT #2, TWGT
PRINT #3, " TOTAL CASES FOR PALLET # :"; PALLET; " - "; CNTR - 1; " TOTAL WEIGHT :"; TWGT
CLOSE #1
CLOSE #2
LPRINT CHR$(27); "A";
LPRINT CHR$(27); "A3H0240V0001";
LPRINT CHR$(27); "%2";
LPRINT CHR$(27); CHR$(27); "H300"; CHR$(27); "V090"; CHR$(27); "L0103"; CHR$(27); "XM CASES"; CNTR - 1
LPRINT CHR$(27); CHR$(27); "H000"; CHR$(27); "V085"; CHR$(27); "L0103"; CHR$(27); "XM"; TWGT
LPRINT CHR$(27); "Q1";
LPRINT CHR$(27); "Z";
OPEN "c:\CSCNT.txt" FOR INPUT AS #2
PRINT " TOTAL WEIGHT FOR PALLET "; TWGT
PRINT " NOW PRINTING PALLET SHEET FOR PALLET :"; PALLET
PRINT CCNTR
SLEEP 1
PALLET = PALLET + 1
CNTR = 0
SHELL "c:\labels.bat"
CLOSE #2
KILL "C:\CSCNT.TXT"
OPEN "C:\CSCNT.TXT" FOR APPEND ACCESS WRITE LOCK READ WRITE AS #2
PRINT #2, " LINE # "; LINE$
PRINT #2, " "
PRINT #2, DATE$; " PALLET COUNT SUMMARY REPORT FOR PRODUCT "; PRODUCT$
PRINT #2, " "; PDESC$
PRINT #2, "--------------------------------------------------------------------"
CTWGT = CTWGT + TWGT
TWGT# = 0
TWGT = 0
SLEEP 1
GOTO 10
30 PRINT
INPUT "End of complete run requested, are you sure? <Y> OR <N> :"; J$
IF J$ = "N" THEN
CNTR = 0
TWGT# = 0
TWGT = 0
COM(1) OFF
CLOSE #1
GOTO 10
END IF
IF J$ = "n" THEN
CNTR = 0
TWGT# = 0
TWGT = 0
COM(1) OFF
CLOSE #1
GOTO 10
END IF
PRINT CCNTR; " "; CTWGT
PRINT #3, ""
PRINT #3, " TOTAL CASES FOR RUN :"; CCNTR; " TOTAL WEIGHT FOR RUN :"; CTWGT
CLOSE #3
SHELL "c:\labels1.bat"
CLOSE
SYSTEM
END
Where it is printing the numeric value for the day of the month, I need it to print the number of days transpired in the year so far.
Aah I understand now, thanks for clearing it up.
So, the purpose of the program is to retrieve the day number of the current year, of NOW. As you already figured out, DATE$ returns a string with the current date, as you can see here:
http://www.qbasicnews.com/qboho/qckadvr.datef.shtml.
It's in the format mm-dd-yyyy.
We can now retrieve the current month, day and year from the date.
Now the current month, day and year are in the 3 variables.
Now we can make an array of days per month:
This is the isleapyear code:
Now we calculate the number of days passed since newyear:
Now to see what day number it is:
(DaysPassed now contains number of days passed).
Hope this helped you . Anyway, do you want to see this all combined in one program or is this fine for you?
(didn't test, may contain some errors)
So, the purpose of the program is to retrieve the day number of the current year, of NOW. As you already figured out, DATE$ returns a string with the current date, as you can see here:
http://www.qbasicnews.com/qboho/qckadvr.datef.shtml.
It's in the format mm-dd-yyyy.
We can now retrieve the current month, day and year from the date.
Code: Select all
DECLARE FUNCTION IsLeapYear% (Z)
DEFINT A-Z
'$DYNAMIC
NowDate$ = DATE$
NowMonth = VAL(MID$(NowDate$, 1, 2))
NowDay = VAL(MID$(NowDate$, 4, 2))
NowYear = VAL(MID$(NowDate$, 7, 4))
Now we can make an array of days per month:
Code: Select all
DIM DaysInMonth(1 TO 12) AS INTEGER
DaysInMonth(1) = 31 'january
DaysInMonth(3) = 31 'march
DaysInMonth(4) = 30 'april
DaysInMonth(5) = 31 'may
DaysInMonth(6) = 30 'june
DaysInMonth(7) = 31 'july
DaysInMonth(8) = 31 'august
DaysInMonth(9) = 30 'september
DaysInMonth(10) = 31 'october
DaysInMonth(11) = 30 'november
DaysInMonth(12) = 31 'december
'now we must use the IsLeapYear function to see if february has 28 or 29 days
DaysInMonth(2) = 28 + ABS(IsLeapYear(NowYear))
Code: Select all
FUNCTION IsLeapYear (Z) STATIC
' If the year is evenly divisible by 4 and not divisible
' by 100, or if the year is evenly divisible by 400, then
' it's a leap year:
IsLeapYear = (Z MOD 4 = 0 AND Z MOD 100 <> 0) OR (Z MOD 400 = 0)
END FUNCTION
'moneo's code
Code: Select all
DaysPassed = 0
FOR I = 1 TO NowMonth - 1
DaysPassed = DaysPassed + DaysInMonth(I)
NEXT I
DaysPassed = DaysPassed + NowDay - 1
Code: Select all
PRINT DaysPassed
Hope this helped you . Anyway, do you want to see this all combined in one program or is this fine for you?
(didn't test, may contain some errors)
Thanks. I'll combine it and integrate it into my routine and run some tests. I used qbasic for this program because the enviroment these machines are in is harsh so they are not on the corporate lan, they are stand alone. And since I am print case labels on the production line and recording data for reports, it was simpler to poll via the com ports of stand alone machines. Thanks for your help.
Anyway, I'm swimming in time atm, so I'll make it somewhat nicer:
Now you can just copy-paste the function into your code (at the bottom of your program), and just call GetDayOfYear% to get the current day of the year. Like this:
Hope it works
Code: Select all
DECLARE FUNCTION GetDayOfYear% ()
DEFINT A-Z
'$DYNAMIC
FUNCTION GetDayOfYear%
NowDate$ = DATE$
NowMonth = VAL(MID$(NowDate$, 1, 2))
NowDay = VAL(MID$(NowDate$, 4, 2))
NowYear = VAL(MID$(NowDate$, 7, 4))
DIM DaysInMonth(1 TO 12) AS INTEGER
DaysInMonth(1) = 31 'january
DaysInMonth(3) = 31 'march
DaysInMonth(4) = 30 'april
DaysInMonth(5) = 31 'may
DaysInMonth(6) = 30 'june
DaysInMonth(7) = 31 'july
DaysInMonth(8) = 31 'august
DaysInMonth(9) = 30 'september
DaysInMonth(10) = 31 'october
DaysInMonth(11) = 30 'november
DaysInMonth(12) = 31 'december
'now we must use the IsLeapYear function to see if february has 28 or 29 days
IsLeapYear = (NowYear MOD 4 = 0 AND NowYear MOD 100 <> 0) OR (NowYear MOD 400 = 0)
DaysInMonth(2) = 28 + ABS(IsLeapYear)
DaysPassed = 0
FOR I = 1 TO NowMonth - 1
DaysPassed = DaysPassed + DaysInMonth(I)
NEXT I
DaysPassed = DaysPassed + NowDay - 1
'now the current day is missing:
DaysFromNewYear = DaysPassed + 1
'of course it's just stupid to subtract 1 three lines above, and now add 1 again, but it's for clarity.
'return the value
GetDayOfYear% = DaysFromNewYear
END FUNCTION
Code: Select all
CurrentDayOfYear% = GetDayOfYear%
Last edited by Anonymous on Tue Aug 31, 2004 7:57 am, edited 1 time in total.
I can code even without QB by hand, but the only problem then is that I can't test it. There might be some errors here and there, which can easily be fixed if I find them...
Anyway, the code looks long, but it can be drastically shortened. But for clarity it's better to leave it like this (not that it will be much slower or so).
Btw, in your code:
can be replaced by:
At least, I think. I don't know if QB1.1 supports UCASE$. I'm using QB4.5, which is a better version than QB1.1. Which version do you run?
Anyway, the code looks long, but it can be drastically shortened. But for clarity it's better to leave it like this (not that it will be much slower or so).
Btw, in your code:
Code: Select all
IF LINE$ = "EX" THEN END
IF LINE$ = "ex" THEN END
Code: Select all
IF UCASE$(LINE$) = "EX" THEN END
Can I see the code now?
It should be something like this:
The only thing you now need to alter I think is where you get and print the number of days since newyear.
(copy-paste into notepad, save as *.BAS file and open it with QB).
XP doesn't like DOS indeed I have Win2K
It should be something like this:
Code: Select all
REM - PROGRAM TO POLL EXTERNAL SCALE FOR A WEIGHT AND PRINT WEIGHT AND NUMERIC DAY ON SATO LABEL PRINTER
DECLARE FUNCTION GetDayOfYear% ()
'$DYNAMIC
CLEAR
D$ = DATE$
DAY = VAL(MID$(D$, 4, 2))
COM(1) ON
OPEN "COM1:9600,N,8,1" FOR INPUT AS #1
CLOSE #1
CNTR = 0
CTWGT = 0
CCNTR = 0
PALLET = 1
KILL "C:\CSCNTOT.TXT"
OPEN "C:\CSCNTOT.TXT" FOR APPEND ACCESS WRITE LOCK READ WRITE AS #3
KILL "C:\CSCNT.TXT"
OPEN "C:\CSCNT.TXT" FOR APPEND ACCESS WRITE LOCK READ WRITE AS #2
PRINT #2, ""
PRINT #3, ""
5 PRINT CHR$(12)
INPUT "ENTER LINE # FOR RUN :"; LINE$
IF LINE$ = "EX" THEN END
IF LINE$ = "ex" THEN END
INPUT "ENTER PRODUCT CODE FOR RUN :"; PRODUCT$
IF PRODUCT$ = "EX" THEN END
IF PRODUCT$ = "ex" THEN END
INPUT "ENTER PRODUCT DESCRIPTION :"; PDESC$
IF PDESC$ = "EX" THEN END
IF PDESC$ = "ex" THEN END
PRINT #2, " LINE # "; LINE$
PRINT #2, " "
PRINT #2, DATE$; " PALLET COUNT SUMMARY REPORT FOR PRODUCT "; PRODUCT$
PRINT #2, " "; PDESC$
PRINT #2, "--------------------------------------------------------------------"
PRINT #3, " LINE # "; LINE$
PRINT #3, " "
PRINT #3, DATE$; " PALLET RUN COUNT SUMMARY REPORT FOR PRODUCT "; PRODUCT$
PRINT #3, " "; PDESC$
PRINT #3, "--------------------------------------------------------------------"
CLOSE COM1
10 SLEEP 1
SHELL "c:\setcom2.bat"
SLEEP 1
COM(1) ON
OPEN "COM1:9600,N,8,1" FOR INPUT AS #1
PRINT CHR$(12)
CNTR = CNTR + 1
PRINT " PRODUCT :"; PRODUCT$; " "; PDESC$; " LINE # "; LINE$; " PALLET NUMBER :"; PALLET
PRINT
PRINT
COLOR 12
PRINT " PLACE CASE NUMBER "; CNTR; "ON SCALE AND PRESS PRINT"
COLOR 15
PRINT
PRINT
PRINT
PRINT " IF PALLET IS COMPLETE, REMOVE CASE FROM SCALE AND PRESS PRINT"
PRINT
PRINT " WHEN RUN IS COMPLETE, ZERO OUT SCALE AND PRESS PRINT TO END RUN"
wgt$ = INPUT$(50, #1)
I = 1: Sppos = 0
DO WHILE I > 0
I = INSTR(Sppos + 1, wgt$, " ") 'Get position of next space.
IF I > 0 THEN Sppos = I
LOOP
'SPPOS now points to the position of the last space.
IF Sppos = 0 THEN
REM PRINT WGT$ 'WGT ONLY INPUT
ELSE
'Everything after last space.
wgt1$ = RIGHT$(wgt$, LEN(wgt$) - Sppos +
'Everything to the left of that
wgt1$ = LEFT$(wgt1$,
wgt$ = wgt1$
END IF
COM(1) OFF
wgt$ = LTRIM$(wgt$)
wgt$ = RTRIM$(wgt$)
wgt# = VAL(wgt$)
IF wgt# = 0 THEN GOTO 30
11 IF wgt# < 0 THEN GOTO 20
TWGT# = TWGT# + wgt#
PRINT #2, CNTR; "- "; wgt$
LPRINT CHR$(27); "A";
LPRINT CHR$(27); "E#5";
LPRINT CHR$(27); "A3H0100V0001";
LPRINT CHR$(27); "%2";
LPRINT CHR$(27); CHR$(27); "H000"; CHR$(27); "V150"; CHR$(27); "XM"; DAY
LPRINT CHR$(27); "A3H0230V0001";
LPRINT CHR$(27); "%2";
LPRINT CHR$(27); CHR$(27); "H000"; CHR$(27); "V090"; CHR$(27); "L0204"; CHR$(27); "XM"; wgt$
LPRINT CHR$(27); "Q1";
LPRINT CHR$(27); "Z";
CCNTR = CCNTR + 1
CLOSE #1
GOTO 10
20 TWGT# = TWGT# + .005
TWGT# = TWGT# * 100
TWGT# = INT(TWGT#)
TWGT! = (TWGT# / 100)
TWGT = TWGT!
PRINT #2, " "
PRINT #2, " TOTAL WEIGHT FOR PALLET NUMBER "; PALLET
PRINT #2, TWGT
PRINT #3, " TOTAL CASES FOR PALLET # :"; PALLET; " - "; CNTR - 1; " TOTAL WEIGHT :"; TWGT
CLOSE #1
CLOSE #2
LPRINT CHR$(27); "A";
LPRINT CHR$(27); "A3H0240V0001";
LPRINT CHR$(27); "%2";
LPRINT CHR$(27); CHR$(27); "H300"; CHR$(27); "V090"; CHR$(27); "L0103"; CHR$(27); "XM CASES"; CNTR - 1
LPRINT CHR$(27); CHR$(27); "H000"; CHR$(27); "V085"; CHR$(27); "L0103"; CHR$(27); "XM"; TWGT
LPRINT CHR$(27); "Q1";
LPRINT CHR$(27); "Z";
OPEN "c:\CSCNT.txt" FOR INPUT AS #2
PRINT
PRINT " TOTAL WEIGHT FOR PALLET "; TWGT
PRINT " NOW PRINTING PALLET SHEET FOR PALLET :"; PALLET
PRINT CCNTR
SLEEP 1
PALLET = PALLET + 1
CNTR = 0
SHELL "c:\labels.bat"
CLOSE #2
KILL "C:\CSCNT.TXT"
OPEN "C:\CSCNT.TXT" FOR APPEND ACCESS WRITE LOCK READ WRITE AS #2
PRINT #2, " LINE # "; LINE$
PRINT #2, " "
PRINT #2, DATE$; " PALLET COUNT SUMMARY REPORT FOR PRODUCT "; PRODUCT$
PRINT #2, " "; PDESC$
PRINT #2, "--------------------------------------------------------------------"
CTWGT = CTWGT + TWGT
TWGT# = 0
TWGT = 0
SLEEP 1
GOTO 10
30 PRINT
PRINT
INPUT "End of complete run requested, are you sure? <Y> OR <N> :"; J$
IF J$ = "N" THEN
CNTR = 0
TWGT# = 0
TWGT = 0
COM(1) OFF
CLOSE #1
GOTO 10
END IF
IF J$ = "n" THEN
CNTR = 0
TWGT# = 0
TWGT = 0
COM(1) OFF
CLOSE #1
GOTO 10
END IF
PRINT CCNTR; " "; CTWGT
PRINT #3, ""
PRINT #3, " TOTAL CASES FOR RUN :"; CCNTR; " TOTAL WEIGHT FOR RUN :"; CTWGT
CLOSE #3
SHELL "c:\labels1.bat"
CLOSE
SYSTEM
END
FUNCTION GetDayOfYear%
NowDate$ = DATE$
NowMonth% = VAL(MID$(NowDate$, 1, 2))
NowDay% = VAL(MID$(NowDate$, 4, 2))
NowYear% = VAL(MID$(NowDate$, 7, 4))
DIM DaysInMonth(1 TO 12) AS INTEGER
DaysInMonth(1) = 31 'january
DaysInMonth(3) = 31 'march
DaysInMonth(4) = 30 'april
DaysInMonth(5) = 31 'may
DaysInMonth(6) = 30 'june
DaysInMonth(7) = 31 'july
DaysInMonth(8) = 31 'august
DaysInMonth(9) = 30 'september
DaysInMonth(10) = 31 'october
DaysInMonth(11) = 30 'november
DaysInMonth(12) = 31 'december
'now we must use the IsLeapYear function to see if february has 28 or 29 days
IsLeapYear% = (NowYear% MOD 4 = 0 AND NowYear% MOD 100 <> 0) OR (NowYear% MOD 400 = 0)
DaysInMonth(2) = 28 + ABS(IsLeapYear%)
DaysPassed% = 0
FOR I% = 1 TO NowMonth% - 1
DaysPassed% = DaysPassed% + DaysInMonth(I%)
NEXT I %
DaysPassed% = DaysPassed% + NowDay% - 1
'now the current day is missing:
DaysFromNewYear% = DaysPassed% + 1
'of course it's just stupid to subtract 1 three lines above, and now add 1 again, but it's for clarity.
'return the value
GetDayOfYear% = DaysFromNewYear%
END FUNCTION
(copy-paste into notepad, save as *.BAS file and open it with QB).
XP doesn't like DOS indeed I have Win2K
Thanks! You have been way too kind. My apologies for implying you were rude. You've gone beyond helping me. I will take this and try it in production and I will get back to you as soon as I can to let you know how it works out. Actually the dayspassed is to be included in another variable, you see instead of printing the "day" on the label which it does now, I needed it to be incorporated into out LOT number system which is going to replace it. I can do the rest , but this logic was beyond me as I was in unfamiliar waters. Thanks again for all your help and if I can ever assist you, feel free to drop me a line. Simplysimple9@aol.com
No problem. I like helping people. It's what I do here
Also, I don't need any assistance at the moment, due to the simple fact I don't have any projects running yet
Pete (this site's creator) will soon upload 2 of my best creations to his download section. Look for NeoLib v1.6 and BIGINT in the Libraries section (http://www.petesqbsite.com/downloads/libraries.shtml).
Currently I'm planning 2 projects, #1: A game like this: http://images.google.nl/images?hl=nl&lr ... &q=Gradius. And #2: Some tutorial sets covering whole QB and more
Btw, the DaysPassed% variable contains the number of days passed till now (which is, if it's 2nd of January now, it contains 1). The variable DaysFromNewYear% contains the number of days passed up to and including now (which is equal to DaysPassed% + 1).
Also, I don't need any assistance at the moment, due to the simple fact I don't have any projects running yet
Pete (this site's creator) will soon upload 2 of my best creations to his download section. Look for NeoLib v1.6 and BIGINT in the Libraries section (http://www.petesqbsite.com/downloads/libraries.shtml).
Currently I'm planning 2 projects, #1: A game like this: http://images.google.nl/images?hl=nl&lr ... &q=Gradius. And #2: Some tutorial sets covering whole QB and more
Btw, the DaysPassed% variable contains the number of days passed till now (which is, if it's 2nd of January now, it contains 1). The variable DaysFromNewYear% contains the number of days passed up to and including now (which is equal to DaysPassed% + 1).