How to choose the dialog to open

forum.td.development (2005-2010)
G G

How to choose the dialog to open

Post by G G » 04 Mar 2009, 17:30

 Posted by:  G G 

Hi to all.
I need a little help to do this. I have a program with some dialogs. If a
customer wants same data but in a different behaviour, I must duplicate the
program to change it. I would do this: store in the database the name of the
standard dialog with the name of the alternative one (if needed). So when I
open the standard dialog, if there is an alternative, close the first and
open the second. I can do this but parameters cannot be passed, because I
use the name of the dlg to open as a string.
This is the function
fNewDialog
Parameters
String: sDialog
Call SqlPrepareAndExecute( hSqlImmediate, 'select dlg_alternativa, fg_mode
from t_dialogs
where dlg_main=:sDialog into :sNewDialog, :OpenMode' )
Call SqlFetchNext( hSqlImmediate, nRet )
If nRet=FETCH_EOF
Return FALSE
Else
Return TRUE

where OpenMode is used to see if opend the dialog with SalModalDialog o with
SalCreateWindow.

Then, with

On SAM_Create
If fNewDlg('dlgDettNomi')
Call SalPostMsg( pbExit, SAM_Click, 0, 0 )
Call SalCreateWindow( sNewDialog, hWndForm, hWndForm, fg_clifor)

I try to close the first dlg and open the second but with errors.
Any hint?
Thank you.

----------------------------------
Gigi
----------------------------------

Jim McNamara

How to choose the dialog to open

Post by Jim McNamara » 04 Mar 2009, 21:50

 Posted by:  Jim McNamara 

Do some homework and experiment with SalCompileAndEvaluate(...)

Christof Helm

How to choose the dialog to open

Post by Christof Helm » 05 Mar 2009, 08:21

 Posted by:  Christof Helm 


Gigi, isn't it possible to evaluate the dialog to be used *before*
opening the standard dialog?
IMHO it is not a good idea to do this in the SAM_Create Handler of the
window to be replaced.

hth,
Christof

Dmytro G

How to choose the dialog to open

Post by Dmytro G » 05 Mar 2009, 09:28

 Posted by:  Dmytro G 

As Jim says about homework and SalCompileAndEvaluate. Absolutely right.

In such cases when one user wants something and the other one wants the same
but slightly different, SalCompileAndEvaluate can do a great job!

Somehow I faced the same problem. What I did, I wrote a function based on
SalCompileAndEvaluate.

Those func can be called recursively and does interpretation of indented SAL
text-code. So I had

possibility to save in database the entire passages of SAL codes different
for different users.

For example if there is a button and there are two users. The one wants one
dialog and the other - different one when pushing this button. Well, On
SAM_Click of button you place Call to this function, and the function
executes the SAL code witch is in database - proper for each user.

If this approach is interesting I am ready to give a hand to anybody and
share my experience.

Regards,

Dmytro G.

G G

How to choose the dialog to open

Post by G G » 05 Mar 2009, 09:58

 Posted by:  G G 

Ok, thanks to all. This seems to be the right way.

G G

How to choose the dialog to open

Post by G G » 05 Mar 2009, 10:16

 Posted by:  G G 

Hi Dmytro, so you use this function instead of Call SalModalDialog, before
opening the window?

Dmytro G

How to choose the dialog to open

Post by Dmytro G » 05 Mar 2009, 10:29

 Posted by:  Dmytro G 

No. In a most simple way, under the button, On SAM_Click, you Call
SalCompileAndEvaluate.
And pass to SalCompileAndEvaluate string parameter which contains "Call
SalModalDialog"..or whatever... But remember this have to be only one line
(we are talking abous simplest implementation).
I think, needless to say that strings that you pass to SalC&E() can be saved
in database and retrieved
properly before calling to SalC&E().

Regards.

G G

How to choose the dialog to open

Post by G G » 05 Mar 2009, 11:09

 Posted by:  G G 

Like this?

--------------------------------
!!CB!! 129
Set sContext=SalContextCurrent( )
Call fNewDlg( 'dlgDettNomi')

!!CB!! 134
Function: fNewDlg
Description:
Returns
Parameters
String: sDialog
Static Variables
Local variables
Number: nError
Number: nPosition
Actions
Call SqlPrepareAndExecute( hSqlImmediate, 'select dlg_alternativa, fg_modo
from t_dialogs
where dlg_main=:sDialog into :sNewDialog, :ModoOpen' )
Call SqlFetchNext( hSqlImmediate, nRet )
Set sContext=SalContextCurrent( )
If nRet=FETCH_EOF
Return FALSE
Else
Call SalCompileAndEvaluate( sNewDialog, nError, nPosition, nTemp, sTemp,
dtTemp, hWndNew, TRUE, sContext )
Return TRUE
-----------------------------

I get sNewDialog from D.B. that contains 'Call SalCreateWindow(dlgDettNomi2,
hWndForm, hWndForm, fg_clifor)' but I get an error 3120 Illegal Symbol at
position 4.
Sorry if I am boring you, but I never used this Sal Function. It seems very
useful and I would understand its use.

Dmytro G

How to choose the dialog to open

Post by Dmytro G » 05 Mar 2009, 11:39

 Posted by:  Dmytro G 

Please find attached little example. It will help you to understand what to
do.
Note, the first param of SalC&E() you have to store in DB - unique for each
user.

A bit latter I will find and prepare example of the said recursive func and
I will post it in the newsgroup.

Regards, Dmytro

Attachment: TestSalCompileAndEvaluate.apt

G G

How to choose the dialog to open

Post by G G » 06 Mar 2009, 11:27

 Posted by:  G G 

YESSS, Dmytro, it runs!
I removed the 'Call' word from the command to evaluate (of course) and my
window starts.
Great! Thank to all.

Beer payed.

Return to “td.development”

Who is online

Users browsing this forum: [Ccbot] and 0 guests