Pracownia specjalistyczna

Podstawy pisania prostych aplikacji II

Ćwiczenie 1 - Właściwość Pola „Default Value”

czyli ustawienie wartości domyślnej dowolnego pola

1.      W Designerze wejść do Formularza

2.      Zaznaczyć dowolne pole (np. Miasto)

3.      Wstawić wartość tekstową do „Default Value”: Białystok”

4.      Zapisać i sprawdzić rezultaty

Dla innego pola (np. o nazwie „Użytkownik”) ustawić w „Default Value” formułę:

@UserName

sprawdzić

HELP

Default value formulas 

A default value formula provides an initial value for a field. This formula executes when a document is created, and for uneditable rich text fields when the document is saved. The user can change the value in the field except for uneditable rich text fields. You must specify a default value formula for an uneditable rich text field.

Ćwiczenie 2 - Input Translation

1.   W Designerze wejść do Formularza

2.   Zaznaczyć dowolne pole (np. Nazwisko)

3.   Wstawić formułę do „Input Translation”

@UpperCase (Nazwisko)

4.   Zapisać i sprawdzić rezultaty

5.   na innym polu wypróbować formułę: @ProperCase(nazwa_pola))

HELP

Input translation formulas 

An input translation formula converts the data entered in the field to adjust the field value or make the field conform to a format. This formula executes when the document containing the field is saved. An input translation formula must evaluate to a value suitable for storage in the current field.

Example: Input translation formulas 

This input translation formula makes the Subject field proper case (initial capitals) with no extraneous spaces.

@Trim(@ProperCase(Subject))

Ćwiczenie 3 - Input validation formulas

1.   W Designerze wejść do Formularza

2.   Zaznaczyć dowolne pole (np. Nazwisko)

3.   Wstawić formułę do „Input Validation”

@If(Nazwisko != "" ; @Success; @Failure("Brak Nazwiska ! Proszę uzupełnić to pole"))

4. Zapisać i sprawdzić rezultaty

HELP

Input validation formulas 

An input validation formula checks the data entered in the field against criteria that you specify. This formula executes after the input translation formula.

An input validation formula should end with a call to @Success or @Failure.

Examples: Input validation formulas 

    This input validation formula doesn't let the Cost field exceed 100.

@If(Cost<100; @Success; @Failure("Cost must be less than $100))

Ćwiczenie 4 - Pola przeliczalne

1. Stworzyć dwa pola typu Number : LataPracy , LataNauki

2. Utworzyć pole typu Number: LataSuma

4.   zmienić typ pola LataSuma z Editable na Computed

5.   W właściwości pola Value wpisać formułę:

@If (@IsNumber(LataPracy) &  @IsNumber(LataNauki);LataNauki + LataPracy; "")



4. Zapisać i sprawdzić rezultaty (F9 – odświeża dokument i powoduje przeliczenie)

HELP

Editable and computed fields 

You choose whether a field is editable or computed in the field properties box, when you create the field. If a field is editable, a user can enter or change the value of the field. If a field is computed, a formula calculates the field value. Users can't change the values in a computed field. Number, date/time, authors, readers, and names fields are usually computed. Text, rich text, and choice list fields are usually editable.

Writing field formulas

Use the Reference tab on the Info List of the Programmer's pane to access the list of fields, @commands, and @functions. You can use the Reference list as a shortcut for looking up @functions and @commands, and for pasting them into the formula.

Computed field formulas

Computed fields are used to automatically enter data, such as the author's name or the date, in a field. You can have more than one computed field on a form. Computed  fields require formulas to supply their values. For example, you use a computed field to assign a creation date to a document. Computed fields are normally recalculated when users create documents, choose View ­ Refresh Fields, press F9, or save documents Selecting the field property "Compute after validation" is useful when a field is dependent on values in other fields and you want to be sure that the calculation occurs after those fields have been validated.

When it's important for users to see results as they proceed, you can force each field to be calculated as it's filled in by selecting the form property "Automatically refresh fields." This is useful when fields at the bottom of the form are dependent on field values at the top. Be aware that this property can slow down document display time if the form has many computed fields.

Ćwiczenie 5 - Ukrywanie pól

Celem ćwiczenie jest pokazywanie i ukrywanie pola inny kolor oczu w zależności czy jest zaznaczona opcja „inny” w polu KolorOczu

1.     Dostawić pole InnyKolorOczu

2.     Zaznaczyć to pole i we właściwościach -> Na zakładce ukrywanie tekstu wpisać formułę:

@If ( KolorOczu  != "inny")

3.       We właściwościach pola KolorOczu uaktywnić opcję : Refresh fields when keywords change

4. Zapisać i przetestować

To hide a field 

 If you have computed fields that users don't need to see, or if you create two fields -- one for display when reading and one for use when editing -- you can stipulate when to hide the fields.

  1. Select the field you want to hide.

  2. Choose Design - Field Properties.

  3. On the Hide tab :

Select "Hide paragraph when document is:" and click all situations when users don't need to see the field information.

or

Select "Hide paragraph if formula is true" and write a formula in the formula window on the Properties box to describe the situations when users don't need to see the fields.

Choosing  "Refresh fields when keywords change" displays documents faster than the form property "Automatically refresh fields." It is useful for showing or hiding parts of the form when you have hide-when formulas that are dependent on values in the field.

Examples

To make documents more readable, you decide to modify the Marketing Ideas form to show only the model name for the product that the author selects.

The Models field is a radio button field that displays these choices for refrigerator models:

Econo-Freeze

Icebox 2000

InstaFreeze

Premium

The Chiller

You hide the Models field when previewed and opened for reading.

You create a computed text field called SelectedModel and locate it under the Models field. SelectedModel uses the value from the Models field. You hide the SelectedModel field when opened for editing.

Now when users create a new document, all model names are shown. When users read a document, they see only the model name chosen by the author.

Ćwiczenie 6 - Selekcja dokumentów w widoku + pobranie wartości z innego widoku

1.      Utworzyć nowy formularz np. pt. „Sprzęt komputerowy”  z polami

Nazwa sprzętu 

Rodzaj (radio Button – komputer, monitor, drukarka , skaner itp)

Typ

Nr ewidencyjny

Koszt 

Data zakupu

Nr Pokoju gdzie sprzęt się znajduje (Dialog list )

Przydzielony do osoby


2.      Utworzyć widok o nazwie „Lista sprzętu”

3.      Utworzyć kilka dokumentów z formularza „Sprzęt komputerowy” 

4.      Zobaczyć co się pojawi w widokach

5.      aby rozdzielić dokumenty na leży wpisać formułę selekcji w każdym z widoków

W widoku Lista sprzętu we właściwości View Selection”

SELECT Form = "Sprzet"

 

6.      Analogiczną formułę wpisać w widoku  „Lista osób”

7.      sprawdzić rezultaty

Pobranie wartości z innego widoku

Dodanie możliwości pobierania osób z widoku „Lista osób”

1. We właściwościach pola „Przydzielony_do_osobyustawić typ „Dialog List”

2. Na drugiej zakładce ustawić „Use View dialog for choices”

4.     wybrać widok „Osoby”

5.     Zapisać i sprawdzić rezultaty

6.     przy wypełnianiu pola „Przydzielony_do_osobypowinno się pojawić okno