Calculating start date when end date is given in script template

Continuing the discussion from Autofill Task Dates Based on Project Due Date:

Can anyone explain how to do this calculation within the script block for record templates?
All of the scripts have the user putting in a start date with the task objects being created and calculating the end dates (probably explaining wrong).
I am using the PM Script Block 1.2 as my basis for making my template, but I want to do the opposite date calculations with:
End Date: user input
Days Out: field filled in already
Start Date: calculated

I am new to script so any ideas, direction, or specific help would be appreciated.

You can use the same method to calculate the start date as those scripts. However, instead of adding the number of days, subtract the number of days.