viewpoint-particle

Author Topic: Date Calculation Project  (Read 18768 times)

winuser2003

  • Newbie
  • *
  • Posts: 34
Date Calculation Project
« on: September 02, 2014, 07:09:10 am »
All,

I am working on a project that will do some date calculations. Below is a concept I am working on...



Goal : To be able enter in 1 date i.e (Target Upload Date) and click the calculate button to calculate the rest of the edit fields displaying the rest of the calculated dates. The only date that can be omitted is the Actual Upload Date because this particular date can be manually entered and not necessary for calculation.  Next, the (Create Template) button will create a template within a plain notepage file. I figure I can use this kind of code to create the template...

Code: [Select]
nm = "PromoCode Data"
fc = StrSub(nm,1,1)
trc = "C:\WBT\%fc%\%nm%.TRC"
ft = FileOpen("C:\PromoCodesTemplate","WRITE")
FileWrite(ft,StrCat(DateTime(),""))
FileWrite(ft,"------Template Form-------")
FileWrite(ft,"%nm%")
FileWrite(ft,"Prefix = REW")
FileWrite(ft,"Start Date =  %ebVariable4%")
FileWrite(ft,"End Date =     %ebVariable5%")
FileWrite(ft,"Country = US")
FileWrite(ft,"Promotion ID = US Rewards Free Cartridge")
FileWrite(ft,"No Of Coupon Codes = 7000")
FileWrite(ft,"BatchName = REW_%ebVariable16%_JULYTHIRTYA")
FileWrite(ft,"Filename = %ebVariable16%")
FileWrite(ft,"End of Date for Code File = <")
FileWrite(ft,"--------------------------------------")
FileClose(ft)

The View File, will bring up the notepad file so the data can be previewed and edited. Just launched in a standard notepad.

In conclusion, the importance is to try and calculate the dates correctly. There is more, but for now calculating the dates and reviewing the notepad is important. I am needing some advice on how to approach this. Please let me know if you have any questions.

The code starting out with the UI

Code: [Select]
MyDialogFormat=`WWWDLGED,6.2`

MyDialogCaption=`Promo Codes v1.0`
MyDialogX=141
MyDialogY=070
MyDialogWidth=380
MyDialogHeight=146
MyDialogNumControls=046
MyDialogProcedure=`DEFAULT`
MyDialogFont=`DEFAULT`
MyDialogTextColor=`DEFAULT`
MyDialogBackground=`DEFAULT,DEFAULT`
MyDialogConfig=0

MyDialog001=`093,127,036,012,PUSHBUTTON,"PushButton_OK",DEFAULT,"OK",1,10,32,DEFAULT,DEFAULT,DEFAULT`
MyDialog002=`247,127,036,012,PUSHBUTTON,"PushButton_Cancel",DEFAULT,"Cancel",0,20,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog003=`139,127,050,012,PUSHBUTTON,"PushButton_3",DEFAULT,"Create Templates",2,30,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog004=`011,017,058,012,EDITBOX,"EditBox_1",ebVariable1,"Edit 1",DEFAULT,40,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog005=`011,007,058,008,STATICTEXT,"StaticText_1",DEFAULT,"Target Upload Date :",DEFAULT,50,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog006=`077,017,058,012,EDITBOX,"EditBox_2",ebVariable2,"Edit 2",DEFAULT,60,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog007=`077,007,058,008,STATICTEXT,"StaticText_2",DEFAULT,"Actual Upload Date :",DEFAULT,70,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog008=`143,007,078,008,STATICTEXT,"StaticText_3",DEFAULT,"Promo Code New Batch Date :",DEFAULT,80,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog009=`143,017,078,012,EDITBOX,"EditBox_3",ebVariable3,"Edit 3",DEFAULT,90,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog010=`333,017,036,012,PUSHBUTTON,"PushButton_4",DEFAULT,"Calculate",3,100,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog011=`229,007,044,008,STATICTEXT,"StaticText_4",DEFAULT,"Start Date :",DEFAULT,110,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog012=`229,017,046,012,EDITBOX,"EditBox_4",ebVariable4,"Edit 4",DEFAULT,120,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog013=`281,007,044,008,STATICTEXT,"StaticText_5",DEFAULT,"Expiration Date :",DEFAULT,130,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog014=`281,017,044,012,EDITBOX,"EditBox_5",ebVariable5,"Edit 5",DEFAULT,140,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog015=`199,127,036,012,PUSHBUTTON,"PushButton_5",DEFAULT,"View File",4,150,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog016=`011,049,058,012,EDITBOX,"EditBox_6",ebVariable6,"Edit 6",DEFAULT,160,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog017=`077,049,058,012,EDITBOX,"EditBox_7",ebVariable7,"Edit 7",DEFAULT,170,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog018=`143,049,078,012,EDITBOX,"EditBox_8",ebVariable8,"Edit 8",DEFAULT,180,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog019=`231,049,044,012,EDITBOX,"EditBox_9",ebVariable9,"Edit 9",DEFAULT,190,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog020=`281,049,044,012,EDITBOX,"EditBox_10",ebVariable10,"Edit 10",DEFAULT,200,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog021=`011,083,060,012,EDITBOX,"EditBox_11",ebVariable11,"Edit 11",DEFAULT,210,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog022=`077,083,060,012,EDITBOX,"EditBox_12",ebVariable12,"Edit 12",DEFAULT,220,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog023=`143,083,080,012,EDITBOX,"EditBox_13",ebVariable13,"Edit 13",DEFAULT,230,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog024=`231,083,046,012,EDITBOX,"EditBox_14",ebVariable14,"Edit 14",DEFAULT,240,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog025=`283,083,042,012,EDITBOX,"EditBox_15",ebVariable15,"Edit 15",DEFAULT,250,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog026=`333,049,036,012,PUSHBUTTON,"PushButton_6",DEFAULT,"Calculate",5,260,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog027=`333,083,036,012,PUSHBUTTON,"PushButton_7",DEFAULT,"Calculate",6,270,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog028=`011,037,058,008,STATICTEXT,"StaticText_6",DEFAULT,"Target Upload Date :",DEFAULT,50,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog029=`077,037,058,008,STATICTEXT,"StaticText_8",DEFAULT,"Actual Upload Date :",DEFAULT,70,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog030=`143,037,078,008,STATICTEXT,"StaticText_9",DEFAULT,"Promo Code New Batch Date :",DEFAULT,80,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog031=`231,037,044,008,STATICTEXT,"StaticText_10",DEFAULT,"Start Date :",DEFAULT,110,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog032=`281,037,044,008,STATICTEXT,"StaticText_11",DEFAULT,"Expiration Date :",DEFAULT,130,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog033=`011,071,058,008,STATICTEXT,"StaticText_12",DEFAULT,"Target Upload Date :",DEFAULT,50,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog034=`079,071,058,008,STATICTEXT,"StaticText_13",DEFAULT,"Actual Upload Date :",DEFAULT,70,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog035=`143,071,080,008,STATICTEXT,"StaticText_14",DEFAULT,"Promo Code New Batch Date :",DEFAULT,80,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog036=`235,071,044,008,STATICTEXT,"StaticText_15",DEFAULT,"Start Date :",DEFAULT,110,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog037=`283,071,044,008,STATICTEXT,"StaticText_16",DEFAULT,"Expiration Date :",DEFAULT,130,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog038=`001,019,008,012,STATICTEXT,"StaticText_18",DEFAULT,"1.)",DEFAULT,380,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog039=`001,051,008,012,STATICTEXT,"StaticText_7",DEFAULT,"2.)",DEFAULT,390,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog040=`001,085,008,012,STATICTEXT,"StaticText_20",DEFAULT,"3.)",DEFAULT,400,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog041=`037,111,088,012,EDITBOX,"EditBox_16",ebVariable1,"Edit 16",DEFAULT,410,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog042=`037,103,044,008,STATICTEXT,"StaticText_22",DEFAULT,"Filename 1 :",DEFAULT,420,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog043=`133,111,088,012,EDITBOX,"EditBox_17",ebVariable2,"Edit 2",DEFAULT,430,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog044=`229,111,086,012,EDITBOX,"EditBox_18",ebVariable3,"Edit 3",DEFAULT,440,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog045=`133,103,044,008,STATICTEXT,"StaticText_17",DEFAULT,"Filename 2 :",DEFAULT,450,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog046=`229,103,044,008,STATICTEXT,"StaticText_24",DEFAULT,"Filename 3 :",DEFAULT,460,DEFAULT,DEFAULT,DEFAULT,DEFAULT`

ButtonPushed=Dialog("MyDialog")


td

  • Tech Support
  • *****
  • Posts: 3467
    • WinBatch
Re: Date Calculation Project
« Reply #1 on: September 02, 2014, 07:35:19 am »
If you are not familiar with how to script Dynamic Dialogs here is a link to a tutorial that should help get you started:

http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+Tutorials+All~about~Dynamic~Dialogs~6.2.txt

Time calculations are relatively easy using the WinBatch time functions like TimeAdd and TimeSubtract.  These function us the YmdHms format but it is easily converted to and from the conventional 'slash' format.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

JTaylor

  • Pundit
  • *****
  • Posts: 1363
    • Data & Stuff Inc.
Re: Date Calculation Project
« Reply #2 on: September 02, 2014, 08:02:07 am »
With all the questions I have it is hard to make suggestions...but as Tony noted, you will want to use a Dynamic Dialog.

Will you only have 3 Promotions?  If not, how will you change to different ones?
Why do the editing within the File and not in the Dialog?   Is the data already there and the only thing you need to do is insert a date?
If the only goal is to add the one date and perform calculations why go to the trouble of using a dialog?   Just script it to step through your files, add the new date, do the calculations and update your file.

Assuming you need to manually add the date and that you have multiple promotions to deal with I would suggest looking at the following options:

ItemListBox for the Promotion file name.  When you select one you can do the detail display for it and the calculations.
Calendar Control pop-up for the date you want to enter.  Can be triggered from typing in the date editbox.  This will avoid having to check to make sure you have valid dates. That event can also be the trigger for calculations and you can eliminate the Calc Button(s)
If file format isn't fixed perhaps use the IniReadPvt()/IniWritePvt() functions for your file.  It will make updating much easier and avoid the free-form editing and potential errors.


If you outline the process a bit more I am sure we can provide some better suggestions.

Jim

winuser2003

  • Newbie
  • *
  • Posts: 34
Re: Date Calculation Project
« Reply #3 on: September 02, 2014, 08:38:49 am »
All,

I agree, I will provide more data for review. Basically the general concept is you enter in one date and it calculates the rest. Example if you enter in one date in the "Target Upload Field" and you click the calculate button. The rest of the dates within section 1.) calculate and populate automatically. The only one that is omitted and will need manual intervention is the Actual Upload Date. If you also look closer at these dates, there is a pattern with them. There is a 14 day space between Target Upload date, Promo code new batch date, Start date, and expiration date. I assume entering this in as a formula should not be too difficult I would assume. I will test and work with Dynamic Dialogs, I have used those before, but can you explain the benefit? and if the user experience would be better?

JTaylor

  • Pundit
  • *****
  • Posts: 1363
    • Data & Stuff Inc.
Re: Date Calculation Project
« Reply #4 on: September 02, 2014, 08:52:31 am »
One of the benefits is that you have "Events".  That is, you can trigger actions based on user activity or other actions.   As I mentioned, there should be no need to have a calculate button as the act of entering the date can trigger the calculation.

Jim

winuser2003

  • Newbie
  • *
  • Posts: 34
Re: Date Calculation Project
« Reply #5 on: September 02, 2014, 09:03:13 am »
With all the questions I have it is hard to make suggestions...but as Tony noted, you will want to use a Dynamic Dialog.

Will you only have 3 Promotions? Yes only 3 so I created 3 sections

Why do the editing within the File and not in the Dialog? The goal is to try to do everything in the GUI and also calculate the dates correctly. Again there is a pattern to the dates, however the only date that can be omitted and will need manual intervention is Actual Upload Date 


Is the data already there and the only thing you need to do is insert a date? Correct, the goal is to enter in one date for example "Target Upload Date" then you click the calculate button and it will calculate the dates for section 1. You would repeat this process for the other sections 2 and 3.

If the only goal is to add the one date and perform calculations why go to the trouble of using a dialog? Training purposes and demo. Should something happen to me my backup will be able to use this application and apply it to everyday usage when necessary.


 Just script it to step through your files, add the new date, do the calculations and update your file.

Assuming you need to manually add the date and that you have multiple promotions to deal with I would suggest looking at the following options:

ItemListBox for the Promotion file name.  When you select one you can do the detail display for it and the calculations.
Calendar Control pop-up for the date you want to enter.  Can be triggered from typing in the date editbox.  This will avoid having to check to make sure you have valid dates. That event can also be the trigger for calculations and you can eliminate the Calc Button(s)
If file format isn't fixed perhaps use the IniReadPvt()/IniWritePvt() functions for your file.  It will make updating much easier and avoid the free-form editing and potential errors.


If you outline the process a bit more I am sure we can provide some better suggestions.

Jim

winuser2003

  • Newbie
  • *
  • Posts: 34
Re: Date Calculation Project
« Reply #6 on: September 02, 2014, 09:04:31 am »
Can you provide a small example of this? I think I understand where your coming from now.

One of the benefits is that you have "Events".  That is, you can trigger actions based on user activity or other actions.   As I mentioned, there should be no need to have a calculate button as the act of entering the date can trigger the calculation.

Jim

JTaylor

  • Pundit
  • *****
  • Posts: 1363
    • Data & Stuff Inc.
Re: Date Calculation Project
« Reply #7 on: September 02, 2014, 09:25:35 am »
The link Tony posted has examples.

Jim

stanl

  • Pundit
  • *****
  • Posts: 1190
Re: Date Calculation Project
« Reply #8 on: September 03, 2014, 06:25:21 am »
The link Tony posted has examples.

Jim


Might want to consider a single calendar control for each target, and auto-calculate the other dates from it. I think I can dig out an old example where I calculated TTL for coupons.

winuser2003

  • Newbie
  • *
  • Posts: 34
Re: Date Calculation Project
« Reply #9 on: September 03, 2014, 09:58:00 am »
I been going over this tutorial, I am understanding it little by little, so am I using this command in the code?
MSG_CALENDAR=9            ; Calendar date change

winuser2003

  • Newbie
  • *
  • Posts: 34
Re: Date Calculation Project
« Reply #10 on: September 03, 2014, 10:40:48 am »
Okay reading over this tutorial, it looks like I can create seperate cases for each instance. So in the event I would create a case for each date? which would define the condition it follows when an action is take. So in my mind I am thinking IF BUTTONPUSHED = X then it calculates the date for that particular section. I would overall create 3 seperate cases according to the tutorial. Case 001, Case 002, and Case 003 and each would be connected to the calculate button to perform the function of applying the correct dates.  Let me know if I lost anyone, again I am going through tutorial and examples. It would be more educational if I had something to start with understand the pattern of the code and go from there.

JTaylor

  • Pundit
  • *****
  • Posts: 1363
    • Data & Stuff Inc.
Re: Date Calculation Project
« Reply #11 on: September 03, 2014, 11:18:39 am »
Again, not clear on your process so making some assumptions here...

You are right in that there are situations where you would check to see if a button has been pushed and take action.   In your situation, if you already have the dates you can do the calculation as part of your load process.  If a date will be entered then I would trigger my calculations off the entering of the date.  Otherwise you are making the user enter the date and *then* click a button, which is an unnecessary step since you know that calculations need to be performed when a date is entered.   Basically, you have triggers for the only two times calculations need to be performed (loading the promo data and entering the date).  Adding a manual step to do it simply wastes your user's time.

The control to check would be your date field (editbox).  If someone tries to type in that field I would pop up a calendar control to select a date.  This avoids you needing to check to make sure it is a valid date.

Jim

winuser2003

  • Newbie
  • *
  • Posts: 34
Re: Date Calculation Project
« Reply #12 on: September 03, 2014, 11:42:03 am »
I apologize, I will present a process flow to get a better understanding... give me a few.

winuser2003

  • Newbie
  • *
  • Posts: 34
Re: Date Calculation Project
« Reply #13 on: September 03, 2014, 12:34:24 pm »
I attached a word document of the process flow of this application. Please let me know if you have any questions and I hope this clears alot of the air up.

Edit : The system says the file is too large, I am unsure if I am allowed to do this but I uploaded the doc to my web server. I apologize if this is not allowed, so let me know and I can find another way to present it

http://www.northprojectz.com/files/Promo%20Code%20Date%20Project.doc

JTaylor

  • Pundit
  • *****
  • Posts: 1363
    • Data & Stuff Inc.
Re: Date Calculation Project
« Reply #14 on: September 03, 2014, 12:51:23 pm »
I guess the question that comes to my mind after reading what you posted is, Why do you need a dialog or user interaction?  There appears to be no decision making.   It is all supplied data and calculations.  What does the Dialog do for you?

Jim

winuser2003

  • Newbie
  • *
  • Posts: 34
Re: Date Calculation Project
« Reply #15 on: September 03, 2014, 01:20:30 pm »
Why do you need a dialog or user interaction?
A concept was introduced to me during a training session one day. Create to train a monkey. I felt that a dialog will better be a guide for the user and people like to see SOMETHING do SOMETHING. If you click something it does something, if you enter something and click something it does something. The interaction creates the ability to the end user that something is being accomplished. I hope that makes sense.

I guess the question that comes to my mind after reading what you posted is, Why do you need a dialog or user interaction?  There appears to be no decision making.   It is all supplied data and calculations.  What does the Dialog do for you?

Jim

stanl

  • Pundit
  • *****
  • Posts: 1190
Re: Date Calculation Project
« Reply #16 on: September 04, 2014, 06:10:02 am »
Jim has a good point, but back to your original questions about date calculations I attached a sample to illustrate the relation between the calendar control and other dates calculated from it. The dialog uses vary text controls so they cannot be edited and some preset days to advance from the calendar date.

Unfortunately it doesn't work if you select a new date, but it was hastily put together and just something to play with if you need more practice with dynamic dialogs.....

I'm sure someone else reading this will correct the script.

winuser2003

  • Newbie
  • *
  • Posts: 34
Re: Date Calculation Project
« Reply #17 on: September 04, 2014, 07:38:12 am »
Thank you, I think this will be a good launchpad to move things forward. I am just working to try and make things easier, and again if there are easier methods, the suggestion are welcome. I will review this and let you know if I have any questions. Thank you for taking the time to present this to me.

stanl

  • Pundit
  • *****
  • Posts: 1190
Re: Date Calculation Project
« Reply #18 on: September 04, 2014, 08:13:23 am »
I made a real dumb mistake - forgot to turn on the calendar in the callback.  You need to add this line

        DialogProcOptions(MyDialog_Handle, MSG_CALENDAR , 1)

after

        DialogProcOptions(MyDialog_Handle,  DPO_CHANGESYSMENU, 4)

in the callback procedure - then the dates will update when you select a new calendar date.

winuser2003

  • Newbie
  • *
  • Posts: 34
Re: Date Calculation Project
« Reply #19 on: September 05, 2014, 04:45:28 am »
OKay, this is really helping me... so far I am discovering that this one line...

#EndSubRoutine                                               ; End of Dialog Callback MyDialogCallbackProc

#DefineFunction cvtDate(d)
Return ( ItemExtract(2,d,":"):"/":ItemExtract(3,d,":"):"/":ItemExtract(1,d,":") )
#EndFunction

this is the line that is doing the calculations.  So I notice when I click a date on the calendar it goes 4 days ahead. However, in this formula I am seeing 3 days? correct me if I am wrong.

winuser2003

  • Newbie
  • *
  • Posts: 34
Re: Date Calculation Project
« Reply #20 on: September 05, 2014, 05:08:59 am »
Wait... I think I found it...

;number of daya to advance
next1=3
next2=5
next3=7

and then your setting the variable in the dialog ....

nadd1, 2, and 3.

winuser2003

  • Newbie
  • *
  • Posts: 34
Re: Date Calculation Project
« Reply #21 on: September 05, 2014, 06:10:34 am »
All, Good News!!

Making great headway on this application, so instead of a calandar, could there be a drop down instead? I posted the code thus far, but this is definitely in the right direction

Code: [Select]
gosub udfs
t1=TimeSubtract(TimeYmdHms(), "0000:00:01:00:00:00")

;number of daya to advance
next1=204
next2=90
next3=98

nadd1="0000:00:0%next1%:00:00:00"
nadd2="0000:00:0%next2%:00:00:00"
nadd3="0000:00:0%next3%:00:00:00"

settime()




TCFormat=`WWWDLGED,6.2`

TCCaption=`Test Calandar`
TCX=120
TCY=101
TCWidth=360
TCHeight=122
TCNumControls=010
TCProcedure=`dlgproc`
TCFont=`DEFAULT`
TCTextColor=`DEFAULT`
TCBackground=`DEFAULT,DEFAULT`
TCConfig=0

TC001=`003,013,088,078,CALENDAR,"C1",t1,DEFAULT,DEFAULT,10,DEFAULT,DEFAULT`
TC002=`301,015,044,012,VARYTEXT,"V1",t2,DEFAULT,DEFAULT,20,DEFAULT,DEFAULT,DEFAULT,"255|255|255"`
TC003=`101,015,052,012,VARYTEXT,"V2",t3,DEFAULT,DEFAULT,30,0,DEFAULT,DEFAULT,"255|255|255"`
TC004=`161,015,078,012,VARYTEXT,"V3",t4,DEFAULT,DEFAULT,40,DEFAULT,DEFAULT,DEFAULT,"255|255|255"`
TC005=`003,003,052,012,STATICTEXT,"StaticText_1",DEFAULT,"Actual Upload Date :",DEFAULT,50,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC006=`101,003,054,012,STATICTEXT,"StaticText_2",DEFAULT,"Target Upload Date :",DEFAULT,60,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC007=`161,003,078,012,STATICTEXT,"StaticText_3",DEFAULT,"Promo Code New Batch Date :",DEFAULT,70,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC008=`247,003,048,012,STATICTEXT,"StaticText_4",DEFAULT,"Start Date :",DEFAULT,80,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC009=`301,003,044,012,STATICTEXT,"StaticText_5",DEFAULT,"Expiration Date :",DEFAULT,90,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC010=`247,015,048,012,VARYTEXT,"V4",t2,DEFAULT,DEFAULT,20,DEFAULT,DEFAULT,DEFAULT,"255|255|255"`

ButtonPushed=Dialog("TC")

Exit



:udfs
;============================================================
;============================================================
;============================================================
#DefineSubRoutine InitDialogConstants()
   ;DialogprocOptions Constants
   MSG_INIT=0                ; The one-time initialization
   MSG_TIMER=1               ; Timer event
   MSG_BUTTONPUSHED=2        ; Pushbutton or Picturebutton
   MSG_RADIOPUSHED=3         ; Radiobutton clicked
   MSG_CHECKBOX=4            ; Checkbox clicked
   MSG_EDITBOX=5             ; Editbox or Multilinebox
   MSG_FILESELECT=6          ; Filelistbox
   MSG_ITEMSELECT=7          ; Itembox
   MSG_COMBOCHANGE=8         ; Combobox/Droplistbox
   MSG_CALENDAR=9            ; Calendar date change
   MSG_SPINNER=10            ; Spinner number change
   MSG_CLOSEVIA49=11         ; Close clicked (Enabled via DialogProcOptions 1002
   MSG_FILEBOXDOUBLECLICK=12 ; Get double-click message on a FileListBox
   MSG_ITEMBOXDOUBLECLICK=13 ; Get double-click message on an ItemBox
   MSG_COMEVENT=14           ; COMCONTROL Event notification from DialogObject (NOT DialogProcOptions)
   MSG_MENUITEM=15           ; MenuItem selected
   MSG_MENUITEMINIT=16       ; MenuItem initialized

   DPO_DISABLESTATE=1000     ; codes -1=GetSetting 0=EnableDialog 1=DisableDialog
   DPO_CHANGEBACKGROUND=1001 ; -1=Get Current otherise bitmap or color string
   DPO_CHANGESYSMENU=1002    ; -1=Get Current 0=none 1=close 2=close/min 3=close/max 4=close/min/max
   DPO_CHANGETITLE=1003      ; Set/Get Dialog Title - (-1 to get)
   DPO_GETNAME=1004          ;  Returns the name associated with a control's number.
   DPO_GETNUMBER=1005        ;  Returns the number associated with a control's name.

   ;DialogControlState Constants
   DCSTATE_SETFOCUS=1        ; Give Control Focus
   DCSTATE_QUERYSTYLE=2      ; Query control's style
   DCSTATE_ADDSTYLE=3        ; Add control style
   DCSTATE_REMOVESTYLE=4     ; Remove control style
   DCSTATE_GETFOCUS=5        ; Get control that has focus
   DCSTATE_MOVEMOUSEOVER=6   ; Move the mouse over the control

   DCSTYLE_DEFAULT=0         ; Set Default Style
   DCSTYLE_INVISIBLE=1       ; Set Control Invisible
   DCSTYLE_DISABLED=2        ; Set Control Disabled
   DCSTYLE_NOUSERDATA=4      ; Note: Setable via DialogControlState function ONLY SPINNER control only
   DCSTYLE_READONLY=8        ; Sets control to read-only (user cannot type in data) EDITBOX MULTILINEBOX SPINNER
   DCSTYLE_PASSWORD=16       ; Sets 'password mode' where only *'s are displayed EDITBOX
   DCSTYLE_DEFAULTBUTTON=32  ; Sets a button as the default button PUSHBUTTON PICTUREBUTTON
   DCSTYLE_DIGITSONLY=64     ; Set edit box to accept digits only EDITMOX MULTILINEBOX
   DCSTYLE_FLAT=128          ; Makes a 'flat' hyperlink-looking button PUSHBUTTON PICTUREBUTTON
   DCSTYLE_NOADJUST=256      ; Turns off auto-height adjustment  ITEMBOX FILELISTBOX
   DCSTYLE_TEXTCENTER=512    ; Center text in control VARYTEXT STATICTEXT
   DCSTYLE_TEXTRIGHT=1024    ; Flush-Right text in control VARYTEXT STATICTEXT
   DCSTYLE_NOSELCURLEFT=2048 ; No selection, cursor left EDITBOX MULTILINEBOX
   DCSTYLE_NOSELCURRIGHT=4096; No selection, cursor right EDITBOX MULTILINEBOX
   DCSTYLE_SHIELD=8192       ; Display Security Shield icon on button (Vista only) PUSHBUTTON PICTUREBUTTON
   DCSTYLE_MENUCHECK=32768   ; Adds a check mark to the left of a menu item MENUITEM
   DCSTYLE_MENURADIO=65536   ; Adds a radio button like dot graphic to the left of a menu item MENUITEM
   DCSTYLE_MENUSEP=131072    ; Separator bar graphic MENUITEM
   DCSTYLE_MENUBREAK=262144  ; column break MENUBAR

   ;DialogControlSet / DialogControlGet Constants
   DC_CHECKBOX=1             ; CHECKBOX
   DC_RADIOBUTTON=2          ; RADIOBUTTON
   DC_EDITBOX=3              ; EDITBOX MULTILINEBOX
   DC_TITLE=4                ; PICTURE RADIOBUTTON CHECKBOX PICTUREBUTTON VARYTEXT STATICTEXT GROUPBOX PUSHBUTTON MENUITEM
   DC_ITEMBOXCONTENTS=5      ; ITEMBOX FILELISTBOX DROPLISTBOX
   DC_ITEMBOXSELECT=6        ; ITEMBOX FILELISTBOX DROPLISTBOX
   DC_CALENDAR=7             ; CALENDAR
   DC_SPINNER=8              ; SPINNER
   DC_MULTITABSTOPS=9        ; MULTILINEBOX
   DC_ITEMSCROLLPOS=10       ; ITEMBOX FILELISTBOX
   DC_BACKGROUNDCOLOR=11     ; RADIOBUTTON CHECKBOX VARYTEXT STATICTEXT GROUPBOX PUSHBUTTON ITEMBOX FILELISTBOX DROPLISTBOX SPINNER EDITBOX MULTILINEBOX
   DC_PICTUREBITMAP=12       ; PICTURE PICTUREBUTTON
   DC_TEXTCOLOR=13           ; RADIOBUTTON CHECKBOX VARYTEXT STATICTEXT GROUPBOX PUSHBUTTON ITEMBOX FIELLISTBOX DROPLISTBOX SPINNER EDITBOX MULTILINEBOX
   DC_ITEMBOXADD=14          ; ITEMBOX FILELISTBOX DROPLISTBOX
   DC_ITEMBOXREMOVE=15       ; ITEMBOX FILELISTBOX DROPLISTBOX
   DC_RADIOVALUE=16          ; RADIOBUTTON
   DC_POSITION=17            ; ALL CONTROLS (Except MENUBAR and MENUITEM)
   DC_MENUNAMES=18           ; ALL CONTROLS
   DC_HANDLE=19              ; ALL CONTROLS (Except MENUBAR and MENUITEM)


   ;DialogObject constants
   DLGOBJECT_ADDEVENT=1      ; Call dialog callback when the specified event occurs
   DLGOBJECT_STOPEVENT=2     ; Stop calling dialog callback when an event previously requested with
   DLGOBJECT_GETOBJECT=3     ; Return an object references to the specified control
   DLGOBJECT_GETPICTURE=4    ; Create and return an object reference to a picture object

   ;Return code constants
   RET_DO_CANCEL=0           ; Cancels dialog
   RET_DO_DEFAULT= -1        ; Continue with default processing for control
   RET_DO_NOT_EXIT= -2       ; Do not exit the dialog
   Return
#EndSubRoutine
;============================================================
;============================================================
;============================================================


#DefineSubRoutine dlgproc(MyDialog_Handle,MyDialog_Message,MyDialog_Name,MyDialog_EventInfo,rsvd)
   InitDialogConstants()                                   ; Initialize Dialog Constants
   ON_EQUAL = @TRUE                                         ; Initialize variable ON_EQUAL
   Switch MyDialog_Message                                  ; Switch based on Dialog Message type
     Case MSG_INIT                                         ; Standard Initialization message
        DialogProcOptions(MyDialog_Handle,  DPO_CHANGESYSMENU, 4)
  DialogProcOptions(MyDialog_Handle, MSG_CALENDAR , 1)
        Return(RET_DO_DEFAULT)
     Case MSG_CALENDAR
        t1 = DialogControlGet(MyDialog_Handle,"C1",7)     
        settime()
        DialogControlSet(MyDialog_Handle,"V1",4,t2)
        DialogControlSet(MyDialog_Handle,"V2",4,t3)
        DialogControlSet(MyDialog_Handle,"V3",4,t4)
  DialogControlSet(MyDialog_Handle,"V4",4,t4)
        Return(RET_DO_DEFAULT)
     Case MSG_CLOSEVIA49
        Exit
     Case ON_EQUAL
        Return(RET_DO_DEFAULT)

   EndSwitch 
   Return(RET_DO_DEFAULT)
#EndSubRoutine                                               ; End of Dialog Callback MyDialogCallbackProc

#DefineFunction cvtDate(d)
Return ( ItemExtract(2,d,":"):"/":ItemExtract(3,d,":"):"/":ItemExtract(1,d,":") )
#EndFunction

#DefineSubRoutine settime()
t2=cvtdate(TimeAdd(t1,nadd1))
t3=cvtdate(TimeAdd(t1,nadd2))
t4=cvtdate(TimeAdd(t1,nadd3))
Return(1)
#EndSubRoutine



Return

stanl

  • Pundit
  • *****
  • Posts: 1190
Re: Date Calculation Project
« Reply #22 on: September 05, 2014, 06:59:51 am »
All, Good News!!

Making great headway on this application, so instead of a calandar, could there be a drop down instead?

First - you re-drew the dialog and therefore the control names will have to be updated with the dialog procedures in the callback.
 
2nd - of course there could be a dropdown (of dates, I'm assuming). My personal opinion is that it would be messy. You would have to maintain a huge array of dates in mm/dd/yyyy as the dropdown choices and these would require updating as you moved forward in time. Then you would have to convert the picked date from that format to WB time format, do the math, then convert back to mm/dd/yyyy format for the calculated dates.  Again, my personal opinion, but I believe a calendar control is more visually pleasing in a dialog.  I have created multiple compiled EXE's for work with 2-4 calendars on dialog with no user complaints.

winuser2003

  • Newbie
  • *
  • Posts: 34
Re: Date Calculation Project
« Reply #23 on: September 05, 2014, 07:38:48 am »


So here is the new concept, I believe this is the direction EVERYONE is telling me to go in with this project. I also put in the code below, now I have to figure out how to apply the calculations to this concept. One line is already completed. I have posted the new code below so hopefully I am on the right track altering the code.

Code: [Select]
gosub udfs
t1=TimeSubtract(TimeYmdHms(), "0000:00:01:00:00:00")

;number of daya to advance
next1=204
next2=90
next3=98

nadd1="0000:00:0%next1%:00:00:00"
nadd2="0000:00:0%next2%:00:00:00"
nadd3="0000:00:0%next3%:00:00:00"

settime()




TCFormat=`WWWDLGED,6.2`

TCCaption=`Promo Codes Concept`
TCX=178
TCY=064
TCWidth=360
TCHeight=104
TCNumControls=026
TCProcedure=`dlgproc`
TCFont=`DEFAULT`
TCTextColor=`DEFAULT`
TCBackground=`DEFAULT,DEFAULT`
TCConfig=0

TC001=`003,013,088,078,CALENDAR,"C1",t1,DEFAULT,DEFAULT,10,DEFAULT,DEFAULT`
TC002=`301,015,044,012,VARYTEXT,"V1",t2,DEFAULT,DEFAULT,20,DEFAULT,DEFAULT,DEFAULT,"255|255|255"`
TC003=`101,015,052,012,VARYTEXT,"V2",t3,DEFAULT,DEFAULT,30,0,DEFAULT,DEFAULT,"255|255|255"`
TC004=`161,015,078,012,VARYTEXT,"V3",t4,DEFAULT,DEFAULT,40,DEFAULT,DEFAULT,DEFAULT,"255|255|255"`
TC005=`003,003,052,012,STATICTEXT,"StaticText_1",DEFAULT,"Actual Upload Date :",DEFAULT,50,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC006=`101,003,054,012,STATICTEXT,"StaticText_2",DEFAULT,"Target Upload Date :",DEFAULT,60,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC007=`161,003,078,012,STATICTEXT,"StaticText_3",DEFAULT,"Promo Code New Batch Date :",DEFAULT,70,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC008=`247,003,048,012,STATICTEXT,"StaticText_4",DEFAULT,"Start Date :",DEFAULT,80,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC009=`301,003,044,012,STATICTEXT,"StaticText_5",DEFAULT,"Expiration Date :",DEFAULT,90,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC010=`247,015,048,012,VARYTEXT,"V4",t2,DEFAULT,DEFAULT,20,DEFAULT,DEFAULT,DEFAULT,"255|255|255"`
TC011=`101,031,054,012,STATICTEXT,"StaticText_6",DEFAULT,"Target Upload Date :",DEFAULT,60,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC012=`101,061,054,012,STATICTEXT,"StaticText_7",DEFAULT,"Target Upload Date :",DEFAULT,60,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC013=`161,031,078,012,STATICTEXT,"StaticText_8",DEFAULT,"Promo Code New Batch Date :",DEFAULT,70,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC014=`161,061,078,012,STATICTEXT,"StaticText_9",DEFAULT,"Promo Code New Batch Date :",DEFAULT,70,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC015=`247,031,048,012,STATICTEXT,"StaticText_10",DEFAULT,"Start Date :",DEFAULT,80,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC016=`247,061,048,012,STATICTEXT,"StaticText_11",DEFAULT,"Start Date :",DEFAULT,80,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC017=`301,031,044,012,STATICTEXT,"StaticText_12",DEFAULT,"Expiration Date :",DEFAULT,90,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC018=`301,061,044,012,STATICTEXT,"StaticText_13",DEFAULT,"Expiration Date :",DEFAULT,90,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC019=`101,045,054,012,VARYTEXT,"V6",t6,DEFAULT,DEFAULT,190,DEFAULT,DEFAULT,DEFAULT,"255|255|255"`
TC020=`161,045,078,012,VARYTEXT,"V7",t7,DEFAULT,DEFAULT,200,DEFAULT,DEFAULT,DEFAULT,"255|255|255"`
TC021=`247,045,048,012,VARYTEXT,"V8",t8,DEFAULT,DEFAULT,210,DEFAULT,DEFAULT,DEFAULT,"255|255|255"`
TC022=`301,045,046,012,VARYTEXT,"V9",t8,DEFAULT,DEFAULT,220,DEFAULT,DEFAULT,DEFAULT,"255|255|255"`
TC023=`101,077,054,012,VARYTEXT,"V10",t10,DEFAULT,DEFAULT,230,DEFAULT,DEFAULT,DEFAULT,"255|255|255"`
TC024=`161,077,080,012,VARYTEXT,"V11",t11,DEFAULT,DEFAULT,240,DEFAULT,DEFAULT,DEFAULT,"255|255|255"`
TC025=`247,077,048,012,VARYTEXT,"V12",t12,DEFAULT,DEFAULT,250,DEFAULT,DEFAULT,DEFAULT,"255|255|255"`
TC026=`301,077,046,012,VARYTEXT,"V13",t12,DEFAULT,DEFAULT,260,DEFAULT,DEFAULT,DEFAULT,"255|255|255"`

ButtonPushed=Dialog("TC")









Exit



:udfs
;============================================================
;============================================================
;============================================================
#DefineSubRoutine InitDialogConstants()
   ;DialogprocOptions Constants
   MSG_INIT=0                ; The one-time initialization
   MSG_TIMER=1               ; Timer event
   MSG_BUTTONPUSHED=2        ; Pushbutton or Picturebutton
   MSG_RADIOPUSHED=3         ; Radiobutton clicked
   MSG_CHECKBOX=4            ; Checkbox clicked
   MSG_EDITBOX=5             ; Editbox or Multilinebox
   MSG_FILESELECT=6          ; Filelistbox
   MSG_ITEMSELECT=7          ; Itembox
   MSG_COMBOCHANGE=8         ; Combobox/Droplistbox
   MSG_CALENDAR=9            ; Calendar date change
   MSG_SPINNER=10            ; Spinner number change
   MSG_CLOSEVIA49=11         ; Close clicked (Enabled via DialogProcOptions 1002
   MSG_FILEBOXDOUBLECLICK=12 ; Get double-click message on a FileListBox
   MSG_ITEMBOXDOUBLECLICK=13 ; Get double-click message on an ItemBox
   MSG_COMEVENT=14           ; COMCONTROL Event notification from DialogObject (NOT DialogProcOptions)
   MSG_MENUITEM=15           ; MenuItem selected
   MSG_MENUITEMINIT=16       ; MenuItem initialized

   DPO_DISABLESTATE=1000     ; codes -1=GetSetting 0=EnableDialog 1=DisableDialog
   DPO_CHANGEBACKGROUND=1001 ; -1=Get Current otherise bitmap or color string
   DPO_CHANGESYSMENU=1002    ; -1=Get Current 0=none 1=close 2=close/min 3=close/max 4=close/min/max
   DPO_CHANGETITLE=1003      ; Set/Get Dialog Title - (-1 to get)
   DPO_GETNAME=1004          ;  Returns the name associated with a control's number.
   DPO_GETNUMBER=1005        ;  Returns the number associated with a control's name.

   ;DialogControlState Constants
   DCSTATE_SETFOCUS=1        ; Give Control Focus
   DCSTATE_QUERYSTYLE=2      ; Query control's style
   DCSTATE_ADDSTYLE=3        ; Add control style
   DCSTATE_REMOVESTYLE=4     ; Remove control style
   DCSTATE_GETFOCUS=5        ; Get control that has focus
   DCSTATE_MOVEMOUSEOVER=6   ; Move the mouse over the control

   DCSTYLE_DEFAULT=0         ; Set Default Style
   DCSTYLE_INVISIBLE=1       ; Set Control Invisible
   DCSTYLE_DISABLED=2        ; Set Control Disabled
   DCSTYLE_NOUSERDATA=4      ; Note: Setable via DialogControlState function ONLY SPINNER control only
   DCSTYLE_READONLY=8        ; Sets control to read-only (user cannot type in data) EDITBOX MULTILINEBOX SPINNER
   DCSTYLE_PASSWORD=16       ; Sets 'password mode' where only *'s are displayed EDITBOX
   DCSTYLE_DEFAULTBUTTON=32  ; Sets a button as the default button PUSHBUTTON PICTUREBUTTON
   DCSTYLE_DIGITSONLY=64     ; Set edit box to accept digits only EDITMOX MULTILINEBOX
   DCSTYLE_FLAT=128          ; Makes a 'flat' hyperlink-looking button PUSHBUTTON PICTUREBUTTON
   DCSTYLE_NOADJUST=256      ; Turns off auto-height adjustment  ITEMBOX FILELISTBOX
   DCSTYLE_TEXTCENTER=512    ; Center text in control VARYTEXT STATICTEXT
   DCSTYLE_TEXTRIGHT=1024    ; Flush-Right text in control VARYTEXT STATICTEXT
   DCSTYLE_NOSELCURLEFT=2048 ; No selection, cursor left EDITBOX MULTILINEBOX
   DCSTYLE_NOSELCURRIGHT=4096; No selection, cursor right EDITBOX MULTILINEBOX
   DCSTYLE_SHIELD=8192       ; Display Security Shield icon on button (Vista only) PUSHBUTTON PICTUREBUTTON
   DCSTYLE_MENUCHECK=32768   ; Adds a check mark to the left of a menu item MENUITEM
   DCSTYLE_MENURADIO=65536   ; Adds a radio button like dot graphic to the left of a menu item MENUITEM
   DCSTYLE_MENUSEP=131072    ; Separator bar graphic MENUITEM
   DCSTYLE_MENUBREAK=262144  ; column break MENUBAR

   ;DialogControlSet / DialogControlGet Constants
   DC_CHECKBOX=1             ; CHECKBOX
   DC_RADIOBUTTON=2          ; RADIOBUTTON
   DC_EDITBOX=3              ; EDITBOX MULTILINEBOX
   DC_TITLE=4                ; PICTURE RADIOBUTTON CHECKBOX PICTUREBUTTON VARYTEXT STATICTEXT GROUPBOX PUSHBUTTON MENUITEM
   DC_ITEMBOXCONTENTS=5      ; ITEMBOX FILELISTBOX DROPLISTBOX
   DC_ITEMBOXSELECT=6        ; ITEMBOX FILELISTBOX DROPLISTBOX
   DC_CALENDAR=7             ; CALENDAR
   DC_SPINNER=8              ; SPINNER
   DC_MULTITABSTOPS=9        ; MULTILINEBOX
   DC_ITEMSCROLLPOS=10       ; ITEMBOX FILELISTBOX
   DC_BACKGROUNDCOLOR=11     ; RADIOBUTTON CHECKBOX VARYTEXT STATICTEXT GROUPBOX PUSHBUTTON ITEMBOX FILELISTBOX DROPLISTBOX SPINNER EDITBOX MULTILINEBOX
   DC_PICTUREBITMAP=12       ; PICTURE PICTUREBUTTON
   DC_TEXTCOLOR=13           ; RADIOBUTTON CHECKBOX VARYTEXT STATICTEXT GROUPBOX PUSHBUTTON ITEMBOX FIELLISTBOX DROPLISTBOX SPINNER EDITBOX MULTILINEBOX
   DC_ITEMBOXADD=14          ; ITEMBOX FILELISTBOX DROPLISTBOX
   DC_ITEMBOXREMOVE=15       ; ITEMBOX FILELISTBOX DROPLISTBOX
   DC_RADIOVALUE=16          ; RADIOBUTTON
   DC_POSITION=17            ; ALL CONTROLS (Except MENUBAR and MENUITEM)
   DC_MENUNAMES=18           ; ALL CONTROLS
   DC_HANDLE=19              ; ALL CONTROLS (Except MENUBAR and MENUITEM)


   ;DialogObject constants
   DLGOBJECT_ADDEVENT=1      ; Call dialog callback when the specified event occurs
   DLGOBJECT_STOPEVENT=2     ; Stop calling dialog callback when an event previously requested with
   DLGOBJECT_GETOBJECT=3     ; Return an object references to the specified control
   DLGOBJECT_GETPICTURE=4    ; Create and return an object reference to a picture object

   ;Return code constants
   RET_DO_CANCEL=0           ; Cancels dialog
   RET_DO_DEFAULT= -1        ; Continue with default processing for control
   RET_DO_NOT_EXIT= -2       ; Do not exit the dialog
   Return
#EndSubRoutine
;============================================================
;============================================================
;============================================================


#DefineSubRoutine dlgproc(MyDialog_Handle,MyDialog_Message,MyDialog_Name,MyDialog_EventInfo,rsvd)
   InitDialogConstants()                                   ; Initialize Dialog Constants
   ON_EQUAL = @TRUE                                         ; Initialize variable ON_EQUAL
   Switch MyDialog_Message                                  ; Switch based on Dialog Message type
     Case MSG_INIT                                         ; Standard Initialization message
        DialogProcOptions(MyDialog_Handle,  DPO_CHANGESYSMENU, 4)
  DialogProcOptions(MyDialog_Handle, MSG_CALENDAR , 1)
        Return(RET_DO_DEFAULT)
     Case MSG_CALENDAR
        t1 = DialogControlGet(MyDialog_Handle,"C1",7)     
        settime()
        DialogControlSet(MyDialog_Handle,"V1",4,t2)
        DialogControlSet(MyDialog_Handle,"V2",4,t3)
        DialogControlSet(MyDialog_Handle,"V3",4,t4)
  DialogControlSet(MyDialog_Handle,"V4",4,t4)
        Return(RET_DO_DEFAULT)
     Case MSG_CLOSEVIA49
        Exit
     Case ON_EQUAL
        Return(RET_DO_DEFAULT)

   EndSwitch 
   Return(RET_DO_DEFAULT)
#EndSubRoutine                                               ; End of Dialog Callback MyDialogCallbackProc

#DefineFunction cvtDate(d)
Return ( ItemExtract(2,d,":"):"/":ItemExtract(3,d,":"):"/":ItemExtract(1,d,":") )
#EndFunction

#DefineSubRoutine settime()
t2=cvtdate(TimeAdd(t1,nadd1))
t3=cvtdate(TimeAdd(t1,nadd2))
t4=cvtdate(TimeAdd(t1,nadd3))
Return(1)
#EndSubRoutine



Return

JTaylor

  • Pundit
  • *****
  • Posts: 1363
    • Data & Stuff Inc.
Re: Date Calculation Project
« Reply #24 on: September 05, 2014, 07:47:18 am »
If the only date choices allowed are those in your list then you may want to consider a drop-down list but if the whole point is to give your users a bunch of unnecessary work then the approach doesn't really matter.  Either approach has its pros and cons.

Jim

winuser2003

  • Newbie
  • *
  • Posts: 34
Re: Date Calculation Project
« Reply #25 on: September 05, 2014, 07:58:04 am »
The new concept is really quite easy and is more convient. Reason is just select the date and the rest of the calculations are done right away. Right now I am working to add the calculations to the rest of the text fields. Sort of having trouble on this part, I am sure there is some minor detail I am missing somewhere.

Code: [Select]
gosub udfs
t1=TimeSubtract(TimeYmdHms(), "0000:00:01:00:00:00")

;number of daya to advance
next1=204
next2=90
next3=98
next4=5
next5=2
next6=4
next7=6
next8=3
next9=9
next10=12
next11=14

nadd1="0000:00:0%next1%:00:00:00"
nadd2="0000:00:0%next2%:00:00:00"
nadd3="0000:00:0%next3%:00:00:00"
nadd3="0000:00:0%next4%:00:00:00"
nadd3="0000:00:0%next5%:00:00:00"
nadd3="0000:00:0%next6%:00:00:00"
nadd3="0000:00:0%next7%:00:00:00"
nadd3="0000:00:0%next8%:00:00:00"
nadd3="0000:00:0%next9%:00:00:00"
nadd3="0000:00:0%next10%:00:00:00"
nadd3="0000:00:0%next11%:00:00:00"

settime()


TCFormat=`WWWDLGED,6.2`

TCCaption=`Promo Codes Concept`
TCX=178
TCY=064
TCWidth=360
TCHeight=100
TCNumControls=026
TCProcedure=`dlgproc`
TCFont=`DEFAULT`
TCTextColor=`DEFAULT`
TCBackground=`DEFAULT,DEFAULT`
TCConfig=0

TC001=`003,013,088,078,CALENDAR,"C1",t1,DEFAULT,DEFAULT,10,DEFAULT,DEFAULT`
TC002=`301,071,046,012,VARYTEXT,"V1",t2,DEFAULT,DEFAULT,20,DEFAULT,DEFAULT,DEFAULT,"255|255|255"`
TC003=`101,071,054,012,VARYTEXT,"V2",t3,DEFAULT,DEFAULT,30,0,DEFAULT,DEFAULT,"255|255|255"`
TC004=`161,071,078,012,VARYTEXT,"V3",t4,DEFAULT,DEFAULT,40,DEFAULT,DEFAULT,DEFAULT,"255|255|255"`
TC005=`003,003,052,012,STATICTEXT,"StaticText_1",DEFAULT,"Actual Upload Date :",DEFAULT,50,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC006=`101,003,054,012,STATICTEXT,"StaticText_2",DEFAULT,"Target Upload Date :",DEFAULT,60,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC007=`161,003,078,012,STATICTEXT,"StaticText_3",DEFAULT,"Promo Code New Batch Date :",DEFAULT,70,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC008=`247,003,048,012,STATICTEXT,"StaticText_4",DEFAULT,"Start Date :",DEFAULT,80,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC009=`301,003,044,012,STATICTEXT,"StaticText_5",DEFAULT,"Expiration Date :",DEFAULT,90,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC010=`247,071,048,012,VARYTEXT,"V4",t2,DEFAULT,DEFAULT,20,DEFAULT,DEFAULT,DEFAULT,"255|255|255"`
TC011=`101,031,054,012,STATICTEXT,"StaticText_6",DEFAULT,"Target Upload Date :",DEFAULT,60,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC012=`101,059,054,012,STATICTEXT,"StaticText_7",DEFAULT,"Target Upload Date :",DEFAULT,60,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC013=`161,031,078,012,STATICTEXT,"StaticText_8",DEFAULT,"Promo Code New Batch Date :",DEFAULT,70,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC014=`161,059,078,012,STATICTEXT,"StaticText_9",DEFAULT,"Promo Code New Batch Date :",DEFAULT,70,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC015=`247,031,048,012,STATICTEXT,"StaticText_10",DEFAULT,"Start Date :",DEFAULT,80,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC016=`247,059,048,012,STATICTEXT,"StaticText_11",DEFAULT,"Start Date :",DEFAULT,80,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC017=`301,031,044,012,STATICTEXT,"StaticText_12",DEFAULT,"Expiration Date :",DEFAULT,90,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC018=`301,059,044,012,STATICTEXT,"StaticText_13",DEFAULT,"Expiration Date :",DEFAULT,90,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC019=`101,043,054,012,VARYTEXT,"V6",t6,DEFAULT,DEFAULT,190,DEFAULT,DEFAULT,DEFAULT,"255|255|255"`
TC020=`161,043,078,012,VARYTEXT,"V7",t7,DEFAULT,DEFAULT,200,DEFAULT,DEFAULT,DEFAULT,"255|255|255"`
TC021=`247,043,048,012,VARYTEXT,"V8",t8,DEFAULT,DEFAULT,210,DEFAULT,DEFAULT,DEFAULT,"255|255|255"`
TC022=`301,043,046,012,VARYTEXT,"V9",t8,DEFAULT,DEFAULT,220,DEFAULT,DEFAULT,DEFAULT,"255|255|255"`
TC023=`101,015,054,012,VARYTEXT,"V10",t10,DEFAULT,DEFAULT,230,DEFAULT,DEFAULT,DEFAULT,"255|255|255"`
TC024=`161,015,080,012,VARYTEXT,"V11",t11,DEFAULT,DEFAULT,240,DEFAULT,DEFAULT,DEFAULT,"255|255|255"`
TC025=`247,015,048,012,VARYTEXT,"V12",t12,DEFAULT,DEFAULT,250,DEFAULT,DEFAULT,DEFAULT,"255|255|255"`
TC026=`301,015,046,012,VARYTEXT,"V13",t12,DEFAULT,DEFAULT,260,DEFAULT,DEFAULT,DEFAULT,"255|255|255"`

ButtonPushed=Dialog("TC")


Exit



:udfs
;============================================================
;============================================================
;============================================================
#DefineSubRoutine InitDialogConstants()
   ;DialogprocOptions Constants
   MSG_INIT=0                ; The one-time initialization
   MSG_TIMER=1               ; Timer event
   MSG_BUTTONPUSHED=2        ; Pushbutton or Picturebutton
   MSG_RADIOPUSHED=3         ; Radiobutton clicked
   MSG_CHECKBOX=4            ; Checkbox clicked
   MSG_EDITBOX=5             ; Editbox or Multilinebox
   MSG_FILESELECT=6          ; Filelistbox
   MSG_ITEMSELECT=7          ; Itembox
   MSG_COMBOCHANGE=8         ; Combobox/Droplistbox
   MSG_CALENDAR=9            ; Calendar date change
   MSG_SPINNER=10            ; Spinner number change
   MSG_CLOSEVIA49=11         ; Close clicked (Enabled via DialogProcOptions 1002
   MSG_FILEBOXDOUBLECLICK=12 ; Get double-click message on a FileListBox
   MSG_ITEMBOXDOUBLECLICK=13 ; Get double-click message on an ItemBox
   MSG_COMEVENT=14           ; COMCONTROL Event notification from DialogObject (NOT DialogProcOptions)
   MSG_MENUITEM=15           ; MenuItem selected
   MSG_MENUITEMINIT=16       ; MenuItem initialized

   DPO_DISABLESTATE=1000     ; codes -1=GetSetting 0=EnableDialog 1=DisableDialog
   DPO_CHANGEBACKGROUND=1001 ; -1=Get Current otherise bitmap or color string
   DPO_CHANGESYSMENU=1002    ; -1=Get Current 0=none 1=close 2=close/min 3=close/max 4=close/min/max
   DPO_CHANGETITLE=1003      ; Set/Get Dialog Title - (-1 to get)
   DPO_GETNAME=1004          ;  Returns the name associated with a control's number.
   DPO_GETNUMBER=1005        ;  Returns the number associated with a control's name.

   ;DialogControlState Constants
   DCSTATE_SETFOCUS=1        ; Give Control Focus
   DCSTATE_QUERYSTYLE=2      ; Query control's style
   DCSTATE_ADDSTYLE=3        ; Add control style
   DCSTATE_REMOVESTYLE=4     ; Remove control style
   DCSTATE_GETFOCUS=5        ; Get control that has focus
   DCSTATE_MOVEMOUSEOVER=6   ; Move the mouse over the control

   DCSTYLE_DEFAULT=0         ; Set Default Style
   DCSTYLE_INVISIBLE=1       ; Set Control Invisible
   DCSTYLE_DISABLED=2        ; Set Control Disabled
   DCSTYLE_NOUSERDATA=4      ; Note: Setable via DialogControlState function ONLY SPINNER control only
   DCSTYLE_READONLY=8        ; Sets control to read-only (user cannot type in data) EDITBOX MULTILINEBOX SPINNER
   DCSTYLE_PASSWORD=16       ; Sets 'password mode' where only *'s are displayed EDITBOX
   DCSTYLE_DEFAULTBUTTON=32  ; Sets a button as the default button PUSHBUTTON PICTUREBUTTON
   DCSTYLE_DIGITSONLY=64     ; Set edit box to accept digits only EDITMOX MULTILINEBOX
   DCSTYLE_FLAT=128          ; Makes a 'flat' hyperlink-looking button PUSHBUTTON PICTUREBUTTON
   DCSTYLE_NOADJUST=256      ; Turns off auto-height adjustment  ITEMBOX FILELISTBOX
   DCSTYLE_TEXTCENTER=512    ; Center text in control VARYTEXT STATICTEXT
   DCSTYLE_TEXTRIGHT=1024    ; Flush-Right text in control VARYTEXT STATICTEXT
   DCSTYLE_NOSELCURLEFT=2048 ; No selection, cursor left EDITBOX MULTILINEBOX
   DCSTYLE_NOSELCURRIGHT=4096; No selection, cursor right EDITBOX MULTILINEBOX
   DCSTYLE_SHIELD=8192       ; Display Security Shield icon on button (Vista only) PUSHBUTTON PICTUREBUTTON
   DCSTYLE_MENUCHECK=32768   ; Adds a check mark to the left of a menu item MENUITEM
   DCSTYLE_MENURADIO=65536   ; Adds a radio button like dot graphic to the left of a menu item MENUITEM
   DCSTYLE_MENUSEP=131072    ; Separator bar graphic MENUITEM
   DCSTYLE_MENUBREAK=262144  ; column break MENUBAR

   ;DialogControlSet / DialogControlGet Constants
   DC_CHECKBOX=1             ; CHECKBOX
   DC_RADIOBUTTON=2          ; RADIOBUTTON
   DC_EDITBOX=3              ; EDITBOX MULTILINEBOX
   DC_TITLE=4                ; PICTURE RADIOBUTTON CHECKBOX PICTUREBUTTON VARYTEXT STATICTEXT GROUPBOX PUSHBUTTON MENUITEM
   DC_ITEMBOXCONTENTS=5      ; ITEMBOX FILELISTBOX DROPLISTBOX
   DC_ITEMBOXSELECT=6        ; ITEMBOX FILELISTBOX DROPLISTBOX
   DC_CALENDAR=7             ; CALENDAR
   DC_SPINNER=8              ; SPINNER
   DC_MULTITABSTOPS=9        ; MULTILINEBOX
   DC_ITEMSCROLLPOS=10       ; ITEMBOX FILELISTBOX
   DC_BACKGROUNDCOLOR=11     ; RADIOBUTTON CHECKBOX VARYTEXT STATICTEXT GROUPBOX PUSHBUTTON ITEMBOX FILELISTBOX DROPLISTBOX SPINNER EDITBOX MULTILINEBOX
   DC_PICTUREBITMAP=12       ; PICTURE PICTUREBUTTON
   DC_TEXTCOLOR=13           ; RADIOBUTTON CHECKBOX VARYTEXT STATICTEXT GROUPBOX PUSHBUTTON ITEMBOX FIELLISTBOX DROPLISTBOX SPINNER EDITBOX MULTILINEBOX
   DC_ITEMBOXADD=14          ; ITEMBOX FILELISTBOX DROPLISTBOX
   DC_ITEMBOXREMOVE=15       ; ITEMBOX FILELISTBOX DROPLISTBOX
   DC_RADIOVALUE=16          ; RADIOBUTTON
   DC_POSITION=17            ; ALL CONTROLS (Except MENUBAR and MENUITEM)
   DC_MENUNAMES=18           ; ALL CONTROLS
   DC_HANDLE=19              ; ALL CONTROLS (Except MENUBAR and MENUITEM)


   ;DialogObject constants
   DLGOBJECT_ADDEVENT=1      ; Call dialog callback when the specified event occurs
   DLGOBJECT_STOPEVENT=2     ; Stop calling dialog callback when an event previously requested with
   DLGOBJECT_GETOBJECT=3     ; Return an object references to the specified control
   DLGOBJECT_GETPICTURE=4    ; Create and return an object reference to a picture object

   ;Return code constants
   RET_DO_CANCEL=0           ; Cancels dialog
   RET_DO_DEFAULT= -1        ; Continue with default processing for control
   RET_DO_NOT_EXIT= -2       ; Do not exit the dialog
   Return
#EndSubRoutine
;============================================================
;============================================================
;============================================================


#DefineSubRoutine dlgproc(MyDialog_Handle,MyDialog_Message,MyDialog_Name,MyDialog_EventInfo,rsvd)
   InitDialogConstants()                                   ; Initialize Dialog Constants
   ON_EQUAL = @TRUE                                         ; Initialize variable ON_EQUAL
   Switch MyDialog_Message                                  ; Switch based on Dialog Message type
     Case MSG_INIT                                         ; Standard Initialization message
        DialogProcOptions(MyDialog_Handle,  DPO_CHANGESYSMENU, 4)
  DialogProcOptions(MyDialog_Handle, MSG_CALENDAR , 1)
        Return(RET_DO_DEFAULT)
     Case MSG_CALENDAR
        t1 = DialogControlGet(MyDialog_Handle,"C1",7)     
        settime()
        DialogControlSet(MyDialog_Handle,"V1",4,t2)
        DialogControlSet(MyDialog_Handle,"V2",4,t3)
        DialogControlSet(MyDialog_Handle,"V3",4,t4)
  DialogControlSet(MyDialog_Handle,"V4",4,t5)
        DialogControlSet(MyDialog_Handle,"V6",4,t6)
  DialogControlSet(MyDialog_Handle,"V7",4,t7)
  DialogControlSet(MyDialog_Handle,"V8",4,t8)
  DialogControlSet(MyDialog_Handle,"V9",4,t9)
  DialogControlSet(MyDialog_Handle,"V10",4,t10)
  DialogControlSet(MyDialog_Handle,"V11",4,t11)
 
  Return(RET_DO_DEFAULT)
     Case MSG_CLOSEVIA49
        Exit
     Case ON_EQUAL
        Return(RET_DO_DEFAULT)

   EndSwitch 
   Return(RET_DO_DEFAULT)
#EndSubRoutine                                               ; End of Dialog Callback MyDialogCallbackProc

#DefineFunction cvtDate(d)
Return ( ItemExtract(2,d,":"):"/":ItemExtract(3,d,":"):"/":ItemExtract(1,d,":") )
#EndFunction

#DefineSubRoutine settime()
t2=cvtdate(TimeAdd(t1,nadd1))
t3=cvtdate(TimeAdd(t1,nadd2))
t4=cvtdate(TimeAdd(t1,nadd3))
Return(1)
#EndSubRoutine



Return

If the only date choices allowed are those in your list then you may want to consider a drop-down list but if the whole point is to give your users a bunch of unnecessary work then the approach doesn't really matter.  Either approach has its pros and cons.

Jim

winuser2003

  • Newbie
  • *
  • Posts: 34
Re: Date Calculation Project
« Reply #26 on: September 05, 2014, 08:21:39 am »
I think I am getting closer, however I am unsure where in the code whats effecting the t5=cvtdate issue. Below is the code...

Code: [Select]
gosub udfs
t1=TimeSubtract(TimeYmdHms(), "0000:00:01:00:00:00")

;number of daya to advance
next1=204
next2=90
next3=98
next4=5
next5=2
next6=4
next7=6
next8=3
next9=9
next10=12
next11=14
next12=22

nadd1="0000:00:0%next1%:00:00:00"
nadd2="0000:00:0%next2%:00:00:00"
nadd3="0000:00:0%next3%:00:00:00"
nadd4="0000:00:0%next4%:00:00:00"
nadd5="0000:00:0%next5%:00:00:00"
nadd6="0000:00:0%next6%:00:00:00"
nadd7="0000:00:0%next7%:00:00:00"
nadd8="0000:00:0%next8%:00:00:00"
nadd9="0000:00:0%next9%:00:00:00"
nadd10="0000:00:0%next10%:00:00:00"
nadd11="0000:00:0%next11%:00:00:00"
nadd12="0000:00:0%next12%:00:00:00"

settime()


TCFormat=`WWWDLGED,6.2`

TCCaption=`Promo Codes Concept`
TCX=178
TCY=064
TCWidth=360
TCHeight=100
TCNumControls=026
TCProcedure=`dlgproc`
TCFont=`DEFAULT`
TCTextColor=`DEFAULT`
TCBackground=`DEFAULT,DEFAULT`
TCConfig=0

TC001=`003,013,088,078,CALENDAR,"C1",t1,DEFAULT,DEFAULT,10,DEFAULT,DEFAULT`
TC002=`301,071,046,012,VARYTEXT,"V1",t2,DEFAULT,DEFAULT,20,DEFAULT,DEFAULT,DEFAULT,"255|255|255"`
TC003=`101,071,054,012,VARYTEXT,"V2",t3,DEFAULT,DEFAULT,30,0,DEFAULT,DEFAULT,"255|255|255"`
TC004=`161,071,078,012,VARYTEXT,"V3",t4,DEFAULT,DEFAULT,40,DEFAULT,DEFAULT,DEFAULT,"255|255|255"`
TC005=`003,003,052,012,STATICTEXT,"StaticText_1",DEFAULT,"Actual Upload Date :",DEFAULT,50,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC006=`101,003,054,012,STATICTEXT,"StaticText_2",DEFAULT,"Target Upload Date :",DEFAULT,60,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC007=`161,003,078,012,STATICTEXT,"StaticText_3",DEFAULT,"Promo Code New Batch Date :",DEFAULT,70,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC008=`247,003,048,012,STATICTEXT,"StaticText_4",DEFAULT,"Start Date :",DEFAULT,80,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC009=`301,003,044,012,STATICTEXT,"StaticText_5",DEFAULT,"Expiration Date :",DEFAULT,90,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC010=`247,071,048,012,VARYTEXT,"V4",t2,DEFAULT,DEFAULT,20,DEFAULT,DEFAULT,DEFAULT,"255|255|255"`
TC011=`101,031,054,012,STATICTEXT,"StaticText_6",DEFAULT,"Target Upload Date :",DEFAULT,60,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC012=`101,059,054,012,STATICTEXT,"StaticText_7",DEFAULT,"Target Upload Date :",DEFAULT,60,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC013=`161,031,078,012,STATICTEXT,"StaticText_8",DEFAULT,"Promo Code New Batch Date :",DEFAULT,70,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC014=`161,059,078,012,STATICTEXT,"StaticText_9",DEFAULT,"Promo Code New Batch Date :",DEFAULT,70,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC015=`247,031,048,012,STATICTEXT,"StaticText_10",DEFAULT,"Start Date :",DEFAULT,80,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC016=`247,059,048,012,STATICTEXT,"StaticText_11",DEFAULT,"Start Date :",DEFAULT,80,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC017=`301,031,044,012,STATICTEXT,"StaticText_12",DEFAULT,"Expiration Date :",DEFAULT,90,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC018=`301,059,044,012,STATICTEXT,"StaticText_13",DEFAULT,"Expiration Date :",DEFAULT,90,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC019=`101,043,054,012,VARYTEXT,"V6",t6,DEFAULT,DEFAULT,190,DEFAULT,DEFAULT,DEFAULT,"255|255|255"`
TC020=`161,043,078,012,VARYTEXT,"V7",t7,DEFAULT,DEFAULT,200,DEFAULT,DEFAULT,DEFAULT,"255|255|255"`
TC021=`247,043,048,012,VARYTEXT,"V8",t8,DEFAULT,DEFAULT,210,DEFAULT,DEFAULT,DEFAULT,"255|255|255"`
TC022=`301,043,046,012,VARYTEXT,"V9",t8,DEFAULT,DEFAULT,220,DEFAULT,DEFAULT,DEFAULT,"255|255|255"`
TC023=`101,015,054,012,VARYTEXT,"V10",t10,DEFAULT,DEFAULT,230,DEFAULT,DEFAULT,DEFAULT,"255|255|255"`
TC024=`161,015,080,012,VARYTEXT,"V11",t11,DEFAULT,DEFAULT,240,DEFAULT,DEFAULT,DEFAULT,"255|255|255"`
TC025=`247,015,048,012,VARYTEXT,"V12",t12,DEFAULT,DEFAULT,250,DEFAULT,DEFAULT,DEFAULT,"255|255|255"`
TC026=`301,015,046,012,VARYTEXT,"V13",t12,DEFAULT,DEFAULT,260,DEFAULT,DEFAULT,DEFAULT,"255|255|255"`

ButtonPushed=Dialog("TC")




Exit



:udfs
;============================================================
;============================================================
;============================================================
#DefineSubRoutine InitDialogConstants()
   ;DialogprocOptions Constants
   MSG_INIT=0                ; The one-time initialization
   MSG_TIMER=1               ; Timer event
   MSG_BUTTONPUSHED=2        ; Pushbutton or Picturebutton
   MSG_RADIOPUSHED=3         ; Radiobutton clicked
   MSG_CHECKBOX=4            ; Checkbox clicked
   MSG_EDITBOX=5             ; Editbox or Multilinebox
   MSG_FILESELECT=6          ; Filelistbox
   MSG_ITEMSELECT=7          ; Itembox
   MSG_COMBOCHANGE=8         ; Combobox/Droplistbox
   MSG_CALENDAR=9            ; Calendar date change
   MSG_SPINNER=10            ; Spinner number change
   MSG_CLOSEVIA49=11         ; Close clicked (Enabled via DialogProcOptions 1002
   MSG_FILEBOXDOUBLECLICK=12 ; Get double-click message on a FileListBox
   MSG_ITEMBOXDOUBLECLICK=13 ; Get double-click message on an ItemBox
   MSG_COMEVENT=14           ; COMCONTROL Event notification from DialogObject (NOT DialogProcOptions)
   MSG_MENUITEM=15           ; MenuItem selected
   MSG_MENUITEMINIT=16       ; MenuItem initialized

   DPO_DISABLESTATE=1000     ; codes -1=GetSetting 0=EnableDialog 1=DisableDialog
   DPO_CHANGEBACKGROUND=1001 ; -1=Get Current otherise bitmap or color string
   DPO_CHANGESYSMENU=1002    ; -1=Get Current 0=none 1=close 2=close/min 3=close/max 4=close/min/max
   DPO_CHANGETITLE=1003      ; Set/Get Dialog Title - (-1 to get)
   DPO_GETNAME=1004          ;  Returns the name associated with a control's number.
   DPO_GETNUMBER=1005        ;  Returns the number associated with a control's name.

   ;DialogControlState Constants
   DCSTATE_SETFOCUS=1        ; Give Control Focus
   DCSTATE_QUERYSTYLE=2      ; Query control's style
   DCSTATE_ADDSTYLE=3        ; Add control style
   DCSTATE_REMOVESTYLE=4     ; Remove control style
   DCSTATE_GETFOCUS=5        ; Get control that has focus
   DCSTATE_MOVEMOUSEOVER=6   ; Move the mouse over the control

   DCSTYLE_DEFAULT=0         ; Set Default Style
   DCSTYLE_INVISIBLE=1       ; Set Control Invisible
   DCSTYLE_DISABLED=2        ; Set Control Disabled
   DCSTYLE_NOUSERDATA=4      ; Note: Setable via DialogControlState function ONLY SPINNER control only
   DCSTYLE_READONLY=8        ; Sets control to read-only (user cannot type in data) EDITBOX MULTILINEBOX SPINNER
   DCSTYLE_PASSWORD=16       ; Sets 'password mode' where only *'s are displayed EDITBOX
   DCSTYLE_DEFAULTBUTTON=32  ; Sets a button as the default button PUSHBUTTON PICTUREBUTTON
   DCSTYLE_DIGITSONLY=64     ; Set edit box to accept digits only EDITMOX MULTILINEBOX
   DCSTYLE_FLAT=128          ; Makes a 'flat' hyperlink-looking button PUSHBUTTON PICTUREBUTTON
   DCSTYLE_NOADJUST=256      ; Turns off auto-height adjustment  ITEMBOX FILELISTBOX
   DCSTYLE_TEXTCENTER=512    ; Center text in control VARYTEXT STATICTEXT
   DCSTYLE_TEXTRIGHT=1024    ; Flush-Right text in control VARYTEXT STATICTEXT
   DCSTYLE_NOSELCURLEFT=2048 ; No selection, cursor left EDITBOX MULTILINEBOX
   DCSTYLE_NOSELCURRIGHT=4096; No selection, cursor right EDITBOX MULTILINEBOX
   DCSTYLE_SHIELD=8192       ; Display Security Shield icon on button (Vista only) PUSHBUTTON PICTUREBUTTON
   DCSTYLE_MENUCHECK=32768   ; Adds a check mark to the left of a menu item MENUITEM
   DCSTYLE_MENURADIO=65536   ; Adds a radio button like dot graphic to the left of a menu item MENUITEM
   DCSTYLE_MENUSEP=131072    ; Separator bar graphic MENUITEM
   DCSTYLE_MENUBREAK=262144  ; column break MENUBAR

   ;DialogControlSet / DialogControlGet Constants
   DC_CHECKBOX=1             ; CHECKBOX
   DC_RADIOBUTTON=2          ; RADIOBUTTON
   DC_EDITBOX=3              ; EDITBOX MULTILINEBOX
   DC_TITLE=4                ; PICTURE RADIOBUTTON CHECKBOX PICTUREBUTTON VARYTEXT STATICTEXT GROUPBOX PUSHBUTTON MENUITEM
   DC_ITEMBOXCONTENTS=5      ; ITEMBOX FILELISTBOX DROPLISTBOX
   DC_ITEMBOXSELECT=6        ; ITEMBOX FILELISTBOX DROPLISTBOX
   DC_CALENDAR=7             ; CALENDAR
   DC_SPINNER=8              ; SPINNER
   DC_MULTITABSTOPS=9        ; MULTILINEBOX
   DC_ITEMSCROLLPOS=10       ; ITEMBOX FILELISTBOX
   DC_BACKGROUNDCOLOR=11     ; RADIOBUTTON CHECKBOX VARYTEXT STATICTEXT GROUPBOX PUSHBUTTON ITEMBOX FILELISTBOX DROPLISTBOX SPINNER EDITBOX MULTILINEBOX
   DC_PICTUREBITMAP=12       ; PICTURE PICTUREBUTTON
   DC_TEXTCOLOR=13           ; RADIOBUTTON CHECKBOX VARYTEXT STATICTEXT GROUPBOX PUSHBUTTON ITEMBOX FIELLISTBOX DROPLISTBOX SPINNER EDITBOX MULTILINEBOX
   DC_ITEMBOXADD=14          ; ITEMBOX FILELISTBOX DROPLISTBOX
   DC_ITEMBOXREMOVE=15       ; ITEMBOX FILELISTBOX DROPLISTBOX
   DC_RADIOVALUE=16          ; RADIOBUTTON
   DC_POSITION=17            ; ALL CONTROLS (Except MENUBAR and MENUITEM)
   DC_MENUNAMES=18           ; ALL CONTROLS
   DC_HANDLE=19              ; ALL CONTROLS (Except MENUBAR and MENUITEM)


   ;DialogObject constants
   DLGOBJECT_ADDEVENT=1      ; Call dialog callback when the specified event occurs
   DLGOBJECT_STOPEVENT=2     ; Stop calling dialog callback when an event previously requested with
   DLGOBJECT_GETOBJECT=3     ; Return an object references to the specified control
   DLGOBJECT_GETPICTURE=4    ; Create and return an object reference to a picture object

   ;Return code constants
   RET_DO_CANCEL=0           ; Cancels dialog
   RET_DO_DEFAULT= -1        ; Continue with default processing for control
   RET_DO_NOT_EXIT= -2       ; Do not exit the dialog
   Return
#EndSubRoutine
;============================================================
;============================================================
;============================================================


#DefineSubRoutine dlgproc(MyDialog_Handle,MyDialog_Message,MyDialog_Name,MyDialog_EventInfo,rsvd)
   InitDialogConstants()                                   ; Initialize Dialog Constants
   ON_EQUAL = @TRUE                                         ; Initialize variable ON_EQUAL
   Switch MyDialog_Message                                  ; Switch based on Dialog Message type
     Case MSG_INIT                                         ; Standard Initialization message
        DialogProcOptions(MyDialog_Handle,  DPO_CHANGESYSMENU, 4)
  DialogProcOptions(MyDialog_Handle, MSG_CALENDAR , 1)
        Return(RET_DO_DEFAULT)
     Case MSG_CALENDAR
        t1 = DialogControlGet(MyDialog_Handle,"C1",7)     
        settime()
        DialogControlSet(MyDialog_Handle,"V1",4,t2)
        DialogControlSet(MyDialog_Handle,"V2",4,t3)
        DialogControlSet(MyDialog_Handle,"V3",4,t4)
  DialogControlSet(MyDialog_Handle,"V4",4,t5)
        DialogControlSet(MyDialog_Handle,"V6",4,t6)
  DialogControlSet(MyDialog_Handle,"V7",4,t7)
  DialogControlSet(MyDialog_Handle,"V8",4,t8)
  DialogControlSet(MyDialog_Handle,"V9",4,t9)
  DialogControlSet(MyDialog_Handle,"V10",4,t10)
  DialogControlSet(MyDialog_Handle,"V11",4,t11)
 
  Return(RET_DO_DEFAULT)
     Case MSG_CLOSEVIA49
        Exit
     Case ON_EQUAL
        Return(RET_DO_DEFAULT)

   EndSwitch 
   Return(RET_DO_DEFAULT)
#EndSubRoutine                                               ; End of Dialog Callback MyDialogCallbackProc

#DefineFunction cvtDate(d)
Return ( ItemExtract(2,d,":"):"/":ItemExtract(3,d,":"):"/":ItemExtract(1,d,":") )
#EndFunction

#DefineSubRoutine settime()
t2=cvtdate(TimeAdd(t1,nadd1))
t3=cvtdate(TimeAdd(t1,nadd2))
t4=cvtdate(TimeAdd(t1,nadd3))
t5=cvtdate(TimeAdd(tl,nadd4))
t6=cvtdate(TimeAdd(t1,nadd5))
t7=cvtdate(TimeAdd(t1,nadd6))
t8=cvtdate(TimeAdd(t1,nadd7))
t9=cvtdate(TimeAdd(t1,nadd8))
t10=cvtdate(TimeAdd(t1,nadd9))
t11=cvtdate(TimeAdd(t1,nadd10))
t12=cvtdate(TimeAdd(t1,nadd11))
t13=cvtdate(TimeAdd(t1,nadd12))

Return(1)
#EndSubRoutine



Return

stanl

  • Pundit
  • *****
  • Posts: 1190
Re: Date Calculation Project
« Reply #27 on: September 05, 2014, 12:09:39 pm »
I posted the calendar code as a quick example to illustrate WB's date calculations. I feel the snippets you are re-posting are getting messier and it might be time to take a breath and help us understand your goal.  Simply put....
 
(1) it appears the number of promo code 'projects' might be variable, or is it fixed at 3 per script execution?
(2) then it appears each project will have variable start/expiration dates. [hopefully these would be semi-fixed offsets from the upload date]
 
If this bears some truth, the outcome depends of selecting a single date for each 'project'. To me, this seems a simple database or excel application where after a date is selected either fields or cells are filled in.
 
In which case, my dialog would consist of:
 
A dropdown - listing all project types, each with a matching offset arrray of start/expire days
A calendar - to set the upload date for the selected project
2-buttons - 1 to proceed with the calculations, 1 to cancel the dialog.
 
for sanity sake and some error-checking I would remove the project from the dropdown once it was selected and procesed, unless the same project could have multiple start dates.
 
or not.....
 
 
 
 

JTaylor

  • Pundit
  • *****
  • Posts: 1363
    • Data & Stuff Inc.
Re: Date Calculation Project
« Reply #28 on: September 05, 2014, 04:25:31 pm »
t5=cvtdate(TimeAdd(tl,nadd4))

should be

t5=cvtdate(TimeAdd(t1,nadd4))

You have t-el instead of t-one.

Jim

steverr

  • Newbie
  • *
  • Posts: 1
Re: Date Calculation Project
« Reply #29 on: September 05, 2014, 06:34:42 pm »
Just from a layout perspective, in my opinion, I would make all the Date fields the same size, which might allow you to move the Filename field up on the same line that it pertains to.  Or rather than a left-to-right flow for the 1, 2, 3...you could make the box more square and use a column approach with the Calculate buttons either across the top or across the bottom.

I know this wasn't really an answer to your question(s), but thought I would offer my opinion in the way the 'form' looks.

Steve

winuser2003

  • Newbie
  • *
  • Posts: 34
Re: Date Calculation Project
« Reply #30 on: September 05, 2014, 08:36:13 pm »
I posted the calendar code as a quick example to illustrate WB's date calculations. I feel the snippets you are re-posting are getting messier and it might be time to take a breath and help us understand your goal.  Simply put....

Answer: Per my earlier post, I provided a URL to a Word Doc that presents the goal in which I am going in with this project. Please let me know if you have troubles viewing this word document or should you have questions after reviewing the word document please let me know. I apologize if that post may have been overlooked.

 
(1) it appears the number of promo code 'projects' might be variable, or is it fixed at 3 per script execution?

Answer : Fixed at 3 per script execution. Again reviewing the word document should answer this and again please let me know if the doc is not completely clear.

(2) then it appears each project will have variable start/expiration dates. [hopefully these would be semi-fixed offsets from the upload date]

Answer : Correct
 
If this bears some truth, the outcome depends of selecting a single date for each 'project'. To me, this seems a simple database or excel application where after a date is selected either fields or cells are filled in.

Answer : The data is originated from an XL document yes, however with the amount of data and functional formula's within the XL doc it becomes difficult to use the XL doc for calculating the necessary information needed. Hence, if you review the word doc I provided in earlier post you can simply see the set of data is from an XL document, but again using that has become unreliable and I feel winbatch with how it can handle this data would be a better option than using XL.
 
In which case, my dialog would consist of:
 
A dropdown - listing all project types, each with a matching offset arrray of start/expire days
A calendar - to set the upload date for the selected project
2-buttons - 1 to proceed with the calculations, 1 to cancel the dialog.

Answer : Could you provide a concept of this? Any suggestion or idea is welcome if it can make the user experience much easier.
 
for sanity sake and some error-checking I would remove the project from the dropdown once it was selected and procesed, unless the same project could have multiple start dates.

Answer : Well, the start date is just the date in which your deciding to run this application and obtain the information needed. Everytime this is ran 1 start date can be applied and the calculation can be provided from there, which is what the current concept is actually doing.
 
or not.....

winuser2003

  • Newbie
  • *
  • Posts: 34
Re: Date Calculation Project
« Reply #31 on: September 05, 2014, 08:38:07 pm »
Just from a layout perspective, in my opinion, I would make all the Date fields the same size, which might allow you to move the Filename field up on the same line that it pertains to.  Or rather than a left-to-right flow for the 1, 2, 3...you could make the box more square and use a column approach with the Calculate buttons either across the top or across the bottom.

Answer : Can you use the current code provided to present your concept? Again, I welcome any suggestion that would make the user experience much better so seeing these concepts can help better decide which would be best to go for.

I know this wasn't really an answer to your question(s), but thought I would offer my opinion in the way the 'form' looks.

Steve

stanl

  • Pundit
  • *****
  • Posts: 1190
Re: Date Calculation Project
« Reply #32 on: September 06, 2014, 07:43:40 am »
This is beginning to sound and look more like a mid-term than an actual application, and as they say on Shark Tank - "I'm Out!"

winuser2003

  • Newbie
  • *
  • Posts: 34
Re: Date Calculation Project
« Reply #33 on: September 08, 2014, 04:18:26 am »
Your right, I applied the fix and now its working perfect ! I can probably finish up the application from here since now everything looks defined and the core calculations are done! 

"I think some people make a bigger deal out of small things more than they should."

Thank you for your help!

t5=cvtdate(TimeAdd(tl,nadd4))

should be

t5=cvtdate(TimeAdd(t1,nadd4))

You have t-el instead of t-one.

Jim

winuser2003

  • Newbie
  • *
  • Posts: 34
Re: Date Calculation Project
« Reply #34 on: September 08, 2014, 05:16:24 am »
Question : I have 2 variables that are still undefined? been trying to find where I made my mistake. I made a reference toward the top of the code that tells me what is defined and what is not. Looks like next8 and next12 are the only two I cannot define for some reason.

Code: [Select]
gosub udfs
t1=TimeSubtract(TimeYmdHms(), "0000:00:01:00:00:00")

;number of daya to advance
;Reference
;V1 = next1=400
;V4 = next1=400
;V2 = next2=400
;V3 = next3=400
;V3 = next4=400
;V6 = next5=400
;V8 = next6=400
;V9 = next7=400
;Vx = next8= Undefined
;V10 = next9=400
;V11 = next10=400
;V12 = next10=400
;V13 = next11=400
;Vx =  next12= Undefined
;V1

next1=0
next2=0
next3=0
next4=0
next5=0
next6=0
next7=0
next8=400
next9=0
next10=0
next11=0
next12=0

nadd1="0000:00:0%next1%:00:00:00"
nadd2="0000:00:0%next2%:00:00:00"
nadd3="0000:00:0%next3%:00:00:00"
nadd4="0000:00:0%next4%:00:00:00"
nadd5="0000:00:0%next5%:00:00:00"
nadd6="0000:00:0%next6%:00:00:00"
nadd7="0000:00:0%next7%:00:00:00"
nadd8="0000:00:0%next8%:00:00:00"
nadd9="0000:00:0%next9%:00:00:00"
nadd10="0000:00:0%next10%:00:00:00"
nadd11="0000:00:0%next11%:00:00:00"
nadd12="0000:00:0%next12%:00:00:00"

settime()


TCFormat=`WWWDLGED,6.2`

TCCaption=`Promo Codes Concept`
TCX=178
TCY=064
TCWidth=360
TCHeight=108
TCNumControls=026
TCProcedure=`dlgproc`
TCFont=`DEFAULT`
TCTextColor=`DEFAULT`
TCBackground=`DEFAULT,DEFAULT`
TCConfig=0

TC001=`003,013,088,078,CALENDAR,"C1",t1,DEFAULT,DEFAULT,10,DEFAULT,DEFAULT`
TC002=`247,071,048,012,VARYTEXT,"V1",t2,DEFAULT,DEFAULT,20,DEFAULT,DEFAULT,DEFAULT,"255|255|255"`
TC003=`101,071,054,012,VARYTEXT,"V2",t3,DEFAULT,DEFAULT,30,0,DEFAULT,DEFAULT,"255|255|255"`
TC004=`301,071,046,012,VARYTEXT,"V3",t4,DEFAULT,DEFAULT,40,DEFAULT,DEFAULT,DEFAULT,"255|255|255"`
TC005=`003,003,052,012,STATICTEXT,"StaticText_1",DEFAULT,"Actual Upload Date :",DEFAULT,50,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC006=`101,003,054,012,STATICTEXT,"StaticText_2",DEFAULT,"Target Upload Date :",DEFAULT,60,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC007=`161,003,078,012,STATICTEXT,"StaticText_3",DEFAULT,"Promo Code New Batch Date :",DEFAULT,70,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC008=`247,003,048,012,STATICTEXT,"StaticText_4",DEFAULT,"Start Date :",DEFAULT,80,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC009=`301,003,044,012,STATICTEXT,"StaticText_5",DEFAULT,"Expiration Date :",DEFAULT,90,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC010=`161,071,078,012,VARYTEXT,"V4",t2,DEFAULT,DEFAULT,20,DEFAULT,DEFAULT,DEFAULT,"255|255|255"`
TC011=`101,031,054,012,STATICTEXT,"StaticText_6",DEFAULT,"Target Upload Date :",DEFAULT,60,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC012=`101,059,054,012,STATICTEXT,"StaticText_7",DEFAULT,"Target Upload Date :",DEFAULT,60,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC013=`161,031,078,012,STATICTEXT,"StaticText_8",DEFAULT,"Promo Code New Batch Date :",DEFAULT,70,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC014=`161,059,078,012,STATICTEXT,"StaticText_9",DEFAULT,"Promo Code New Batch Date :",DEFAULT,70,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC015=`247,031,048,012,STATICTEXT,"StaticText_10",DEFAULT,"Start Date :",DEFAULT,80,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC016=`247,059,048,012,STATICTEXT,"StaticText_11",DEFAULT,"Start Date :",DEFAULT,80,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC017=`301,031,044,012,STATICTEXT,"StaticText_12",DEFAULT,"Expiration Date :",DEFAULT,90,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC018=`301,059,044,012,STATICTEXT,"StaticText_13",DEFAULT,"Expiration Date :",DEFAULT,90,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
TC019=`101,043,054,012,VARYTEXT,"V6",t6,DEFAULT,DEFAULT,190,DEFAULT,DEFAULT,DEFAULT,"255|255|255"`
TC020=`161,043,078,012,VARYTEXT,"V7",t7,DEFAULT,DEFAULT,200,DEFAULT,DEFAULT,DEFAULT,"255|255|255"`
TC021=`247,043,048,012,VARYTEXT,"V8",t7,DEFAULT,DEFAULT,210,DEFAULT,DEFAULT,DEFAULT,"255|255|255"`
TC022=`301,043,046,012,VARYTEXT,"V9",t8,DEFAULT,DEFAULT,220,DEFAULT,DEFAULT,DEFAULT,"255|255|255"`
TC023=`101,015,054,012,VARYTEXT,"V10",t10,DEFAULT,DEFAULT,230,DEFAULT,DEFAULT,DEFAULT,"255|255|255"`
TC024=`161,015,080,012,VARYTEXT,"V11",t11,DEFAULT,DEFAULT,240,DEFAULT,DEFAULT,DEFAULT,"255|255|255"`
TC025=`247,015,048,012,VARYTEXT,"V12",t11,DEFAULT,DEFAULT,250,DEFAULT,DEFAULT,DEFAULT,"255|255|255"`
TC026=`301,015,046,012,VARYTEXT,"V13",t12,DEFAULT,DEFAULT,260,DEFAULT,DEFAULT,DEFAULT,"255|255|255"`

ButtonPushed=Dialog("TC")

Exit



:udfs
;============================================================
;============================================================
;============================================================
#DefineSubRoutine InitDialogConstants()
   ;DialogprocOptions Constants
   MSG_INIT=0                ; The one-time initialization
   MSG_TIMER=1               ; Timer event
   MSG_BUTTONPUSHED=2        ; Pushbutton or Picturebutton
   MSG_RADIOPUSHED=3         ; Radiobutton clicked
   MSG_CHECKBOX=4            ; Checkbox clicked
   MSG_EDITBOX=5             ; Editbox or Multilinebox
   MSG_FILESELECT=6          ; Filelistbox
   MSG_ITEMSELECT=7          ; Itembox
   MSG_COMBOCHANGE=8         ; Combobox/Droplistbox
   MSG_CALENDAR=9            ; Calendar date change
   MSG_SPINNER=10            ; Spinner number change
   MSG_CLOSEVIA49=11         ; Close clicked (Enabled via DialogProcOptions 1002
   MSG_FILEBOXDOUBLECLICK=12 ; Get double-click message on a FileListBox
   MSG_ITEMBOXDOUBLECLICK=13 ; Get double-click message on an ItemBox
   MSG_COMEVENT=14           ; COMCONTROL Event notification from DialogObject (NOT DialogProcOptions)
   MSG_MENUITEM=15           ; MenuItem selected
   MSG_MENUITEMINIT=16       ; MenuItem initialized

   DPO_DISABLESTATE=1000     ; codes -1=GetSetting 0=EnableDialog 1=DisableDialog
   DPO_CHANGEBACKGROUND=1001 ; -1=Get Current otherise bitmap or color string
   DPO_CHANGESYSMENU=1002    ; -1=Get Current 0=none 1=close 2=close/min 3=close/max 4=close/min/max
   DPO_CHANGETITLE=1003      ; Set/Get Dialog Title - (-1 to get)
   DPO_GETNAME=1004          ;  Returns the name associated with a control's number.
   DPO_GETNUMBER=1005        ;  Returns the number associated with a control's name.

   ;DialogControlState Constants
   DCSTATE_SETFOCUS=1        ; Give Control Focus
   DCSTATE_QUERYSTYLE=2      ; Query control's style
   DCSTATE_ADDSTYLE=3        ; Add control style
   DCSTATE_REMOVESTYLE=4     ; Remove control style
   DCSTATE_GETFOCUS=5        ; Get control that has focus
   DCSTATE_MOVEMOUSEOVER=6   ; Move the mouse over the control

   DCSTYLE_DEFAULT=0         ; Set Default Style
   DCSTYLE_INVISIBLE=1       ; Set Control Invisible
   DCSTYLE_DISABLED=2        ; Set Control Disabled
   DCSTYLE_NOUSERDATA=4      ; Note: Setable via DialogControlState function ONLY SPINNER control only
   DCSTYLE_READONLY=8        ; Sets control to read-only (user cannot type in data) EDITBOX MULTILINEBOX SPINNER
   DCSTYLE_PASSWORD=16       ; Sets 'password mode' where only *'s are displayed EDITBOX
   DCSTYLE_DEFAULTBUTTON=32  ; Sets a button as the default button PUSHBUTTON PICTUREBUTTON
   DCSTYLE_DIGITSONLY=64     ; Set edit box to accept digits only EDITMOX MULTILINEBOX
   DCSTYLE_FLAT=128          ; Makes a 'flat' hyperlink-looking button PUSHBUTTON PICTUREBUTTON
   DCSTYLE_NOADJUST=256      ; Turns off auto-height adjustment  ITEMBOX FILELISTBOX
   DCSTYLE_TEXTCENTER=512    ; Center text in control VARYTEXT STATICTEXT
   DCSTYLE_TEXTRIGHT=1024    ; Flush-Right text in control VARYTEXT STATICTEXT
   DCSTYLE_NOSELCURLEFT=2048 ; No selection, cursor left EDITBOX MULTILINEBOX
   DCSTYLE_NOSELCURRIGHT=4096; No selection, cursor right EDITBOX MULTILINEBOX
   DCSTYLE_SHIELD=8192       ; Display Security Shield icon on button (Vista only) PUSHBUTTON PICTUREBUTTON
   DCSTYLE_MENUCHECK=32768   ; Adds a check mark to the left of a menu item MENUITEM
   DCSTYLE_MENURADIO=65536   ; Adds a radio button like dot graphic to the left of a menu item MENUITEM
   DCSTYLE_MENUSEP=131072    ; Separator bar graphic MENUITEM
   DCSTYLE_MENUBREAK=262144  ; column break MENUBAR

   ;DialogControlSet / DialogControlGet Constants
   DC_CHECKBOX=1             ; CHECKBOX
   DC_RADIOBUTTON=2          ; RADIOBUTTON
   DC_EDITBOX=3              ; EDITBOX MULTILINEBOX
   DC_TITLE=4                ; PICTURE RADIOBUTTON CHECKBOX PICTUREBUTTON VARYTEXT STATICTEXT GROUPBOX PUSHBUTTON MENUITEM
   DC_ITEMBOXCONTENTS=5      ; ITEMBOX FILELISTBOX DROPLISTBOX
   DC_ITEMBOXSELECT=6        ; ITEMBOX FILELISTBOX DROPLISTBOX
   DC_CALENDAR=7             ; CALENDAR
   DC_SPINNER=8              ; SPINNER
   DC_MULTITABSTOPS=9        ; MULTILINEBOX
   DC_ITEMSCROLLPOS=10       ; ITEMBOX FILELISTBOX
   DC_BACKGROUNDCOLOR=11     ; RADIOBUTTON CHECKBOX VARYTEXT STATICTEXT GROUPBOX PUSHBUTTON ITEMBOX FILELISTBOX DROPLISTBOX SPINNER EDITBOX MULTILINEBOX
   DC_PICTUREBITMAP=12       ; PICTURE PICTUREBUTTON
   DC_TEXTCOLOR=13           ; RADIOBUTTON CHECKBOX VARYTEXT STATICTEXT GROUPBOX PUSHBUTTON ITEMBOX FIELLISTBOX DROPLISTBOX SPINNER EDITBOX MULTILINEBOX
   DC_ITEMBOXADD=14          ; ITEMBOX FILELISTBOX DROPLISTBOX
   DC_ITEMBOXREMOVE=15       ; ITEMBOX FILELISTBOX DROPLISTBOX
   DC_RADIOVALUE=16          ; RADIOBUTTON
   DC_POSITION=17            ; ALL CONTROLS (Except MENUBAR and MENUITEM)
   DC_MENUNAMES=18           ; ALL CONTROLS
   DC_HANDLE=19              ; ALL CONTROLS (Except MENUBAR and MENUITEM)


   ;DialogObject constants
   DLGOBJECT_ADDEVENT=1      ; Call dialog callback when the specified event occurs
   DLGOBJECT_STOPEVENT=2     ; Stop calling dialog callback when an event previously requested with
   DLGOBJECT_GETOBJECT=3     ; Return an object references to the specified control
   DLGOBJECT_GETPICTURE=4    ; Create and return an object reference to a picture object

   ;Return code constants
   RET_DO_CANCEL=0           ; Cancels dialog
   RET_DO_DEFAULT= -1        ; Continue with default processing for control
   RET_DO_NOT_EXIT= -2       ; Do not exit the dialog
   Return
#EndSubRoutine
;============================================================
;============================================================
;============================================================


#DefineSubRoutine dlgproc(MyDialog_Handle,MyDialog_Message,MyDialog_Name,MyDialog_EventInfo,rsvd)
   InitDialogConstants()                                   ; Initialize Dialog Constants
   ON_EQUAL = @TRUE                                         ; Initialize variable ON_EQUAL
   Switch MyDialog_Message                                  ; Switch based on Dialog Message type
     Case MSG_INIT                                         ; Standard Initialization message
        DialogProcOptions(MyDialog_Handle,  DPO_CHANGESYSMENU, 4)
  DialogProcOptions(MyDialog_Handle, MSG_CALENDAR , 1)
        Return(RET_DO_DEFAULT)
     Case MSG_CALENDAR
        t1 = DialogControlGet(MyDialog_Handle,"C1",7)
     
        settime()
        DialogControlSet(MyDialog_Handle,"V1",4,t2)
        DialogControlSet(MyDialog_Handle,"V2",4,t3)
        DialogControlSet(MyDialog_Handle,"V3",4,t4)
  DialogControlSet(MyDialog_Handle,"V4",4,t5)
        DialogControlSet(MyDialog_Handle,"V6",4,t6)
  DialogControlSet(MyDialog_Handle,"V7",4,t7)
  DialogControlSet(MyDialog_Handle,"V8",4,t8)
  DialogControlSet(MyDialog_Handle,"V9",4,t9)
  DialogControlSet(MyDialog_Handle,"V10",4,t10)
  DialogControlSet(MyDialog_Handle,"V11",4,t11)
 
  Return(RET_DO_DEFAULT)
     Case MSG_CLOSEVIA49
        Exit
     Case ON_EQUAL
        Return(RET_DO_DEFAULT)

   EndSwitch 
   Return(RET_DO_DEFAULT)
#EndSubRoutine                                               ; End of Dialog Callback MyDialogCallbackProc

#DefineFunction cvtDate(d)
Return ( ItemExtract(2,d,":"):"/":ItemExtract(3,d,":"):"/":ItemExtract(1,d,":") )
#EndFunction

#DefineSubRoutine settime()
t2=cvtdate(TimeAdd(t1,nadd1))
t3=cvtdate(TimeAdd(t1,nadd2))
t4=cvtdate(TimeAdd(t1,nadd4))
t5=cvtdate(TimeAdd(t1,nadd4))
t6=cvtdate(TimeAdd(t1,nadd5))
t7=cvtdate(TimeAdd(t1,nadd6))
t8=cvtdate(TimeAdd(t1,nadd7))
t9=cvtdate(TimeAdd(t1,nadd8))
t10=cvtdate(TimeAdd(t1,nadd9))
t11=cvtdate(TimeAdd(t1,nadd10))
t12=cvtdate(TimeAdd(t1,nadd4))
t13=cvtdate(TimeAdd(t1,nadd4))

Return(1)
#EndSubRoutine



Return