Alpha Video Training
Page 1 of 2 12 LastLast
Results 1 to 30 of 45

Thread: Date Script

  1. #1
    "Certified" Alphaholic
    Real Name
    John Koh
    Join Date
    Jan 2004
    Location
    Maryland, USA
    Posts
    1,082

    Default Date Script

    Hi all,

    How can I find the Day of week on this script?
    I do not have any result of my vDays message.
    dim i as n
    dim vDur as n = 3
    dim vSDate as d ={11/30/09}
    dim vNext as c
    dim vDays as c
    dim vDate as c


    if vdur>0 then
    for i=1 to vdur
    vNext=vSDate+i
    vDate=ui_msg_box("Date",vNext)
    'vDays=ui_msg_box("Day",dow({vDate}))
    'vdays=ui_msg_box("Day",cdow(dtoc(vDate)))
    vdays=ui_msg_box("Day",cdow(ctod(vDate))) '<--- Result: Blank

    next i
    else
    ui_msg_box("No Duration","Enter Duration Information")
    end if

  2. #2
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Date Script

    What do you intend

    vDate=ui_msg_box("Date",vNext)

    to do?
    Code:
    vdays=ui_msg_box("Day",cdow(ctod(vNext))) '<--- Result: Not Blank
    There can be only one.

  3. #3
    "Certified" Alphaholic
    Real Name
    John Koh
    Join Date
    Jan 2004
    Location
    Maryland, USA
    Posts
    1,082

    Default Re: Date Script

    Stan,

    My intention is Day of Week for the vDate which I added with duration. It should be "Monday and so".

  4. #4
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Date Script

    John,

    The documentation indicates that the return type of

    ui_msg_box("Date",vNext)

    is a numerical response code, not a date.

    Unless you are testing that response code, eliminate the assignment

    vDate=

    Change the other line as indicated.
    There can be only one.

  5. #5
    "Certified" Alphaholic
    Real Name
    John Koh
    Join Date
    Jan 2004
    Location
    Maryland, USA
    Posts
    1,082

    Default Re: Date Script

    Stan,

    I was looking for a wrong variable field.

    Thank you.

  6. #6
    "Certified" Alphaholic
    Real Name
    John Koh
    Join Date
    Jan 2004
    Location
    Maryland, USA
    Posts
    1,082

    Default Re: Date Script

    Stan,

    How about save the vNext result to a filed in my Work Order table?
    Code:
    dim thdr as p
    dim i as n
    dim vDur as n 
    dim vSDate as d
    dim vNext as c
    thdr=table.open("wrkodr_hd",File_rw_shared)
    vSDate=thdr.Plan_startdate
    vDur=thdr.Plan_duration
    
    thdr.index_primary_put()
    thdr.fetch_first()
    while .not. thdr.fetch_eof()
    if vdur>0 then
    	for i=1 to vdur
    		vnext=vsdate+i
    		'vDate=ui_msg_box("counting",vsdate+i)
    		'vDays=ui_msg_box("Day",cdow(ctod(vNext)))
    
    		Select
    		    case cdow(ctod(vNext))="Monday"
    		        thdr=table.change_begin()
    				     thdr.mon=vNext
    				thdr=table.change_end(.t.)
    			case cdow(ctod(vNext))="tuesay"
    			    thdr=table.change_begin()
    				     thdr.Tue=vNext
    				thdr=table.change_end(.t.)
    			case cdow(ctod(vNext))="Wednesay"
    			    thdr=table.change_begin()
    				     thdr.wed=vNext
    				thdr=table.change_end(.t.)	
    		end select
    
    		next i
    	else
        ui_msg_box("No Duration","Enter Duration Information")	
    end if
    thdr.fetch_next()	
    end while
    
    thdr.close()
    end

  7. #7
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Date Script

    If I understand what you want to do..


    Code:
    dim thdr as p
    dim i as n
    dim vDur as n 
    dim vSDate as d
    dim vNext as c
    thdr=table.open("wrkodr_hd",File_rw_shared)
    
    
    thdr.index_primary_put()
    thdr.fetch_first()
    while .not. thdr.fetch_eof()
    vSDate=thdr.Plan_startdate 'move these two lines to here
    vDur=thdr.Plan_duration 'move these two lines to here
    if vdur>0 then
    	for i=1 to vdur
    		vnext=vsdate+i
    		'vDate=ui_msg_box("counting",vsdate+i)
    		'vDays=ui_msg_box("Day",cdow(ctod(vNext)))
    
    		Select
    		    case cdow(ctod(vNext))="Monday"
    		        thdr=table.change_begin()
    				     thdr.mon=vNext
    				thdr=table.change_end(.t.)
    			case cdow(ctod(vNext))="tuesay"
    			    thdr=table.change_begin()
    				     thdr.Tue=vNext
    				thdr=table.change_end(.t.)
    			case cdow(ctod(vNext))="Wednesay"
    			    thdr=table.change_begin()
    				     thdr.wed=vNext
    				thdr=table.change_end(.t.)	
    		end select
    
    		next i
    	else
        ui_msg_box("No Duration","Enter Duration Information")	
    end if
    thdr.fetch_next()	
    end while
    
    thdr.close()
    end
    There can be only one.

  8. #8
    "Certified" Alphaholic
    Real Name
    John Koh
    Join Date
    Jan 2004
    Location
    Maryland, USA
    Posts
    1,082

    Default Re: Date Script

    Stan,

    Woooo~~~~AK (my scream to A5)

    Code:
    Error Message - thdr.Mon subelement not found
    What is this error mean here.

  9. #9
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Date Script

    It means that there is not a "Mon" field in the table referenced by the

    thdr.

    pointer dot variable. ("wrkodr_hd")
    There can be only one.

  10. #10
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Date Script

    I really didn't study your code other than to notice the two statements out of place. There are other issues. Changes in red.

    thdr.change_begin()

    not

    thdr = table.change_begin()

    for example.


    Code:
    dim thdr as p
    dim i as n
    dim vDur as n 
    dim vSDate as d
    dim vNext as c
    thdr=table.open("wrkodr_hd",File_rw_shared)
    
    
    thdr.index_primary_put()
    thdr.fetch_first()
    while .not. thdr.fetch_eof()
    vSDate=thdr.Plan_startdate 'move these two lines to here
    vDur=thdr.Plan_duration 'move these two lines to here
    if vdur>0 then
    	for i=1 to vdur
    		vnext=vsdate+i
    		'vDate=ui_msg_box("counting",vsdate+i)
    		'vDays=ui_msg_box("Day",cdow(ctod(vNext)))
    
    		Select
    		    case cdow(ctod(vNext))="Monday"
    		        thdr.change_begin()
    				     thdr.mon=vNext
    				thdr.change_end(.t.)
    			case cdow(ctod(vNext))="tuesay"
    			    thdr.change_begin()
    				     thdr.Tue=vNext
    				thdr.change_end(.t.)
    			case cdow(ctod(vNext))="Wednesay"
    			    thdr.change_begin()
    				     thdr.wed=vNext
    				thdr.change_end(.t.)	
    		end select
    
    		next i
    	else
        ui_msg_box("No Duration","Enter Duration Information")	
    end if
    thdr.fetch_next()	
    end while
    
    thdr.close()
    end
    There can be only one.

  11. #11
    "Certified" Alphaholic
    Real Name
    John Koh
    Join Date
    Jan 2004
    Location
    Maryland, USA
    Posts
    1,082

    Default Re: Date Script

    Stan,

    Thank you.

  12. #12
    "Certified" Alphaholic
    Real Name
    John Koh
    Join Date
    Jan 2004
    Location
    Maryland, USA
    Posts
    1,082

    Default Re: Date Script

    Stan,

    It does not fire. I think I still missed some of function here.

  13. #13
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Date Script

    We need to find a translator.

    It does not fire. I think I still missed some of function here.
    I have no clue what this means.

    John,

    You downloaded gaby's sample and fixed his problem. If you were to upload a sample, do you think that might happen for you? Someone would download your sample and see what is wrong????
    Last edited by Stan Mathews; 12-14-2009 at 08:32 PM.
    There can be only one.

  14. #14
    "Certified" Alphaholic
    Real Name
    John Koh
    Join Date
    Jan 2004
    Location
    Maryland, USA
    Posts
    1,082

    Default Re: Date Script

    Stan,

    I mean It(vNext variable) did not save into the a field of the Work_order table.

    I wish to know How to Zip file only selected files from my Master database.
    Every time I tested the Zip file, It shows every thing from my master database.

    I will create a sample database on tomorrow and zip it on here.

    I always appreciate and try to share with others in this forum.

  15. #15
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Date Script

    wish to know How to Zip file only selected files from my Master database.
    In the Alpha control panel, right click on a table or set name and choose Zip. This will include the table or set and the support files for same, not the whole database.
    There can be only one.

  16. #16
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Date Script

    I mean It(vNext variable) did not save into the a field of the Work_order table.
    Did you still get an error?
    Is there a field in the wrkodr_hd table with the name mon?

    You can watch the script execution by placing the command

    debug(1)

    as the first line. Then run the script. The debugger will open and you can use the F12 key to cause the script to step one line at a time. You will be able to see which lines get executed and which are skipped (due to not meeting an if test, for instance.). You can type variable names in the "example" boxes and see how their values change.

    I look forward to your sample.
    There can be only one.

  17. #17
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Date Script

    John,

    How about an update? Did you get this working? Are you able to create a single table/set zip now?
    There can be only one.

  18. #18
    "Certified" Alphaholic
    Real Name
    John Koh
    Join Date
    Jan 2004
    Location
    Maryland, USA
    Posts
    1,082

    Default Re: Date Script

    Stan,
    Not Yet

    I tried to create the Zip file. I opened this zip but I cannot open it because no adb file. If I added the adb file then entire tables are shown.

  19. #19
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Date Script

    Getting somewhere now.

    It is simple enough to add your set to an existing database.

    Try this.

    Code:
    dim thdr as p
    dim i as n
    dim vDur as n 
    dim vSDate as d
    dim vNext as c
    thdr=table.open("wrkodr_hd",File_rw_shared)
    
    thdr.index_primary_put()
    thdr.fetch_first()
    while .not. thdr.fetch_eof()
    vSDate=thdr.Plan_startdate 'move these two lines to here
    vDur=thdr.Plan_duration 'move these two lines to here
    if vdur>0 then
    	for i=1 to vdur
    		vnext=vsdate+i
    		'vDate=ui_msg_box("counting",vsdate+i)
    		'vDays=ui_msg_box("Day",cdow(ctod(vNext)))
    
    		Select
    		    case cdow(ctod(vNext))="Monday"
    		        thdr.change_begin()
    				     thdr.mon= ctod(vNext)
    				thdr.change_end(.t.)
    			case cdow(ctod(vNext))="tuesday"
    			    thdr.change_begin()
    				     thdr.Tue=ctod(vNext)
    				thdr.change_end(.t.)
    			case cdow(ctod(vNext))="Wednesay"
    			    thdr.change_begin()
    				     thdr.wed= ctod(vNext)
    				thdr.change_end(.t.)	
    		end select
    
    		next i
    	else
        ui_msg_box("No Duration","Enter Duration Information")	
    end if
    thdr.fetch_next()	
    end while
    
    thdr.close()
    end
    Since the fields Mon, Tue, etc are date fields you can't put text like "12/14/2009" in them. Also Tuesday was misspelled in

    case cdow(ctod(vNext))="tuesay"

    Wednesday is misspelled as well.

    case cdow(ctod(vNext))="Wednesay"
    Last edited by Stan Mathews; 12-15-2009 at 06:08 PM.
    There can be only one.

  20. #20
    "Certified" Alphaholic
    Real Name
    John Koh
    Join Date
    Jan 2004
    Location
    Maryland, USA
    Posts
    1,082

    Default Re: Date Script

    Stan,

    I Just created new zip and attached here.

    I want to store the Date into "Mon" field if the vNext date is Monday.
    I will express on Color equation ... isnotblank("mon") then Lime Color other Black color.

    But, My alternate method concept had a problem because if the start_date is Friday and more than two days (only business days) then the color bar will be out of range....

  21. #21
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Date Script

    You'll have to spell it out for me. What do you want to happen if the duration would cause the script to fill in the "day" fields through the weekend? Do you want to cycle back to the first of the week?

    Thursday start, duration 3, populate Friday, Monday, Tuesday?
    There can be only one.

  22. #22
    "Certified" Alphaholic
    Real Name
    John Koh
    Join Date
    Jan 2004
    Location
    Maryland, USA
    Posts
    1,082

    Default Re: Date Script

    Stan,

    actually, the deburg(1) runs well witout any problem. I get the value of vNext, vDate and vdays. But the WorkOrder table did not have the date data on here yet.
    My "Mon" field is a Data type. vNext is number and vDate is convert to data field.

  23. #23
    "Certified" Alphaholic
    Real Name
    John Koh
    Join Date
    Jan 2004
    Location
    Maryland, USA
    Posts
    1,082

    Default Re: Date Script

    Stan,

    Code:
    Thursday start, duration 3, populate Friday, Monday, Tuesday?
    Yes, but It should be exposed by following week, isn't it?

    Let's worry about it after solve the vNext or vDate problem.

  24. #24
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Date Script

    As far as I can tell the script in post 19 is working once the misspelling of Wednesday is corrected.
    There can be only one.

  25. #25
    "Certified" Alphaholic
    Real Name
    John Koh
    Join Date
    Jan 2004
    Location
    Maryland, USA
    Posts
    1,082

    Default Re: Date Script

    Stan,

    Yes, Thank you. I get the result after I changed and used ctod(vNext).

    Code:
     vnext= vsdate-1+i
     'vDate= ctod(vNext) 'Conver to Date Filed Type
     'vDays=cdow(ctod(vNext))'Convert to Day of Week
    			    			     
     Select
     Case cdow(ctod(vNext))="Monday"
    	    thdr.change_begin()
    	    thdr.Mon =ctod(vNext) 
    	    'thdr.Mon = vDate
    	    thdr.change_end(.t.)
     Case cdow(ctod(vNext))="tuesday"
    	   'and repeated...
    Do you know why
    Code:
     "Case vDate="Monday"  .... thdr.Mon = vDate
    the above code did not work? I called vDate as convert to data type.

  26. #26
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Date Script

    Since we are working with your set zip only the script you have on the code tab is not available to me. (That's stored in the database files, not the table/set files)

    You could copy and paste it here if you like.
    There can be only one.

  27. #27
    "Certified" Alphaholic
    Real Name
    John Koh
    Join Date
    Jan 2004
    Location
    Maryland, USA
    Posts
    1,082

    Default Re: Date Script

    Stan,

    Here the Code
    Code:
    'Date Created: 12-Dec-2009 08:22:31 PM
    'Last Updated: 15-Dec-2009 05:56:39 PM
    'Created By  : John Koh
    'Updated By  : John Koh
    
    'debug(1)
    
    dim thdr as p
    dim i as n
    dim vDur as n 
    dim vSDate as d
    dim vNext as c
    dim vDate as d
    
    thdr=table.open("wrkodr_hd",File_rw_shared)
    'Query.filter=".t."
    'Quary.order=""
    'query.options=""
    thdr.index_primary_put()
    thdr.fetch_first()
    while .not. thdr.fetch_eof()
    	vSDate=thdr.Plan_startdate
    	vDur=thdr.Plan_duration
    
    if vdur>0 then
    		for i=1 to vdur
    			vnext= vsdate-1+i
    			     'vDate=ui_msg_box("counting",vNext)
    			'vDate= ctod(vNext) 'Conver to Date Filed Type
    			     'vdate=ui_msg_box("date", vdate)     
    			'vDays=cdow(ctod(vNext))'Convert to Day of Week
    			     'vDays=ui_msg_box("Day",vdays)
    			     
    			Select
    			   Case cdow(ctod(vNext))="Monday"
    				    thdr.change_begin()
    					     thdr.Mon =ctod(vNext) 'tHdr.Mon is a date Feild and vdate is a Data Field. Why not?
    					     'thdr.Mon = vdate
    				    thdr.change_end(.t.)
    			   Case cdow(ctod(vNext))="tuesday"
    				    thdr.change_begin()
    					     thdr.Tue=ctod(vNext)
    				    thdr.change_end(.t.)	    
    		       Case cdow(ctod(vNext))="Wednesday"
    				    thdr.change_begin()
    					     thdr.Wed=ctod(vNext)
    				    thdr.change_end(.t.)
    			   Case cdow(ctod(vNext))="Thursday"
    				    thdr.change_begin()
    					     thdr.thu=ctod(vNext)
    				    thdr.change_end(.t.)
    			   Case cdow(ctod(vNext))="Friday"
    				    thdr.change_begin()
    					     thdr.Fri=ctod(vNext)
    				    thdr.change_end(.t.)
    			   Case cdow(ctod(vNext))="Saturday"
    				    thdr.change_begin()
    					     thdr.Sat=ctod(vNext)
    				    thdr.change_end(.t.)
    			   Case cdow(ctod(vNext))="Sunday"
    				    thdr.change_begin()
    					     thdr.Sun=ctod(vNext)
    				    thdr.change_end(.t.)	    	    	    	    
    		   end select		    
            next i
    		else		
    	    ui_msg_box("No Duration","Enter Duration Information")	
    end if			     			
    thdr.fetch_next()	
    end while
    thdr.close()
    end
    If I changed the duration or date, what is an additional scripts for re-write to field?
    In order to control the overflew End_date, My next plans are
    (1) create a new table . If I control the End_date with Week() function ... I may be able to add the continuation(overflow) date records in the new table but I am not sure.
    (2) Apply with Dr Wayne's Calendar which shows by Monthly.
    (3) or depend on you idea if you don't mind.
    (4) Is it possible to make the outline frame and fill in(display) the data. I tied the Crosstab Operation but not good result. Weekly date range, add color and display Project Name problem

    I attached my manual working plan which I want to have a form (data base on work order) and print.

  28. #28
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Date Script

    John,

    Of these

    Code:
    'vDate=ui_msg_box("counting",vNext)
    'vDate= ctod(vNext) 'Conver to Date Filed Type
    'vdate=ui_msg_box("date", vdate)     
    'vDays=cdow(ctod(vNext))'Convert to Day of Week
    'vDays=ui_msg_box("Day",vdays)
    Only

    vDate= ctod(vNext) 'Conver to Date Filed Type and
    vDays=cdow(ctod(vNext))'Convert to Day of Week


    actually does anything.


    Please see the documentation for ui_msg_box(). Ui_msg_box() does not do any conversions.

    vdate=ui_msg_box("date", vdate)

    says assign the response code of a message box with the title "date" and the message vdate (character representation of a date to the vdate variable. The response code is a numeric data type.

    It is unclear how many of these were active in your script.

    I'll look at the rest of your questions tomorrow.
    There can be only one.

  29. #29
    "Certified" Alphaholic
    Real Name
    John Koh
    Join Date
    Jan 2004
    Location
    Maryland, USA
    Posts
    1,082

    Default Re: Date Script

    Good Morning, Stand

    vDate= ctod(vNext) 'Conver to Date Filed Type and
    vDays=cdow(ctod(vNext))'Convert to Day of Week

    actually does anything.
    Did you mean it did not convert to "date" nor "days" ?
    or
    it (Case vDays="Monday") is bad script.

    vdate=ui_msg_box("date", vdate)

    It is unclear how many of these were active in your script.
    I used it for temporary, just see the result.

  30. #30
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Date Script

    Code:
    dim vdate as d
    dim vnext as c
    vnext = "12/15/2009"
    
    vDate=ui_msg_box("counting",vNext) ' can't assign a number to a date type variable
    ERROR: Variable type mismatch
    
    vDate= ctod(vNext) 'Conver to Date Filed Type 'this does work
    ? vdate
    = {12/15/2009}
    If you have the line
    ui_msg_box("counting",vNext)
    in a script, a message box will appear.

    If you have the line
    vDate=ui_msg_box("counting",vNext)
    a message box will appear and Alpha will try to assign the return code (numeric value indicating what button was pressed) to the variable to the left of the equals sign.
    There can be only one.

Similar Threads

  1. Date dialog script & report script won't combi
    By rbierman@iowbar.org in forum Alpha Five Version 5
    Replies: 6
    Last Post: 12-07-2003, 08:40 AM
  2. Problem with date script
    By Glen Beer in forum Alpha Five Version 4
    Replies: 5
    Last Post: 08-25-2003, 07:50 PM
  3. Date Script
    By Mick Magnuson in forum Code Archive
    Replies: 0
    Last Post: 11-29-2001, 10:13 AM
  4. Date Format In Script
    By John Wood in forum Alpha Five Version 4
    Replies: 7
    Last Post: 02-24-2001, 01:50 PM
  5. Valid Date Script
    By Michael Humby in forum Alpha Five Version 4
    Replies: 3
    Last Post: 01-10-2001, 12:36 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •