Date Calculation Project

Started by winuser2003, September 02, 2014, 07:09:10 AM

Previous topic - Next topic

winuser2003

I think I am getting a little closer, I have posted a word document again to explain where my troubles are. I also posted the code snippet. Hopefully this is not too hard to resolve and point out my mistake.

http://www.northprojectz.com/files/TargetDate.doc (Word Document #2 Review)

gosub udfs
t1=TimeSubtract(TimeYmdHms(), "0000:00:01:00:00:00")

;number of daya to advance
;Reference
;V1 = next1=400 = Bottom 3
;V4 = next1=400 = Bottom 2
;V2 = next2=400 = Bottom 1
;V3 = next3=400 = Bottom 4

;V3 = next4=400

;V7 = next6=400 = Middle 2
;V6 = next5=400 = Middle 1
;V8 = next6=400 = Middle 3
;V9 = next7=400 = Middle 4

;Vx = next8= Undefined

;V10 = next9=400 = Top 1
;V11 = next10=400 = Top 2
;V12 = next10=400 = Top 3
;V13 = next11=400 = Top 4

;Vx =  next12= Undefined
;V1

next1=70
next2=63
next3=400
next4=0
next5=49
next6=56
next7=10
next8=0
next9=35
next10=15
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=110
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",t6,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=`301,015,044,012,VARYTEXT,"V11",t11,DEFAULT,DEFAULT,240,DEFAULT,DEFAULT,DEFAULT,"255|255|255"`
TC025=`161,015,078,012,VARYTEXT,"V12",t11,DEFAULT,DEFAULT,250,DEFAULT,DEFAULT,DEFAULT,"255|255|255"`
TC026=`247,015,048,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

winuser2003

Been working with this, unsure where I am going wrong here... trying though. Can you help?

Quote from: JTaylor 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

JTaylor

Trying to figure out what you are doing but you are making it difficult...


  • Your "reference" section at the top makes no sense as all the "next" variables = 400.
  • Your name & variable assignments are not meaningful.  At least match up your V's and T's.....but better yet, give them meaningful values.
  • You assign the same variable name to multiple controls in the dialog.  It will still work in a dynamic dialog but confusing.
  • Conceptually I'm still not sure what you are doing.  How does selecting one upload date populate three rows?  The way they are laid out makes one think they are three different promotions.  Does one upload date create three different promotions?


Hope this helps or at least if you address these issues you might be able to figure out where things are going wrong.   I think the main problem is you are just assigning things incorrectly because your naming convention is not meaningful so it is not obvious where you are going wrong.

Jim

winuser2003

I posted a video, hopefully this helps get a little better understanding and answers your questions.
https://www.youtube.com/watch?v=WXHcIG8N6JI&feature=youtu.be

Refactored Code:
gosub udfs
t1=TimeSubtract(TimeYmdHms(), "0000:00:01:00:00:00")

;Below is a reference so you have the V - variable, next - variable of the field, Botton, middle, and
;top is the location of that field. So lets say I want to change the counter of V1 and V4. So I look

;V1 = next1 Bottom 3
;V4 = next1 Bottom 2
;V2 = next2 Bottom 1
;V3 = next3 Bottom 4

;V7 = next6 Middle 2
;V6 = next5 Middle 1
;V8 = next6 Middle 3
;V9 = next7 Middle 4

;V10 = next9 Top 1
;V11 = next10 Top 2
;V12 = next10 Top 3
;V13 = next11 Top 4

next1=70
next2=63
next3=400
next4=0
next5=49
next6=56
next7=10
next8=0
next9=35
next10=15
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"
nadd13="0000:00:0%next12%:00:00:00"

settime()


TCFormat=`WWWDLGED,6.2`

TCCaption=`Promo Codes Concept`
TCX=178
TCY=064
TCWidth=360
TCHeight=110
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",t6,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=`301,015,044,012,VARYTEXT,"V11",t11,DEFAULT,DEFAULT,240,DEFAULT,DEFAULT,DEFAULT,"255|255|255"`
TC025=`161,015,078,012,VARYTEXT,"V12",t11,DEFAULT,DEFAULT,250,DEFAULT,DEFAULT,DEFAULT,"255|255|255"`
TC026=`247,015,048,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)
  DialogControlSet(MyDialog_Handle,"V12",4,t12)
  DialogControlSet(MyDialog_Handle,"V13",4,t13)
 
  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


Quote from: JTaylor on September 10, 2014, 05:47:49 AM
Trying to figure out what you are doing but you are making it difficult...


  • Your "reference" section at the top makes no sense as all the "next" variables = 400.
  • Your name & variable assignments are not meaningful.  At least match up your V's and T's.....but better yet, give them meaningful values.
  • You assign the same variable name to multiple controls in the dialog.  It will still work in a dynamic dialog but confusing.
  • Conceptually I'm still not sure what you are doing.  How does selecting one upload date populate three rows?  The way they are laid out makes one think they are three different promotions.  Does one upload date create three different promotions?


Hope this helps or at least if you address these issues you might be able to figure out where things are going wrong.   I think the main problem is you are just assigning things incorrectly because your naming convention is not meaningful so it is not obvious where you are going wrong.

Jim

winuser2003

Your "reference" section at the top makes no sense as all the "next" variables = 400.
Answer : Hope the video can better explain this.


Your name & variable assignments are not meaningful.  At least match up your V's and T's.....but better yet, give them meaningful values.
Answer : I was following the same naming convention you were in the beginning.



You assign the same variable name to multiple controls in the dialog.  It will still work in a dynamic dialog but confusing.
Answer : Correct, because there are two boxes that will have the same information, Review the work document I have attached in an earlier post from the other day.


Conceptually I'm still not sure what you are doing.  How does selecting one upload date populate three rows?
Answer : Because sence I added more dialog s I can tell how many days to assign to which dialog.

The way they are laid out makes one think they are three different promotions.  Does one upload date create three different promotions?
Answer : Correct, the actual upload date will always be the day of the upload. So I calculated the rest from using the actual upload date. How many days from actual upload date to promo code batch, etc...


Quote from: winuser2003 on September 10, 2014, 10:03:35 AM
I posted a video, hopefully this helps get a little better understanding and answers your questions.
https://www.youtube.com/watch?v=WXHcIG8N6JI&feature=youtu.be

Refactored Code:
gosub udfs
t1=TimeSubtract(TimeYmdHms(), "0000:00:01:00:00:00")

;Below is a reference so you have the V - variable, next - variable of the field, Botton, middle, and
;top is the location of that field. So lets say I want to change the counter of V1 and V4. So I look

;V1 = next1 Bottom 3
;V4 = next1 Bottom 2
;V2 = next2 Bottom 1
;V3 = next3 Bottom 4

;V7 = next6 Middle 2
;V6 = next5 Middle 1
;V8 = next6 Middle 3
;V9 = next7 Middle 4

;V10 = next9 Top 1
;V11 = next10 Top 2
;V12 = next10 Top 3
;V13 = next11 Top 4

next1=70
next2=63
next3=400
next4=0
next5=49
next6=56
next7=10
next8=0
next9=35
next10=15
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"
nadd13="0000:00:0%next12%:00:00:00"

settime()


TCFormat=`WWWDLGED,6.2`

TCCaption=`Promo Codes Concept`
TCX=178
TCY=064
TCWidth=360
TCHeight=110
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",t6,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=`301,015,044,012,VARYTEXT,"V11",t11,DEFAULT,DEFAULT,240,DEFAULT,DEFAULT,DEFAULT,"255|255|255"`
TC025=`161,015,078,012,VARYTEXT,"V12",t11,DEFAULT,DEFAULT,250,DEFAULT,DEFAULT,DEFAULT,"255|255|255"`
TC026=`247,015,048,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)
  DialogControlSet(MyDialog_Handle,"V12",4,t12)
  DialogControlSet(MyDialog_Handle,"V13",4,t13)
 
  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


Quote from: JTaylor on September 10, 2014, 05:47:49 AM
Trying to figure out what you are doing but you are making it difficult...


  • Your "reference" section at the top makes no sense as all the "next" variables = 400.
  • Your name & variable assignments are not meaningful.  At least match up your V's and T's.....but better yet, give them meaningful values.
  • You assign the same variable name to multiple controls in the dialog.  It will still work in a dynamic dialog but confusing.
  • Conceptually I'm still not sure what you are doing.  How does selecting one upload date populate three rows?  The way they are laid out makes one think they are three different promotions.  Does one upload date create three different promotions?


Hope this helps or at least if you address these issues you might be able to figure out where things are going wrong.   I think the main problem is you are just assigning things incorrectly because your naming convention is not meaningful so it is not obvious where you are going wrong.

Jim

JTaylor

Let's deal with a specific problem.  You mention a problem with V7?   What is the problem?    You have told it to add 56 days to the selected date and that is what it is doing.  What should it be doing?   You had notepad off the edge of the page in your video and couldn't read everything you were typing.

V and T works, obviously, but where it gets confusing it where you match up the different numbers.    Can do that all you want but makes it harder to see mistakes.    If 7's always goes with 7's then it makes it clearer.   If I somehow suggested mixing up such things I apologize.  Not seeing anything like that which I posted.   Actually not seeing any code I posted except repeating yours with a correction.

Jim

winuser2003

All,

I have finally sat down and figured out the code really well. Once I got a grasp on structure and what variables are doing what this project ended up being a major success. I wanted to take the time to thank everyone for there kind assistance and investment in time to helping me out with this. I have learned alot especially working with dynamic dialog boxes. Thank you again and consider this project completed!! thank you again!

WinUser2003