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

Case Handling Question

Status
Not open for further replies.

Volkmaniac

Technical User
Mar 19, 2003
104
0
0
US
Hello,

I borrowed a date script taken off of This is a great script for date handling. I currently have the script grabbing everything from the previous month (02/01/04 to 02/29/04). I'd like the user to enter whichever month they'd like to run. Is there a way I can change cases or change the value of iMonth based on the month that the user enters? For instance, if they entered January I'd like 01/01/04 to 01/31/04.


ltimeints $LTIME iYear iMonth iDay2 iHour iMin iSec
if iDay2 <= 31
iMonth = iMonth-1
switch iMonth
case 1;January
case 3;March
case 5;May
case 7;July
case 8;August
case 10;October
case 12;December
iDay2 = 31;31 Days
endcase
case 4;April
case 6;June
case 9;September
case 11;November
iDay2 = 30;30 days
endcase
case 2
intsltime iYear iMonth iDay2 iHour iMin iSec TimeVal;Convert to a long time value
ltimemisc TimeVal iWeekday iDayYear iLeapYear;Get leap year value
if iLeapYear == 1;If leap year
iDay2 = 29;Set day to 29
else
iDay2 = 28;Else 28
endif
endcase
endswitch
endif

strfmt sDate2 "%02d-%02d-%d" iMonth iDay2 iYear;
strdelete sDate2 6 2;take off the first two digits of the year
 
If I understand what you are wanting to do correctly, probably the easiest way is to use the control in asptime.dll to display a calendar that will let the user select the month and year. You can then convert that long value to it's integer values using ltimeints as you are now and use the case statements you have now to create the values for sDate2 (plus adding a second strfmt command where the day value is hard-coded to 01 for the first day of the month). Here is a little more information from my site regarding how to interface with the asptime.dll file:

Procomm Plus comes with an ASPECT-callable DLL called ASPTIME.DLL. This DLL allows your script to display handy controls for users to input time and/or date values. ASPTIME.TXT, located in the ASPECT directory of your Procomm Plus installation, documents the functionality of this DLL. Be aware that ASPTIME.TXT incorrectly reports 0 being returned if the user did not select the OK button in the various controls available through ASPTIME.DLL - the correct value to check for is 2.

aspect@aspectscripting.com
 
Knob,

I don't have asptime.dll. Why doesn't this work? Is there a way I can convert the value stored in sMonth to become the value in iMonth?

ltimeints $LTIME iYear iMonth iDay iHour iMin iSec
sdlginput "Enter the number of the month" "Number of the Month: " sMonth
strtonum sMonth iMonth
transmit sMonth
transmit "^M"
if iDay <= 31
iMonth = iMonth
iDay = 1
endif
strfmt sDate "%02d-%02d-%d" iMonth iDay iYear
strdelete sDate 6 2
 
I tried this and it worked:

dialogbox 0 75 19 190 220 7 " LIQUIDATION BY SUPERVISOR"
pushbutton 141 82 34 100 24 "SECONDS"
pushbutton 142 82 68 100 24 "******QUIT******"
enddialog
while 1
dlgevent 0 Event
switch Event
case 0
endcase
case 141
ltimeints $LTIME iYear iMonth iDay iHour iMin iSec
sdlginput "Enter the number of the month" "Number of the Month: " sMonth
atoi sMonth iMonth
transmit sMonth
transmit "^M"

if iDay <= 31
iDay = 1
endif

strfmt sDate "%02d-%02d-%d" iMonth iDay iYear
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top