new window calculation

  • Follow


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.

0
Reply priyankc (17) 6/30/2005 9:00:54 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

> 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.
> 



0
Reply Dan 6/30/2005 9:38:59 PM


pri wrote:
> 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
0
Reply Michael 7/1/2005 3:41:56 AM

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
0
Reply Matt 7/1/2005 12:34:35 PM

Matt Wills wrote:
> 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
0
Reply Michael 7/1/2005 1:54:40 PM

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

0
Reply pri 7/1/2005 2:15:08 PM


Michael Myett wrote:

>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
0
Reply Matt 7/1/2005 2:47:40 PM


pri wrote:

>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
0
Reply Matt 7/1/2005 3:06:06 PM

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.

0
Reply pri 7/1/2005 3:28:28 PM

8 Replies
138 Views

(page loaded in 0.197 seconds)

Similiar Articles:













7/9/2012 11:43:07 PM


Reply: