[CLOSED] how do I pass dialog variables in a macro to

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
Patrick Le Derff
Newbie
Posts: 7
Joined: Thu Sep 06, 2007 10:00 am

[CLOSED] how do I pass dialog variables in a macro to

Post by Patrick Le Derff » Thu Sep 06, 2007 12:12 pm

MacroOne

Dialog>Dialog1
Caption=Notice
Width=445
Height=250
Top=104
Left=16
Edit=FileName,80,72,121,FilSeqCustomers
Button=OK,356,80,75,25,0
EndDialog>Dialog1

Show>dialog1,r

IfFileExists>msEdit1,existe,nexistepas
label>existe
MessageModal>"File exists"
DeleteFile>msEdit1
goto>fin
Label>nexistepas
MessageModal>"File not found"
Label>Fin




I want to use this macro below in BATCH like


MacroTwo

Macro>MacroOne.scp /FileName=NewFile




MacroTwo fails. How can I pass the value to the defined dialog variable?
Or other solution?

Thank you
Last edited by Patrick Le Derff on Fri Sep 07, 2007 7:55 am, edited 1 time in total.
MacroScheduler 9 1 04e
Evaluating the product

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Thu Sep 06, 2007 1:25 pm

You mean:

Macro>%SCRIPT_DIR%\MacroOne.scp /FilSeqCustomers=NewFile

If MacroOne.scp is in a different folder to the calling macro replaces %SCRIPT_DIR% with the path.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Thu Sep 06, 2007 1:30 pm

There are multiple syntax errors
try this and compare the code with yours to see the changes

Macro>[drive]:\[path]\MacroOne.scp /FileName=NewFile

Code: Select all

//Assigned checks to see if text string "filename"
//has a value and is therefore a variable
Assigned>filename,result

//If filename is a variable put its value in
//the edit box to look at it
If>result=TRUE
  Dialog>Dialog1
    Caption=Notice
    Width=445
    Height=250
    Top=104
    Left=16
    Edit=msEdit1,80,72,121,%filename%
    Button=OK,356,80,75,25,3
  EndDialog>Dialog1

  Show>dialog1,r

//if the value of filename is a valid existing file
//delete it,  if not, report that filename does not exist
  IfFileExists>dialog1.msEdit1,existe,nexistepas
    label>existe
      MessageModal>File %filename% exists
      DeleteFile>%dialog1.msEdit1%
      goto>Fin
    Label>nexistepas
      MessageModal>File %filename% not found
    Label>Fin
  EndIf

Else
MessageModal>No File specified
EndIf

Patrick Le Derff
Newbie
Posts: 7
Joined: Thu Sep 06, 2007 10:00 am

Post by Patrick Le Derff » Thu Sep 06, 2007 1:53 pm

both macros are in the same directory but in different file.
With the first macro (MacroOne it is a sample) I want to delete a file if exists. I run the macro and i fill the field and it works.

In the second macro I want to run the first macro without displaying the dialog but to pass the parameters directly

Excuse for my english but I am connected from France
Do You understand what I wannt to do?

rgds
MacroScheduler 9 1 04e
Evaluating the product

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Thu Sep 06, 2007 2:04 pm

So I think you want:

Code: Select all

//Assigned checks to see if text string "filename"
//has a value and is therefore a variable
Assigned>filename,result

//Do we have a filename or not
If>result=TRUE
  Let>thefile=filename
Else
  //no filename passed, so display a dialog to request it
  Dialog>Dialog1
    Caption=Notice
    Width=316
    Height=152
    Top=226
    Left=155
    Edit=msEdit1,24,24,177,
    Button=OK,108,72,75,25,3
    Button=Browse,208,24,75,25,0
	FileBrowse=Browse,msEdit1
  EndDialog>Dialog1

  Show>dialog1,r
  Let>thefile=dialog1.msEdit1
Endif

//if the value of filename is a valid existing file
//delete it,  if not, report that filename does not exist
IfFileExists>thefile,existe,nexistepas
  label>existe
    MessageModal>File %thefile% exists
    DeleteFile>%thefile%
    goto>Fin
  Label>nexistepas
    MessageModal>File %thefile% not found
  Label>Fin
EndIf
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Patrick Le Derff
Newbie
Posts: 7
Joined: Thu Sep 06, 2007 10:00 am

Post by Patrick Le Derff » Thu Sep 06, 2007 2:18 pm

What can I do to post reply in the same subject.
I had click on PostReply button. I fill up my reply and click on Submit button

Regards
MacroScheduler 9 1 04e
Evaluating the product

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Thu Sep 06, 2007 2:25 pm

Just hit Post Reply, write your message and hit Submit. You don't need to enter anything in the Subject. Just like you have just done.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Patrick Le Derff
Newbie
Posts: 7
Joined: Thu Sep 06, 2007 10:00 am

Post by Patrick Le Derff » Thu Sep 06, 2007 2:58 pm

Thank you

must I post again my earlier message?

Regards
MacroScheduler 9 1 04e
Evaluating the product

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Thu Sep 06, 2007 3:00 pm

What earlier message? Did we miss something?
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Patrick Le Derff
Newbie
Posts: 7
Joined: Thu Sep 06, 2007 10:00 am

Post by Patrick Le Derff » Thu Sep 06, 2007 3:18 pm

Not at all!
apologies!

Rgds
MacroScheduler 9 1 04e
Evaluating the product

Patrick Le Derff
Newbie
Posts: 7
Joined: Thu Sep 06, 2007 10:00 am

Post by Patrick Le Derff » Fri Sep 07, 2007 7:31 am

Good morning,

Macro>%SCRIPT_DIR%\MacroOne.scp /FilSeqCustomers=NewFile

your reply works partially.
The new value is passed correctly to MacroOne, but the dialog box is displayed. How can I by-pass the interactive box?

Regards
MacroScheduler 9 1 04e
Evaluating the product

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri Sep 07, 2007 7:34 am

The new variable is filename. Use this code:

Code: Select all

//Assigned checks to see if text string "filename"
//has a value and is therefore a variable
Assigned>filename,result

//Do we have a filename or not
If>result=TRUE
  Let>thefile=filename
Else
  //no filename passed, so display a dialog to request it
  Dialog>Dialog1
    Caption=Notice
    Width=316
    Height=152
    Top=226
    Left=155
    Edit=msEdit1,24,24,177,
    Button=OK,108,72,75,25,3
    Button=Browse,208,24,75,25,0
	FileBrowse=Browse,msEdit1
  EndDialog>Dialog1

  Show>dialog1,r
  Let>thefile=dialog1.msEdit1
Endif

//if the value of filename is a valid existing file
//delete it,  if not, report that filename does not exist
IfFileExists>thefile,existe,nexistepas
  label>existe
    MessageModal>File %thefile% exists
    DeleteFile>%thefile%
    goto>Fin
  Label>nexistepas
    MessageModal>File %thefile% not found
  Label>Fin
EndIf
Call it with:

Macro>%SCRIPT_DIR%\MacroOne.scp /filename=c:\bla\somefile.fil

Note the very first line of the script above checks to see if filename is assigned. If not it shows the dialog. If it is it ignores the dialog.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Patrick Le Derff
Newbie
Posts: 7
Joined: Thu Sep 06, 2007 10:00 am

Post by Patrick Le Derff » Fri Sep 07, 2007 7:53 am

Thank you for your effective support. I understood how it works
Regards
MacroScheduler 9 1 04e
Evaluating the product

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts