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 19 SEP 2001 10:10:07AM Rick Todd wrote:

I have been trying to use the default of an editline. I would like to call a stored procedure, that I created. I would like the stored procedure to use data that was entered from a previous editline. To see how it works I created a form called TEST1 with two editlines, FIELD1 and FIELD2 and a stored procedure called DEFAULT_TEMP. The stored procedure DEFAULT_TEMP look like;

SUBROUTINE DEFAULT_TEMP(DATA)

DECLARE FUNCTION MSG

X=MSG(@WINDOW,DATA,"")

RETURN

In the editline on FIELD2 for the default I put DEFAULT_TEMP("XXX") thinking that the "XXX" would be passed as a literal. I tried it with quotes, without quotes, with brackets, but it does not work I get a looping error that requires me to reboot the computer.

I know that the example is FUNCNAME( 'arg1',2,'arg3',3 ) but I have been unable to get it to work. So, does anyone see what I am doing wrong?

Thanks

Rick


At 19 SEP 2001 10:45AM Oystein Reigem wrote:

Rick,

I think in my own app I've only used FUNCNAME('') with an empty parameter. But why on earth do you want to pass the function a parameter?

If what you think of is to get the value from a different control in your form let your function do a

Value=Get_Property( @Window:".THATOTHERCTRL", "TEXT" )

or something.

- Oystein -


At 19 SEP 2001 12:14PM Alun Hutchings wrote:

If it is of any help I programatically set default values retrieved from a lookup table by setting the default property of an edit line to DEFAULT('key') where DEFAULT is the following program and key is the key to the row I want to retrieve.

Compile Subroutine Default(row)

Declare Subroutine Msg, Set_Property

open 'VOCABULARY' to filevar else

msg(@window,"Can't open ":file)

Return

end

readv deflt from filevar, row, 2 else null

Return deflt


At 19 SEP 2001 12:51PM Donald Bakke wrote:

Rick,

Your first problem is that the routine must be a function and not a subroutine. The return value is what will appear in the edit control as your default.

You can pass literal values, but use single quotes. We tend to create a single function for an entire form and use the FOCUS property to branch to the specific default logic for each form. This is kind of a commuter module for defaults.

dbakke@srpcs.com

SRP Computer Solutions, Inc.


At 19 SEP 2001 09:29PM Rick Todd wrote:

You are correct. Changing the SUBROUTINE to FUNCTION solved the problem. I also learned that it is impossible to use double quotes. Even if you type in double quotes when you exit the control OI converts them to single quotes.

I'll have to play with the FOCUS property.

Thanks very much.

Rick


At 19 SEP 2001 09:36PM Rick Todd wrote:

I too, what to use the default to lookup the a value from another table based on data in this table. I created a subroutine in AREV tens years ago to search for zip codes using a BTREE index. I now am trying to convert that subroutine to OI.

Thanks

Rick


At 19 SEP 2001 10:03PM Rick Todd wrote:

Oystein,

"But why on earth do you want to pass the function a parameter?" you ask.

My goal was to have a stored procedure that searchs for a matching zip code based on the city and state, and enter it into a zip field as the default value. Now, I don't want to have to create a separate script for each zip code in every form of the application. And, the only things that are different from one table to another are the field names. Such as, BILLING_CITY, SHIPPING_CITY, FATHER_CITY, CITY, etc. So, if I have a function that passes the names of the city and state fields, when it is called, I can use one function for all searchs.

Sounds, simply huh? I used the same concept in AREV many years ago. I'm just trying to convert it to OI.

Thanks

Rick


At 20 SEP 2001 07:27AM Oystein Reigem wrote:

Rick,

As far as I understand you can only have a constant as a parameter to your default function. E.g,

DEFAULT_TEMP('XXX')

I thought what you wanted was to feed it some variable thing, like the value of a field, or the property of a different control. If so you must let the function itself retrieve the value.

It would have been nice, of course, if one could do stuff like

DEFAULT_TEMP(@WINDOW.SOMEOTHERFIELD)

DEFAULT_TEMP({SOMEOTHERFIELD})

DEFAULT_TEMP(@USER0)

… etc …

- Oystein -

View this thread on the Works forum...

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