dbTalk Databases Forums  

new window calculation

comp.databases.filemaker comp.databases.filemaker


Discuss new window calculation in the comp.databases.filemaker forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
pri
 
Posts: n/a

Default new window calculation - 06-30-2005 , 04:00 PM






hi all,

i'm trying to use the button featre where it opens a related record in
a new window from an existing portal. So right now the feature works,
where i have checked off the appropriate table and layout and checked
off "show in new window". But the problem is that in the protal if i
use he button, each time it opens a new window. I dont want multiple
windows to open, just one NEW window to open and then that one being
used to show the records. I have other places to use the patternmatch
funtion with the window name but i need more specifics. Basically i
want the following to happen:

IF (windowA is already open)
THEN (open related record in windowA)
ELSE (open new window named windowA with related record)

thanks for help.


Reply With Quote
  #2  
Old   
Dan
 
Posts: n/a

Default Re: new window calculation - 06-30-2005 , 04:38 PM






Hello pri,

I have done a similar thing where I pass a parameter to the script on the
button which is the name of the window AND the name of the layout that I
want to use. I have then set up a little subscript which I call to check
whether the window is already open and if not then open it. You can modify
this to suit your needs.

Select Window[Name: Get(ScriptParameter)]
If[Get(WindowName) =/ Get(ScriptParameter)] -- =/ is not equals
New Window[Name:Get(ScriptParameter)]
Go To Layout[Get(ScriptParameter)]
End If
Go to Layout[Get(ScriptParameter)]

If you do not want to use the same name for the Window and the Layout then
you can pass both and parse them out of the ScriptParameter

Quote:
hi all,

i'm trying to use the button featre where it opens a related record in
a new window from an existing portal. So right now the feature works,
where i have checked off the appropriate table and layout and checked
off "show in new window". But the problem is that in the protal if i
use he button, each time it opens a new window. I dont want multiple
windows to open, just one NEW window to open and then that one being
used to show the records. I have other places to use the patternmatch
funtion with the window name but i need more specifics. Basically i
want the following to happen:

IF (windowA is already open)
THEN (open related record in windowA)
ELSE (open new window named windowA with related record)
thanks for help.





Reply With Quote
  #3  
Old   
Michael Myett
 
Posts: n/a

Default Re: new window calculation - 06-30-2005 , 10:41 PM



pri wrote:
Quote:
hi all,

i'm trying to use the button featre where it opens a related record in
a new window from an existing portal. So right now the feature works,
where i have checked off the appropriate table and layout and checked
off "show in new window". But the problem is that in the protal if i
use he button, each time it opens a new window. I dont want multiple
windows to open, just one NEW window to open and then that one being
used to show the records. I have other places to use the patternmatch
funtion with the window name but i need more specifics. Basically i
want the following to happen:

IF (windowA is already open)
THEN (open related record in windowA)
ELSE (open new window named windowA with related record)

thanks for help.

You need to test to see if an instance of the window is already open, if
not, open one. Try a variation of the following script.

Select Window [ Name: "windowA" ]
If [ Get ( LastError ) â‰* 0 ]
New Window [ Name: "windowA"; Height: 318; Width: 406; Top: ((Get (
WindowDesktopHeight ) - Get ( WindowHeight )) / 2) - 50; Left:
(Get ( WindowDesktopWidth ) - Get ( WindowWidth )) / 2 ]
Go to Layout [ "anyLayout" ]
Show/Hide Status Area
[ Lock; Hide ]
End If

Michael Myett


Reply With Quote
  #4  
Old   
Matt Wills
 
Posts: n/a

Default Re: new window calculation - 07-01-2005 , 07:34 AM



Michael Myett wrote:

Quote:
You need to test to see if an instance of the window is already open, if
not, open one. Try a variation of the following script.

Select Window [ Name: "windowA" ]
If [ Get ( LastError ) â‰* 0 ]
New Window [ Name: "windowA"; Height: 318; Width: 406; Top: ((Get (
WindowDesktopHeight ) - Get ( WindowHeight )) / 2) - 50; Left:
(Get ( WindowDesktopWidth ) - Get ( WindowWidth )) / 2 ]
Go to Layout [ "anyLayout" ]
Show/Hide Status Area
[ Lock; Hide ]
End If

Michael Myett
Michael:

I saw this as an improvement on what I had come up with and sought to
implement it.

As a test, I scripted

Select window [ Name: "WindowA" ]
If [ Get ( LastError ) â‰* 0 ]
Show custom dialog [ Get (LastError) ]
End If

The Custom Dialog displays "0".

No, wait. It was supposed to be if it DIDN'T equal zero. So why did it trap?

So I tried

Select window [ Name: "WindowA" ]
Show custom dialog [ Get (LastError) ]

and the Custom Dialog displayed "112" (Window is Missing)

Then I tried

Select window [ Name: "WindowA" ]
If [ Get ( LastError ) = 112 ]
Show custom dialog [ Get (LastError) ]
End If

The Custom Dialog is displayed, but it still shows "0".

Obviously, the technique does work either way (and I certainly won't
include the Custom Dialog in the finished product) but I am curious as to
why, if the error is 112, does it show up as a "0" in the custom dialog?

Matt


Reply With Quote
  #5  
Old   
Dan
 
Posts: n/a

Default Re: new window calculation - 07-01-2005 , 08:44 AM



Hello Matt,

I guess the LastError dynamically updates everytime you perform a script
step so if you Get it and then perform a valid step it reverts to 0 when
you Get it again.

Quote:
Michael Myett wrote:

You need to test to see if an instance of the window is already open,
if not, open one. Try a variation of the following script.

Select Window [ Name: "windowA" ]
If [ Get ( LastError ) ? 0 ]
New Window [ Name: "windowA"; Height: 318; Width: 406; Top: ((Get (
WindowDesktopHeight ) - Get ( WindowHeight )) / 2) - 50; Left:
(Get ( WindowDesktopWidth ) - Get ( WindowWidth )) / 2 ]
Go to Layout [ "anyLayout" ]
Show/Hide Status Area
[ Lock; Hide ]
End If
Michael Myett

Michael:

I saw this as an improvement on what I had come up with and sought to
implement it.

As a test, I scripted

Select window [ Name: "WindowA" ]
If [ Get ( LastError ) ? 0 ]
Show custom dialog [ Get (LastError) ]
End If
The Custom Dialog displays "0".

No, wait. It was supposed to be if it DIDN'T equal zero. So why did it
trap?

So I tried

Select window [ Name: "WindowA" ]
Show custom dialog [ Get (LastError) ]
and the Custom Dialog displayed "112" (Window is Missing)

Then I tried

Select window [ Name: "WindowA" ]
If [ Get ( LastError ) = 112 ]
Show custom dialog [ Get (LastError) ]
End If
The Custom Dialog is displayed, but it still shows "0".

Obviously, the technique does work either way (and I certainly won't
include the Custom Dialog in the finished product) but I am curious as
to why, if the error is 112, does it show up as a "0" in the custom
dialog?

Matt





Reply With Quote
  #6  
Old   
Michael Myett
 
Posts: n/a

Default Re: new window calculation - 07-01-2005 , 08:54 AM



Matt Wills wrote:
Quote:
Michael Myett wrote:

You need to test to see if an instance of the window is already open,
if not, open one. Try a variation of the following script.

Select Window [ Name: "windowA" ]
If [ Get ( LastError ) â‰* 0 ]
New Window [ Name: "windowA"; Height: 318; Width: 406; Top: ((Get (
WindowDesktopHeight ) - Get ( WindowHeight )) / 2) - 50; Left:
(Get ( WindowDesktopWidth ) - Get ( WindowWidth )) / 2 ]
Go to Layout [ "anyLayout" ]
Show/Hide Status Area
[ Lock; Hide ]
End If

Michael Myett


Michael:

I saw this as an improvement on what I had come up with and sought to
implement it.

As a test, I scripted

Select window [ Name: "WindowA" ]
If [ Get ( LastError ) â‰* 0 ]
Show custom dialog [ Get (LastError) ]
End If

The Custom Dialog displays "0".

No, wait. It was supposed to be if it DIDN'T equal zero. So why did it
trap?

So I tried

Select window [ Name: "WindowA" ]
Show custom dialog [ Get (LastError) ]

and the Custom Dialog displayed "112" (Window is Missing)

Then I tried

Select window [ Name: "WindowA" ]
If [ Get ( LastError ) = 112 ]
Show custom dialog [ Get (LastError) ]
End If

The Custom Dialog is displayed, but it still shows "0".

Obviously, the technique does work either way (and I certainly won't
include the Custom Dialog in the finished product) but I am curious as
to why, if the error is 112, does it show up as a "0" in the custom dialog?

Matt
Perhaps the "If [ Get ( LastError ) = 112 ]" script step sets the error
number to zero? I'm not really sure. So I tried the following script.

First create a global number field, gError, to trap the last error number.

Select Window [ Name: "windowA" ]
Set Field [ anyTable::gError; Get ( LastError ) ]
If [ The Deal::gError â‰* 0 ]
Show Custom Dialog [ Title: "Error ..."; Message: The Deal::gError;
Buttons: "OK" ]
New Window [ Name: "windowA"; Height: 193; Width: 148; Top: 205; Left: 205 ]
Go to Layout [ "anyTable" (anyLayout) ]
Show/Hide Status Area
[ Hide ]
Set Field [ anyTable::gOrigin; Get ( ScriptParameter ) ]
End If

This seems to behave as expected.

Michael Myett


Reply With Quote
  #7  
Old   
pri
 
Posts: n/a

Default Re: new window calculation - 07-01-2005 , 09:15 AM



thanks guys, the script works like i wanted. but i have another
problem. since i am using the script inside a portal, after i click the
button the window always shows the first record from the portal. I
think once the script is initiated and the Select Window function runs,
FMP7 loses track of which row of the related record to use, and so it
goes to the first related record, instead of the related record of that
row. Any ideas?
thanks again


Reply With Quote
  #8  
Old   
Matt Wills
 
Posts: n/a

Default Re: new window calculation - 07-01-2005 , 09:47 AM





Michael Myett wrote:

Quote:
Perhaps the "If [ Get ( LastError ) = 112 ]" script step sets the error
number to zero? I'm not really sure. So I tried the following script.

First create a global number field, gError, to trap the last error number.

Select Window [ Name: "windowA" ]
Set Field [ anyTable::gError; Get ( LastError ) ]
If [ The Deal::gError â‰* 0 ]
Show Custom Dialog [ Title: "Error ..."; Message: The Deal::gError;
Buttons: "OK" ]
New Window [ Name: "windowA"; Height: 193; Width: 148; Top: 205; Left: 205
]
Go to Layout [ "anyTable" (anyLayout) ]
Show/Hide Status Area
[ Hide ]
Set Field [ anyTable::gOrigin; Get ( ScriptParameter ) ]
End If

This seems to behave as expected.

Michael Myett
I think you and Dan both came up with what I was thinking.

The value of Get ( LastError ) results from the last script step that
calls it.

Thus,

Select Window [non-existent Window ] generates a 112
If [ Get ( LastError <> 0 ] is thus true, and the Custom Dialog (or
opening a new window) step is executed.
Now, there is no longer an error, so the CD shows the last error as 0.

That's why the If works, but the CD suggests it shouldn't have worked.

The case, she is sol-ved (Clousseau)

Matt


Reply With Quote
  #9  
Old   
Matt Wills
 
Posts: n/a

Default Re: new window calculation - 07-01-2005 , 10:06 AM





pri wrote:

Quote:
thanks guys, the script works like i wanted. but i have another
problem. since i am using the script inside a portal, after i click the
button the window always shows the first record from the portal. I
think once the script is initiated and the Select Window function runs,
FMP7 loses track of which row of the related record to use, and so it
goes to the first related record, instead of the related record of that
row. Any ideas?
thanks again
Doesn't sound to me like the button is inside the portal.

If the button is inside a portal, then it appears on each row. There would
be no question as to which related record it goes to.

If you have the script executed from elsewhere, there's no way it would
know which related record you want.

Matt


Reply With Quote
  #10  
Old   
pri
 
Posts: n/a

Default Re: new window calculation - 07-01-2005 , 10:28 AM



I'm not sure if i was clear, but i have placed the button inside the
portal and a script is executed to open a new window. But still the
related record that opens is the first one, not the record in the row
the button was clicked.

If i dont use a script on the button and just the function :
GoToRelatedRecord and then specify the table and layout, a new window
opens with the correct record showing. But a new window opens for each
record i click on. I want to just have one new window to open and
change the record in that new window each time. With the script i can
acheive the one new window feature but it only opens the first record
from the portal.

Hope this is better.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.