[jawsscripts] Re: inserting yesterday's date with a script

Hi Jason,

  I think Paul has found the answer to your problem in a rather 
comprehensive manner, but just for completeness:

I use Notepad to write the scripts, with extensive use of the VBScript 
reference documentation which can be downloaded in chm format from:

http://www.microsoft.com/downloads/details.aspx?familyid=01592C48-207D-4BE1-8A76-1C4099D7BBB9&displaylang=en

A script which can be run using the JAWS Run command, and is passed the 
initial date string as a parameter might look like:

---contents of priorDate.vbs---
Option Explicit
Dim oArgs, initialDate, priorDate

Set oArgs = WScript.Arguments

if ((Not oArgs.Count = 1) Or (Not IsDate(oArgs(0)))) then
    WScript.Echo "One date argument required"
    WScript.Quit
end if

initialDate = oArgs(0)
priorDate = DateAdd("d", -1, initialDate)
WScript.Echo "Prior date is: " & priorDate

Set oArgs = Nothing
---end of code---

If the .vbs file is placed in C:\ (for ease of typing) then it can be run 
from a JAWS script:

Run ("c:\\priorDate.vbs 01/01/2010")


  Points I haven't covered include:

a) whether you would be permitted to run VBScript code on a work machine.
b) whether you want the answer to pop up in a dialog or to be handled in 
some other way.
c) the DateAdd function can easily give the next instead of the prior date.
d) although I tried to catch the situation where no parameter is given, I 
notice that a VBScript error is generated when running via a JAWS script. 
More thought required.

  hth

Martin


----- Original Message ----- 
From: "Jason Boston" <jwb3301@xxxxxxx>
To: <jawsscripts@xxxxxxxxxxxxx>
Sent: Friday, February 19, 2010 12:24 AM
Subject: [jawsscripts] Re: inserting yesterday's date with a script


> So do you know of another way to due this from within Jaws? I'm not sure 
> if
> I can run VB scripts on my work PC. How do you go about writing them 
> anyway?
> Do I need visual studio, or what?
>
> -----Original Message-----
> From: jawsscripts-bounce@xxxxxxxxxxxxx
> [mailto:jawsscripts-bounce@xxxxxxxxxxxxx] On Behalf Of Martin Slack
> Sent: Thursday, February 18, 2010 1:35 AM
> To: JAWSScripts
> Subject: [jawsscripts] Re: inserting yesterday's date with a script
>
> I found this at:
>
> http://www.classanytime.com/mis333k/sjdatetime.html
>
>      DateAdd() Add and subtract dates.
>
>      10/11/2002 returned by DateAdd("yyyy", 1, 10/11/2001#))
>      Today's date + 30 days returned by DateAdd("d", 30, Date)
>      The date 45 days ago returned by DateAdd("d", -45, Date)
>      To find Monday of a week: DateAdd("d",-WeekDay(Date)2,Date)
>
>
> Is the DateAdd () function available in Access VBA?  If not, a VBScript 
> can
> certainly be written which converts the date to a day number in the range
> 1-365, subtracts one, then converts back to date.  The script can then be
> run using the JAWS Run function.
>
>  Martin
>
>
> ----- Original Message ----- 
> From: "Jason Boston" <jwb3301@xxxxxxx>
> To: <jawsscripts@xxxxxxxxxxxxx>
> Sent: Thursday, February 18, 2010 2:34 AM
> Subject: [jawsscripts] inserting yesterday's date with a script
>
>
>> HI all,
>> I work in MS Access much of my day at work and have written a script I
>> find
>> very useful for pasting in  today's date based on the computers system
>> date.
>> Below is the script I use assigned to the key stroke "ctrl+shift+v".
>> However,  I would like to create a similar script that pastes in
>> yesterday's
>> date based on the system date. Since the method I'm using defines the
>> system
>> date as a string, I can't figure out how to make it go back one day. 
>> Could
>> anyone suggest how to accomplish this with JFW 11 and MS Access?
>>
>> Here's the script I use for pasting the  current date. BTW it works in a
>> table, query, or a form.
>>
>> Script EnterCurrentDate ()
>> Var
>> String sDate
>> Let sDate = SysGetDate ("MM/dd/yyyy")
>> TypeString(sDate)
>> ' next 2 lines takes focus away from current cell and brings it back
>> quickly
>> so jaws automatically reads you what was just posted.
>> {tab}
>> ShiftTabKey ()
>> EndScript
>>
>>
>>
>>
>>
>>
>> TIA
>>
>> Jason
>>
>>
>> __________
>> Visit and contribute to The JAWS Script Repository http://jawsscripts.com
>>
>> View the list's information and change your settings at
>> http://www.freelists.org/list/jawsscripts
>>
>
> __________
> Visit and contribute to The JAWS Script Repository http://jawsscripts.com
>
> View the list's information and change your settings at
> http://www.freelists.org/list/jawsscripts
>
> __________
> Visit and contribute to The JAWS Script Repository http://jawsscripts.com
>
> View the list's information and change your settings at
> http://www.freelists.org/list/jawsscripts
> 

__________ 
Visit and contribute to The JAWS Script Repository http://jawsscripts.com

View the list's information and change your settings at 
http://www.freelists.org/list/jawsscripts

Other related posts: