Join The Works program to have access to the most current content, and to be able to ask questions and get answers from Revelation staff and the Revelation community

At 29 APR 2020 10:16:53PM rdhull50 wrote:

Rober Hull

First of all, I am new to OI. I have spent a lot of time in AREV, so I am trying to learn how to do things in an OI Form that I used to do in an AREV Window.

An Example:

I have a Form named "WIN_VISITS". It is populated as follows:

Visit # (EDL_ID) this is initially set by the SeqKey

User ID (EDL_User_ID)

Visit Date (EDL_VisitDate)

Visit Start Time (EDL_VisitStart)

Visit End Time (EDL_VisitEnd)

Visit Purpose (EDL_Purpose)

Class Code (EDL_Class_CD)

In AREV, the default value for Purpose is set by a Symbolic called {Deflt_Purpose}; Also, the Class Code is only valid if the Purpose is either "Training" or "Trainer". That is validated by a subroutine called "Check_Visit" which validates that along with other pieces of information (such as the Time columns) prior to permitting the record to be saved. If there is an error, then an error message is displayed.

I need to set the DefValue of the Purpose column. It doesn't appear that I can do this with a Symbolic from the dictionary, so I need to do it with a stored procedure or some Event script. I see that DefValue can get its value from a Function. i.e. FUNCNAME('arg1',2,['arg3',3])

I need to know how to pass the data from the current record in the Window into the stored procedure or Event so that I can manipulate it. A simple example is: the DefValue for Purpose can be the information that is stored in the "FHC_Users" table for the displayed User ID, field # 3. e.g. DefValue = Xlate ("FHC_Users", {User_ID},3,"X"). I then need to pass the correct value back to the DefValue property for the Purpose column. It needs to go into DefValue instead of directly into Purpose since it is possible, under certain conditions, to choose something other than the DefValue.

I need to pass the record to the Check_Visit subroutine which runs when the "Write" button is clicked, but before the row is saved. If there is an error; Display the error; return to the record in the window to correct the error. (The Check_Visit subroutine potentially runs multiple times until all errors are corrected i.e. each time "Write" is clicked.)

I suspect that there may be multiple ways to accomplish the above. Any guidance would be appreciated.

This is the actual code from the symbolic "{Deflt_Purpose}":

DFLT = {USER_DFLT_PURPOSE}; * A symbolic on the Visits Table, it's value is set as follows: * ROLE=XLATE("FHC_USERS",{USER_ID},3,"X") * @ANS=XLATE("ROLES",ROLE,2,"X") - This is the Default_Purpose column UDFLT = DFLT * DFLT begins as 'DEFAULT_PURPOSE' from ROLES Table BTDATE = ICONV("03 JAN 19","DE"); * FIRST THURSDAY BFDATE = BTDATE + 1 ; * FIRST FRIDAY BSDATE = BTDATE + 3 ; * FIRST SUNDAY * DATE is usually DATE(), as that is the default. DATE = @RECORD<2> TDDIFF = DATE-BTDATE FDDIFF = DATE-BFDATE SDDIFF = DATE-BSDATE * TIME = TIME() TIME = @RECORD<3> TDFLAG = 0 ; * THURSDAY DATE FLAG FDFLAG = 0 ; * FRIDAY DATE FLAG SDFLAG = 0 ; * SUNDAY DATE FLAG FTFLAG = 0 ; * FRIDAY TIME FLAG ETFLAG = 0 ; * EVENING TIME FLAG TFLAG = 0 ; * TIME FLAG IF TIME >= 41400 AND TIME ⇐ 61200 THEN TFLAG = 1 IF TIME >= 66600 THEN ETFLAG = 1 IF MOD(TDDIFF,7) = 0 THEN TDFLAG = 1 IF MOD(FDDIFF,7) = 0 THEN FDFLAG = 1 IF MOD(SDDIFF,7) = 0 THEN SDFLAG = 1 IF FDFLAG AND TFLAG THEN FTFLAG = 1 IF FDFLAG = 0 THEN FTFLAG = 0 IF UDFLT = 'YOUTH' AND ( FDFLAG = 0 OR FTFLAG = 0 ) THEN DFLT = 'PATRON' END IF FDFLAG AND FTFLAG THEN IF DFLT = "YOUTH" THEN NULL END ELSE DFLT = UDFLT END END IF TDFLAG AND ETFLAG AND DFLT <> "TRAINER" THEN DFLT = "TRAINING" END IF TDFLAG = 0 AND ETFLAG THEN DFLT = "GROUP" END IF SDFLAG THEN DFLT = "GROUP" END @ANS = DFLT

This is the actual code (AREV64) for the Check_Visits subroutine

SUBROUTINE CHECK_VISITS $INSERT SYSINCLUDE,WINDOW_COMMON% DECLARE SUBROUTINE MSG UID = @RECORD<1> VSTART = @RECORD<3> VEND = @RECORD<4> VSECS = VEND - VSTART PURPOSE = @RECORD<5> CLASS = @RECORD<6> ROLE = XLATE("FHC_USERS",UID,3,"X") WARD = XLATE("FHC_USERS",UID,4,"X") BEGIN CASE CASE ROLE = 'STAFF' AND PURPOSE = 'YOUTH' MSG ('"STAFF" must not be entered as "YOUTH" on the Friday program') WC_VALID% = 0 CASE VEND > 0 AND VEND < VSTART MSG ('Visit End Time must be after Visit Start,|Hint: Enter a "P" after the time for PM.|Press [F1] at the prompt for more information.') WC_VALID% = 0 CASE VSTART < 21600 MSG ('Visit Start Time should be 6:00 AM or later.') WC_VALID% = 0 CASE VSTART > 0 AND VSTART = VEND MSG ('Visit start and End Time are the same.') WC_VALID% = 0 CASE VSECS > 36000 MSG ('WARNING - visit exceeds 10 hours') WC_VALID% = 0 CASE ( PURPOSE <> 'TRAINING' AND PURPOSE <> 'TRAINER' ) AND CLASS > 0 MSG ('Visit has invalid purpose|Or Class ID entered in error') WC_VALID% = 0 CASE ( PURPOSE = 'TRAINING' OR PURPOSE = 'TRAINER' ) AND CLASS = MSG ('Class # must be entered for Trainer/Training Visits.') WC_VALID% = 0 END CASE IF WARD = "NK" OR WARD = THEN MSG ('Caution: WARD = "NK",|Please endeavor to find the correct ward.') END RETURN END


At 04 MAY 2020 03:28PM rdhull50 wrote:

Rober Hull

Since writing this thread originally, I have learned a few things, and with some assistance, have resolved all of my issues on this topic.

I am now able to populate the defValue property with a function and my "Check_Visits" program is running as a Write-event on the Form.

I presume that the data in the controls on the form are converted into their internal stored format as part of the Write event and are thereby not accessible from the form itself. e.g. Dates are entered on the form in there external format and converted to an integer value during Write. So if you need to use the internal integer form of the date, then you need to use the Iconv statement. If there is some other way of directly getting at the converted value of a control, I would be happy to know it.


At 04 MAY 2020 03:30PM bob carten wrote:

Hi Robert,

The 'INVALUE' property should give you the internal value


At 07 MAY 2020 01:13PM rdhull50 wrote:

Can you tell me exactly what "DEFPROP" is, in terms of a data bound control in a Window (form)?

e.g. Get_Property( @Window : ".EDL_RECORDDATE" , "DEFPROP" )

where EDL_RECORDDATE is the control for a field of Data Type, "DATE".

How does it differ from:

Get_Property( @Window : "EDL_RECORDDATE" , "TEXT" )

which returns the textual value for the field (e.g. "30 APR 2020" ) and,

Get_Property( @Window : "EDL_RECORDDATE" , "INVALUE" )

which returns the internal (stored) value for the field (e.g. "19053" ).


At 07 MAY 2020 02:17PM Andrew McAuley wrote:

It's a conceptual difference. With DEFPROP you don't need to differentiate between the default data property for each control, TEXT vs CHECK vs VALUE etc. Also (and more importantly) when you set TEXT it updates the TEXT/DEFPROP property but the system doesn't behave as though it were changed so won't for example, warn you if you attempt to leave the window immediately without saving (as the system thinks nothing has changed). When you set the DEFPROP property the system registers the change.

The Sprezzatura Group

The Sprezzatura Blog

World leaders in all things RevSoft

View this thread on the Works forum...

  • third_party_content/community/commentary/forums_works/de1a0f98e3b16e4f9c1962c4fda5a2fb.txt
  • Last modified: 2023/12/30 11:57
  • by 127.0.0.1