Welcome! Log In Create A New Profile

Advanced

Passing Parameters to Windows ...

Posted by Dan M 
Dan M
Passing Parameters to Windows ...
May 31, 2009 08:13PM
This seems basic but I am not getting it so far ...

I have 2 windows

WIN_Companies_table : A Window with a table of all the Companies.
WIN_Company_Form : A Window with a form for the company details

I added a button called View to WIN_Companies_table.

I want to click on the button and open a new window with a form that displays all the details of the record which was highlighted in the table.

So far I have tried many versions but this is where I am so far ...

1. Added this code to the Global Declaration of WIN_Company_Form:

PROCEDURE WIN_Company_Form(company.company_id)

it did not like that so I changed it to ...

PROCEDURE WIN_Company_Form(gCompany_id)


2. Then I added this line to the Initialization of WIN_Company_Form

company.company_id = gCompany_id


3. Then I added this code to the click of the button:

Open (WIN_Company_Form, company.company_id)


I can now click on the button in WIN_Companies_Table and it will open WIN_Company_form but it is blank (does not pull up the data for the selected record)???

I have looked in the WinDev tutorial, the online help, & in RAD examples ....

Is this very basic concept explained anywhere?

Did I miss it? How do I get the proper record to display in the form?

Can someone send me a functional example?

dan dot matis at gmail dot com

Any help ... AGAIN ... very much appreciated ...

Dan


ICI
Re: Passing Parameters to Windows ...
May 31, 2009 08:22PM
From First window on button click:
Open(SecondWindow)
TableDisaplay(TABLE_COMPANY)

You dont need nothing but FileToScreen()
Or better this on initialization code for second window

IF Company..NewRecord = False THEN
FileToScreen()
END

Also Dan. I think you need to read Tutorial very easy.
This question is very simple explained into one of tutorial sections.
I think, something like : "Forms with Data" or similar. winking smiley



Edited 1 time(s). Last edit at 05/31/2009 08:24PM by ICI.
Dan M
Re: Passing Parameters to Windows ...
May 31, 2009 08:38PM
So I changed the code in the button to say :

Open (WIN_Company_Form)
TableDisplay(TABLE_WIN_Companies)

I remove the following code from WIN_Company_form in the Global Declaration of WIN_Company_Form:

PROCEDURE WIN_Company_Form(gCompany_id)

The code in the Initialization of WIN_Company_Form is

IF company..NewRecord = False THEN
FileToScreen()
END


Then I run the program ... The Form comes up blank

? Was I supposed to pass the parameter or am I missing something else??
ICI
Re: Passing Parameters to Windows ...
May 31, 2009 09:32PM
Are you sure you are link editboxes to correct table and fields into analisys
Al
Re: Passing Parameters to Windows ...
June 01, 2009 01:21AM
Hello Dan

I assume you are using the RAD code and I am not familiar with that but in terms of the following section of code

IF company..NewRecord = False THEN
FileToScreen()
END

Use the debugger to test the result of ..newrecord

Another way of managing these type of interactions is to send an explicit value to describe the manner in which the form window opens

e.g. Open(FormWindow,"NEW" ) or "EDIT" or "BROWSE" as the parameter and then there is no confusion as to how the form window is to operate.

If your table is a memory table then you will need to locate the file record before opening the form. The calling table should have the primary key of the company in a hidden column, when the row is selected, hreadseekfirst(company,pkindex,table.pkvalue) and then on exit of the table you would open the form window using either the "Edit" or "Browse" parameter and in the form window use filetoscreen to set up the controls.
For a new record you would open the form window with the "New" Parameter and issue a HReset(Company) to set up a clean record

If it is a file based table then you should be able to go straight to the form with either the "Edit" or "Browse" parameter and use filetoscreen()

Regards
Al


Regards
Al
Dan M
Re: Passing Parameters to Windows ...
June 01, 2009 02:22AM
I am not uusing RAD.


I added "BROWSE" to the Click Button code, so it now looks like this

Open (WIN_Company_Form,"BROWSE")
TableDisplay(TABLE_WIN_Companies)

I now get the following error:

the WIN_Company_Form window expects 0 parameters while 1 parameters is passed

so it seems I am missing something on the receiving side.

I also added the column company_id to the table. I do not know what you mean by hidden column and I was unable to locate anything in the help by searching for hidden column?

The only code I currently have in the WIN_Company_Form is in the Initialize of WIN_Company_Form is

IF company..NewRecord = False THEN
FileToScreen()
END

Where is the BROWSE parameter being accepted?

Is there any documentation on how this process is supposed to occur ... it seems like I am still not getting it.

I appreciate your help and hope you can get me there!!!
Al
Re: Passing Parameters to Windows ...
June 01, 2009 03:47AM
Hello Dan

In the "GUI" editor for a table column you can make a column invisible which "hides" it from view

The calling window could send something like:
Open(CompanyForm,"Browse",CompanyPK)

The receiving window would have
PROCEDURE Form(CallMode="Browse",CallingPK = 0)

The callmode has a default value of "Browse" and the CallingPk has a default value of zero. You can leave the default value out

In the form window:
If CallingPk = 0 and Upper(CallingMode) <> "NEW"
Msg("Incorrect call - Zero primary key on existing record")
close()
// I find these tests useful when I am developing and also later on it can pick up errors if other procedures call this window incorrectly
end

Switch upper(CallingMode)
Case "BROWSE"
//set some controles inactive
Case "EDIT"

CASE "New"
HReset(CompanyFile)
end


Regards
Al

Jimbo
Re: Passing Parameters to Windows ...
June 01, 2009 08:04AM
Quote
ICI
From First window on button click:
Open(SecondWindow)
TableDisaplay(TABLE_COMPANY)

You dont need nothing but FileToScreen()
Or better this on initialization code for second window

IF Company..NewRecord = False THEN
FileToScreen()
END

Also Dan. I think you need to read Tutorial very easy.
This question is very simple explained into one of tutorial sections.
I think, something like : "Forms with Data" or similar. winking smiley



Edited 1 times. Last edit at 05/31/09 08:24PM by ICI.

Yes ICI, the missing link here is knowledge about the fact that the 'HyperFileSQL context' (aka file buffer) is handed over (inherited) to the opened window. So, HyperFileSQL context contains all the record details and therefore, as you say, a simple FileToScreen() will work and show data. It's one one of the clever - but rather rarely mentioned - features of WinDev. Kind regards, Guenter
Dan M
Re: Passing Parameters to Windows ...
June 01, 2009 08:40AM
Al,

Thank you for following up with me ...

I still have not seen it work, yet.

I am getting an error on CompanyPK

'CompanyPK' identifier is unknown or inaccessible: to access an element beyond scope, use an EXTERN declaration.

In reference to the part below where you mention "In the form window". Should this be placed in the Initialization section where I have placed :

IF company..NewRecord = False THEN
FileToScreen()
END

.. and if so, should it be before or after this code?
.. if not ... where

In the form window:
If CallingPk = 0 and Upper(CallingMode) <> "NEW"
Msg("Incorrect call - Zero primary key on existing record")
close()
// I find these tests useful when I am developing and also later on it can pick up errors if other procedures call this window incorrectly
end

Switch upper(CallingMode)
Case "BROWSE"
//set some controles inactive
Case "EDIT"

CASE "New"
HReset(CompanyFile)
end

Thanks ... Dan
Jimbo
Re: Passing Parameters to Windows ...
June 01, 2009 09:51AM
Hi Dan, just my 2 cents here: reading your postings tells me that you should deepen your knowledge of a) Windows programming in general and b) of WinDev.

Do the following:
- build a small analysis of three or four files. Like Person, Phone, Group of persons.
- do a full application RAD with the old but proven Windev 11-RAD
- use HyperFileSQL, 'Procedural' and H-commands for generation

Try to read / understand the generated RAD code. Many of your doubts and questions will be answered. If anything is unclear, we will help and provide you with explanations. 11-RAD needs some additions if used for real-world programs, but in principle it works fine.

Kind regards,
Guenter
Dan M
Re: Passing Parameters to Windows ...
June 01, 2009 11:31AM
Guenter,

Thank you for your 2 cents.

I have started to build the small application using 11-RAD and will do my studying.

When you mention "Windows Programming in General" can you suggest or recommend anything specific (web or book).

Again, Thank you !

Regards,
Dan
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: