Simple Javascripting for DB/TextWorks - PowerPoint PPT Presentation

1 / 28
About This Presentation
Title:

Simple Javascripting for DB/TextWorks

Description:

A few thoughts about this presentation... Firstly... Thirdly... I've only got 15 minutes to deliver this talk. I hope to pique your interest ... – PowerPoint PPT presentation

Number of Views:662
Avg rating:3.0/5.0
Slides: 29
Provided by: eli97
Category:

less

Transcript and Presenter's Notes

Title: Simple Javascripting for DB/TextWorks


1
Simple Javascripting for DB/TextWorks
  • Alan Matthews
  • Information Solutions Consultant
  • Friday, 23 March 2012

2
Agenda
  • What is Javascripting?
  • Why would you want to use it?
  • How is it used within DB/TextWorks?
  • A worked example
  • Resources available
  • Summary
  • Questions 5 minutes

3
A few thoughts about this presentation
  • Firstly Im not going to be teaching you
    programming.
  • Secondly Scripts are usually lt 10 lines long.
  • Thirdly Ive only got 15 minutes to deliver this
    talk.
  • I hope to pique your interest
  • And to point out that its not dangerous!
  • So, in true H2G2 style DONT PANIC!
  • So try it, it may save you time and make your
    application slicker!

4
OK, so what is this Javascripting stuff?
  • JavaScript is a lightweight programming language
  • It looks something like this
  • function onFormClear()
  • Form.boxes("name1").content "gt_at_date - 7"
  • Form.boxes("name1").setFocus()
  • Available since DB/TextWorks v4.0
  • DB/TextWorks gives you many ways to read/write
    and control data and forms through scripting.

5
Why would you want to use it?
  • To automate a repetitive task.
  • To simplify a complex task.
  • To combine a series of tasks in a workflow.
  • To create more advanced linking from external
    textbases.
  • To display helpful messages.
  • To select the right forms for the output.
  • To assist navigation around a complex application

6
Example 1
7
Example 2
8
Examples 3 2020 LMS
9
How is it used within DB/TextWorks?
  • Worked example report form with 3 sort options

10
Stage 1 Create your Script Buttons
  • Use Edit gt Add gt Script Button from the menu
  • Give them Captions
  • Adjust their Position Size

11
Stage 2 Adding the script
12
Stage 3 Name the buttons
  • Provide each button and/or field that will use in
    your scripts with a name.

13
Stage 4 Create your script
Beg, borrow or otherwise acquire a script similar
to the one you need.
Hack it about until it fits your needs.
Debug it until it works.
14
Scripting Some detail
The function needs to be defined. In this case it
will activate when you click on the defined button
function title_onClick()
var crs Application.activeTextbase.currentRecord
set var sd crs.newSortDescriptor()
Set up some variables so we can pass the values
to other functions
sd.sortFieldName(0) "title"
Setup the sort descriptor to be the field you
want to sort by.
crs.Sort(sd)
Do the sort with the Current Record Set and the
Sort Descriptor
Command.refreshWindow()
Refresh the window displaying the results
15
Stage 5 Re-use it as much as possible!
function title_onClick() var crs
Application.activeTextbase.currentRecordset
var sd crs.newSortDescriptor()
sd.sortFieldName(0) title" crs.Sort(sd)
Command.refreshWindow()
Sort by title field
function id_onClick() var crs
Application.activeTextbase.currentRecordset
var sd crs.newSortDescriptor()
sd.sortFieldName(0) "id" crs.Sort(sd)
Command.refreshWindow()
Sort by id field
function modified_onClick() var crs
Application.activeTextbase.currentRecordset
var sd crs.newSortDescriptor()
sd.sortFieldName(0) modified"
crs.Sort(sd) Command.refreshWindow()
Sort by modified field
16
Voila! One really neat solution!
17
A note on debugging
  • There are several immutable laws when
    programming.
  • It wont ever work first time!
  • If it does, go and buy a lottery ticket, you
    cant lose!
  • It is down to CaSe sEnsitiviTy.
  • Look at those variable and button names again.
  • It is down to grammar -,
  • watch those commas, dots, semicolons and
    brackets, etc.
  • Its down to syntax
  • Dont words the get the wrong way round
  • Youre trying to do something that the Object,
    its property or method isnt designed to do.
  • Are you trying to write into a read-only
    property?
  • If at first you dont succeed, try, try, try,
    try, try, try, try, try, try, try, try, try, try,
    try, try again.
  • And then read a book

18
Some simple scripts see DBTW Help
  • Pre-populate a query screen for new queries.
  • Add a "help" button next to a box on an edit
    screen, telling the user what to type in that
    field.
  • Launch document(s) in a field in the Edit,
    Display, or Report window in its native
    application.
  • Add button to report to sort by a specific field
    exploded.
  • Specify forms for use with an individual query
    screen.
  • Reset the buttons for all query boxes to AND when
    you click New Query.

19
Some simple scripts see DBTW Help
  • Add a script button to swap the contents of two
    fields.
  • Add buttons to a query screen to print the
    current set using either of two report forms.
  • Copy the first word of one field to another field
    (if the second field is empty) when the record is
    saved.
  • Import file using delimited ASCII format.
  • Export all records in textbase in delimited ASCII
    format.
  • Send report as mail with attachments.

20
Resources available
  • W3Schools online web tutorialshttp//www.w3school
    s.com/js/default.asp
  • Books JavaScript For Dummies and 1,000s more
  • Inmagics Script Libraryhttp//www.inmagic.com/su
    pport/script_lib/script_lib.html
  • Inmagic Forumhttp//inmagic.infopop.cc/6/ubb.x
  • DB/TextWorks online Help (F1)

21
Summary
  • JavaScripting isnt that difficult to understand.
  • There are masses of general resources.
  • Theres a lot of DB/TextWorks material available
    too.
  • It will save you from so much tedium and
    time-wasting activity.
  • You will learn something useful.
  • And youll get an application that will be easier
    for you and others to use.

22
Questions?
23
Thank You!Simple Javascripting for DB/TextWorks
  • Alan Matthews
  • Information Solutions Consultant
  • Friday, 23 March 2012

24
Further help from Soutron
Alan Matthews Account Manager
Get the most value out of your Inmagic software
Investment with...
  • Upgrades and enhancements
  • Other uses applications
  • Web-based and on-site training
  • Professional Services/Consultancy

Contact me directly
0870 950 60 87
alan.matthews_at_soutron.com
25
Some More Practical JavaScripting Applications
26
Screens from our internal systems
27
Screens from 2020 LMS
28
JavaScripting galore!
Write a Comment
User Comments (0)
About PowerShow.com