VISUAL QUICKPRO GUIDE FileMaker Pro 7 Advanced FOR WINDOWS AND MACINTOSH [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

VISUAL QUICKPRO GUIDE FileMaker Pro 7 Advanced FOR WINDOWS AND MACINTOSH [Electronic resources] - نسخه متنی

Cynthia L. Baron, Daniel Peck

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید











Using If with Else


Sometimes you'll want the script to do something when the answer to the If condition isn't yes. You use an Else step within an If so the script will choose a different action when the If statement isn't true. Else steps are only executed if the condition is not true. Otherwise, they're ignored.

This script uses If and Else to change data in the Paid field for each record.

To use If and Else to modify data



1 .

Choose Scripts > ScriptMaker (Control+Shift+S/Command+Shift+S). When the Define Scripts dialog box appears, click New.

2 .

When the Edit Script dialog box appears, type a descriptive name for the script in the Script Name text box (in this case Set Paid).

3 .Under the Control category in the script step list on the left, double- click If.

4 .In the Script Step Options section, click Specify to bring up the Specify Calculation dialog box.

5 .In the field list on the left, scroll to find your field (we're using Balance Due). Double-click to add it to the formula box.

6 .

Choose the greater than (>) symbol from the Operators scrolling list by double- clicking it.

7 .Type 0 (zero), then click OK. The formula box now displays the highlighted If statement with its condition (Figure 8.8). Click OK.

Figure 8.8. The If step checks to see if the amount in Balance Due is greater than 0.


8 .In the step list on the left, double-click the action you want performed. In this example, we choose Set Field from the Fields section (Figure 8.9). It replaces the contents of a field with whatever you specify.

Figure 8.9. Choose Set Field to insert new information into an existing field.


9 .In Script Step Options, click the "Specify target field" check box (Figure 8.10).

Figure 8.10. The Specify target field check box allows you to specify the field you want to change.


10 .When the Specify Field dialog box appears (Figure 8.11), choose the field name (in our example, we choose Paid). If you haven't yet created the field you need, choose Define Database in the drop-down menu to create it. Click OK to close the box and return to the Edit Script window.

Figure 8.11. Choose or create the field you want in the Specify Field dialog box.


11 .In the Script Step Options section, click the Calculated result: Specify button.

12 .When the Specify Calculation window appears, click the quotes operator button (""), then type an N between the quotes. Click OK to close the dialog box (Figure 8.12).

Figure 8.12. If there's a balance, Set Field marks the Paid field with an N for not paid.


[View full size image]

At this point, your script checks to see if the balance in the account is more than 0. If it is, the script marks the Paid field with an N for not paid.

13 .In the step list, double-click Else to add it to the script-assembly list (Figure 8.13).

Figure 8.13. Else follows If in a script.


[View full size image]

14 .Repeat steps 811.

15 .

When the Specify Calculation window appears, click the quotes operator button (""), then type a Y between the quotes. Click OK to close the dialog box (Figure 8.14).

Figure 8.14. The Y marks the field as Paid.


Now your script marks the Paid field with a Y for paid if there is no balance due.

16 .Click OK twice to close ScriptMaker.



Commonly Used Get Functions


Although there are dozens of Get functions in the function list, some are much more useful than others. These are some of our favorites, which we use frequently in scripts we create.

Date and TimeGet(CurrentDate)The current date according to your computer.

Get(CurrentTime)The current time according to your computer.

ScriptGet(LastError)

The error code for the most recent error. See Chapter 10, "Script Troubleshooting" for more details about using this function.

Get(LastMessageChoice)A number that stands for one of three possible buttons a user can choose from an alert message. All three can be changed using a Show Custom Dialog step in a script.

1 = first button (by default, OK)

2 = second button

3 = third button

Get(ScriptName)The name of the script that's currently active.

Field and LayoutGet(ActiveFieldName)The name of the field where the cursor is active.

Get(LayoutName)The name of the current layout.

Get(LayoutTableName)The name of the table being used in the current layout.

Get(PortalRowNumber)The number of the current portal row. If no portal is selected, this number will be 0.

Get(ActiveRepetitionNumber)The number of the current repetition in a repeating field.

DatabaseGet(FileName)The name of the current file.

Get(FoundCount)The number of records in the current found set.

Get(TotalRecordCount)The number of records in the table.

Get(WindowMode)0 = Browse mode 1 = Find mode

2 = Preview mode

3 = Printing in progress

Get(SortState)0 = unsorted 1 = sorted

2 = partially (semi) sorted

Multi-UserGet(MultiUserState)0 = sharing off

1 = database accessed from a host

2 = database accessed from local computer

Get(UserName)The name of the user currently logging in to the local computer.

Get(AccountName)The name of the current account (from Accounts & Privileges) logged in to FileMaker.

System SettingsGet(SystemVersion)The version of the current operating system.

Get(SystemPlatform)-1 = Macintosh

-2 = Windows XP or Windows 2000

Get(PrinterName)The printer name, driver name, and port name (Windows) or the Queue name and IP address of the current printer (Mac).


Using Get Functions


If you're having problems visualizing how you might use a Get function, here are some practical suggestions to jump-start your imagination:

Date and TimeUse date and time functions in scripts to track changes and additions.

LastMessageChoiceMake a user's choice in a custom dialog box the condition for an If/Else statement.

LayoutNameWindowModeAccountNameEach of these functions is handy for scripting custom navigation within a database. You can fine-tune what each user sees and where they go in the database with these tools.

FoundCountUse this function to determine whether or not a scripted Find had the desired results (for example, if no records were found). If you use it in combination with the Set Error Capture script step, it will enable a script to return a custom result for a scripted Find.

SystemVersionSystemPlatformThese two functions can be invaluable if you have to adjust your scripts for older operating systems, fine-tune printing issues between Macs and Windows, or keep specialized FileMaker plug-ins straight on the different platforms.


/ 227