dbTalk Databases Forums  

User input in script to search in multiple fields

comp.databases.filemaker comp.databases.filemaker


Discuss User input in script to search in multiple fields in the comp.databases.filemaker forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Sara
 
Posts: n/a

Default User input in script to search in multiple fields - 06-10-2012 , 04:57 AM






I'm using FMP 11.0v4

I have a database where there are five different fields containing dates
for different things.

I want to script a search for a date that may occur in any of these five
fields. That's easy enough to do if I enter a date manually in the
script editor, but what I'd like to do is add a dialogue box that asks
me for the date I want to search for.

I've found an inelegant way of doing this using a separate field as
somewhere to copy the data from as shown below, but I'm sure there must
be a better way.

What I've done is write two scripts, so I didn't mess up one part whilst
trying to get to grips with the other.

The first script says this:

Go to Layout [ ³Sara's layout² (Purchase Orders) ] Perform Script
[³Find export date² ]
Enter Find Mode [ ]
Go to Field [ Purchase Orders::Input date L1 ]
Paste [ ]
[ Select ]
New Record/Request
Go to Field [ Purchase Orders::Input date L2 ]
Paste [ ]
[ Select ]
New Record/Request
Go to Field [ Purchase Orders::Input date L3 ]
Paste [ ]
[ Select ]
New Record/Request
Go to Field [ Purchase Orders::Input date L4 ]
Paste [ ]
[ Select ]
New Record/Request
Go to Field [ Purchase Orders::Input date L5 ]
Commit Records/Requests Perform Find [ ]

The script Find export date says this:

Show Custom Dialog [ Title: "FindDate"; Message: "Please enter required
date"; Buttons: ³OK², ³Cancel²; Input #1: Purchase Orders::Find date,
"Find date" ]
Go to Field [ Purchase Orders::Find date ]
Copy [ ]
[ Select ]

I'd love to be able to do this without having to use an extra field that
has no bearing on anything else. If anyone has any ideas I'd be very
grateful.

--
Armageddon can be louder than expected for such a small cat.

Reply With Quote
  #2  
Old   
Christoph Kaufmann
 
Posts: n/a

Default Re: User input in script to search in multiple fields - 06-10-2012 , 07:24 AM






Sara <saramerriman (AT) blueyonder (DOT) co.uk> wrote:

Quote:
I have a database where there are five different fields containing dates
for different things.
I want to script a search for a date that may occur in any of these five
fields.
There's a possibility that the database's design is worth
re-considering.

Quote:
I'd love to be able to do this without having to use an extra field that
has no bearing on anything else. If anyone has any ideas I'd be very
grateful.
There's nothing wrong with a field like zzDate_g (global storage) which
can be used every time you need a global date field.

Quote:
What I've done is write two scripts, so I didn't mess up one part whilst
trying to get to grips with the other.
That's good, because you might want to use the scripts for other
purposes later.

Quote:
The first script says this:
[...]
Paste [ ]
Don't use copy and paste in scripts (if you want to know why, post that
question in a new thread).

Quote:
The script Find export date says this:

Show Custom Dialog [ Title: "FindDate"; Message: "Please enter required
date"; Buttons: "OK", "Cancel"; Input #1: Purchase Orders::Find date,
"Find date" ]
Use this script in order to fill your global date field. I use a loop
and the isvalid function in order to insist on a proper date.

The scripts ends with a script result 0 if the user has aborted.

Once you have the date in your global date field, a scripted search is
easy.

--
Christoph Kaufmann
http://clk.ch

Reply With Quote
  #3  
Old   
Sara
 
Posts: n/a

Default Re: User input in script to search in multiple fields - 06-10-2012 , 07:59 AM



In article <1klh8rf.1wbs0dl1hd30t6N%clkaufmann (AT) gmx (DOT) ch>,
clkaufmann (AT) gmx (DOT) ch (Christoph Kaufmann) wrote:

Quote:
Sara <saramerriman (AT) blueyonder (DOT) co.uk> wrote:

I have a database where there are five different fields containing dates
for different things.
I want to script a search for a date that may occur in any of these five
fields.

There's a possibility that the database's design is worth
re-considering.

That's not going to happen. This is an old and much loved database that
does everything else I want perfectly, I'm not going to redesign it just
for this.

Quote:
I'd love to be able to do this without having to use an extra field that
has no bearing on anything else. If anyone has any ideas I'd be very
grateful.

There's nothing wrong with a field like zzDate_g (global storage) which
can be used every time you need a global date field.

OK... I've no idea what one of those is at the moment. I shall have a
poke around and see what I can find. As I've had to create a new field
anyway, is there any reason I can't turn that into a global date field?
(When I've worked out what one is, of course).

Quote:
What I've done is write two scripts, so I didn't mess up one part whilst
trying to get to grips with the other.

That's good, because you might want to use the scripts for other
purposes later.

The first script says this:
[...]
Paste [ ]

Don't use copy and paste in scripts (if you want to know why, post that
question in a new thread).

Hmmm. How else would I search for something then? I can't see a way of
getting what I'm looking for into a "Find". Maybe it'll become clearer
when I've found out what a global date field is.

Quote:
The script Find export date says this:

Show Custom Dialog [ Title: "FindDate"; Message: "Please enter required
date"; Buttons: "OK", "Cancel"; Input #1: Purchase Orders::Find date,
"Find date" ]

Use this script in order to fill your global date field. I use a loop
and the isvalid function in order to insist on a proper date.

Good point. It's only me using it for now, so I'll leave that until (if
ever) I need to allow others to use it.

Quote:
The scripts ends with a script result 0 if the user has aborted.

Once you have the date in your global date field, a scripted search is
easy.
Is it? Argh.

Seriously though, thanks for replying so quickly. You've given me a few
pointers to follow. I'll post back and let the group know how I get on.

--
Armageddon can be louder than expected for such a small cat.

Reply With Quote
  #4  
Old   
Christoph Kaufmann
 
Posts: n/a

Default Re: User input in script to search in multiple fields - 06-10-2012 , 09:13 AM



Sara <saramerriman (AT) blueyonder (DOT) co.uk> wrote:

[use a global field]
Quote:
OK... I've no idea what one of those is at the moment. I shall have a
poke around and see what I can find. As I've had to create a new field
anyway, is there any reason I can't turn that into a global date field?
(When I've worked out what one is, of course).
A global field is place where you store some data temporarily, like a
variable. The content is global for a user and a session, meaning

- other users can't see what you've put into the global field, and you
can't be bothered with whatever they put in the very same global field.

- the content is not data that does belong to a record. Put the global
field on a list layout, put some data into the global field in a liine
-> the same data apperas in every line

- when you open the file, the global fields show the data they had the
last time the file was stored locally, which is most probably wrong if
the database is shared. Do not use global fields to store data
permanently (even though it apperas to work when the file is local and
you're the only who uses it, because these things change). Create a
script that sets all global field with content that is empty and make it
run every your file is opened.

[no copying and pasting in scripts]
Quote:
Hmmm. How else would I search for something then? I can't see a way of
getting what I'm looking for into a "Find".
Put the values you search for into variables or global fields, got to
search mode, use set field to insert the values from the global fields
and/or variables.

And yes, you can turn an existing field into a global field. Of course,
all data in that field is gone forever if you do so.
--
Christoph Kaufmann
http://clk.ch

Reply With Quote
  #5  
Old   
Helpful Harry
 
Posts: n/a

Default Re: User input in script to search in multiple fields - 06-11-2012 , 02:08 AM



In article
<saramerriman-6BA209.10574510062012 (AT) news (DOT) eternal-september.org>, Sara
<saramerriman (AT) blueyonder (DOT) co.uk> wrote:

Quote:
I'm using FMP 11.0v4

I have a database where there are five different fields containing dates
for different things.

I want to script a search for a date that may occur in any of these five
fields. That's easy enough to do if I enter a date manually in the
script editor, but what I'd like to do is add a dialogue box that asks
me for the date I want to search for.

I've found an inelegant way of doing this using a separate field as
somewhere to copy the data from as shown below, but I'm sure there must
be a better way.

What I've done is write two scripts, so I didn't mess up one part whilst
trying to get to grips with the other.

The first script says this:

Go to Layout [ ³Sara's layout² (Purchase Orders) ] Perform Script
[³Find export date² ]
Enter Find Mode [ ]
Go to Field [ Purchase Orders::Input date L1 ]
Paste [ ]
[ Select ]
New Record/Request
Go to Field [ Purchase Orders::Input date L2 ]
Paste [ ]
[ Select ]
New Record/Request
Go to Field [ Purchase Orders::Input date L3 ]
Paste [ ]
[ Select ]
New Record/Request
Go to Field [ Purchase Orders::Input date L4 ]
Paste [ ]
[ Select ]
New Record/Request
Go to Field [ Purchase Orders::Input date L5 ]
Commit Records/Requests Perform Find [ ]

The script Find export date says this:

Show Custom Dialog [ Title: "FindDate"; Message: "Please enter required
date"; Buttons: ³OK², ³Cancel²; Input #1: Purchase Orders::Find date,
"Find date" ]
Go to Field [ Purchase Orders::Find date ]
Copy [ ]
[ Select ]

I'd love to be able to do this without having to use an extra field that
has no bearing on anything else. If anyone has any ideas I'd be very
grateful.
Don't use Copy and Paste. If the user copies something and then runs your
script, they lose whatever they copied and become confused as to why they
are now getting a "strange date" when they next perform a paste.


The best approach is to use a Global Field or a Variable to obtain the
required date from the user, and then use that to set the other fields
when in Find Mode.
i.e.
Set Field [Purchase Orders::Input date L1; g_FindDate]

You may need to play with the Get functions that convert the user-entered
text in the Global Field to a proper date format, but I think newer
versions of FileMaker may be more flexible about this than my old
versions.


Rather than the necessity of setting multiple fields, you could create a
new Calculation Field that hides in the backgorund and combines all the
other dates - then you can perform the Find on just one field. Something
like:
e.g.
c_AllDates Calculation, Text Result
= GetAsText (Purchase Orders::Input date L1) & "P"
& GetAsText (Purchase Orders::Input date L2) & "P"
& GetAsText (Purchase Orders::Input date L3) & "P"
& GetAsText (Purchase Orders::Input date L4) & "P"
& GetAsText (Purchase Orders::Input date L5)

where P is the "backwards P" return symbol, and then the script becomes:

Enter Find Mode []
Set Field [c_AllDates; GetAsText(g_FindDate)]
Perform Find []



Note: I haven't got a copy of FileMaker on this computer, so the
"GetAsText" function may not be the correct name.

Helpful Harry )

Reply With Quote
  #6  
Old   
Sara
 
Posts: n/a

Default Re: User input in script to search in multiple fields - 06-11-2012 , 07:01 AM



In article
<HelpfulHarry-1106121908460001 (AT) 203-118-187-111 (DOT) dsl.dyn.ihug.co.nz>,
HelpfulHarry (AT) BusyWorking (DOT) com (Helpful Harry) wrote:

Quote:
In article
saramerriman-6BA209.10574510062012 (...-september.org>, Sara
saramerriman (AT) blueyonder (DOT) co.uk> wrote:

I'm using FMP 11.0v4

I have a database where there are five different fields containing dates
for different things.

I want to script a search for a date that may occur in any of these five
fields. That's easy enough to do if I enter a date manually in the
script editor, but what I'd like to do is add a dialogue box that asks
me for the date I want to search for.

I've found an inelegant way of doing this using a separate field as
somewhere to copy the data from as shown below, but I'm sure there must
be a better way.

What I've done is write two scripts, so I didn't mess up one part whilst
trying to get to grips with the other.

The first script says this:

Go to Layout [ ³Sara's layout² (Purchase Orders) ] Perform Script
[³Find export date² ]
Enter Find Mode [ ]
Go to Field [ Purchase Orders::Input date L1 ]
Paste [ ]
[ Select ]
New Record/Request
Go to Field [ Purchase Orders::Input date L2 ]
Paste [ ]
[ Select ]
New Record/Request
Go to Field [ Purchase Orders::Input date L3 ]
Paste [ ]
[ Select ]
New Record/Request
Go to Field [ Purchase Orders::Input date L4 ]
Paste [ ]
[ Select ]
New Record/Request
Go to Field [ Purchase Orders::Input date L5 ]
Commit Records/Requests Perform Find [ ]

The script Find export date says this:

Show Custom Dialog [ Title: "FindDate"; Message: "Please enter required
date"; Buttons: ³OK², ³Cancel²; Input #1: Purchase Orders::Find date,
"Find date" ]
Go to Field [ Purchase Orders::Find date ]
Copy [ ]
[ Select ]

I'd love to be able to do this without having to use an extra field that
has no bearing on anything else. If anyone has any ideas I'd be very
grateful.

Don't use Copy and Paste. If the user copies something and then runs your
script, they lose whatever they copied and become confused as to why they
are now getting a "strange date" when they next perform a paste.


The best approach is to use a Global Field or a Variable to obtain the
required date from the user, and then use that to set the other fields
when in Find Mode.
i.e.
Set Field [Purchase Orders::Input date L1; g_FindDate]

You may need to play with the Get functions that convert the user-entered
text in the Global Field to a proper date format, but I think newer
versions of FileMaker may be more flexible about this than my old
versions.


Rather than the necessity of setting multiple fields, you could create a
new Calculation Field that hides in the backgorund and combines all the
other dates - then you can perform the Find on just one field. Something
like:
e.g.
c_AllDates Calculation, Text Result
= GetAsText (Purchase Orders::Input date L1) & "P"
& GetAsText (Purchase Orders::Input date L2) & "P"
& GetAsText (Purchase Orders::Input date L3) & "P"
& GetAsText (Purchase Orders::Input date L4) & "P"
& GetAsText (Purchase Orders::Input date L5)

where P is the "backwards P" return symbol, and then the script becomes:

Enter Find Mode []
Set Field [c_AllDates; GetAsText(g_FindDate)]
Perform Find []



Note: I haven't got a copy of FileMaker on this computer, so the
"GetAsText" function may not be the correct name.

Helpful Harry )
Thanks both of you - I'll be trying these suggestions out later this
evening. Wish me luck!

--
Sara

Peeps squeaks, Billy is silly and as for Armageddon...

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.