how to fix the macro to save file?
Hi guys, I wrote a macro for saving file, but when I click the button, an error message is displayed. How can I fix it? Thank you!
The code of the macro:
*beginmacro(macrosave) *writefile 'D:/Documents/temp.hm' 1 *answer(yes) *endmacro() *createbutton(5, 'Save File', 20, 0, 10, GREEN, 'Save file', 'macrosave')
The error message:
Answers
-
Hi @Hao Jiang To save file use only this command:
*writefile 'C:/Users/ABCD/Desktop/a11.hm' 1
0 -
Hi Jouher, only *writefile can work, but I want to create a button, when the button is clicked, macro is called.
0 -
@Hao Jiang Please write command : *writefile 'C:/Users/ABCD/Desktop/a11.hm' 1 in separate tcl file and save.
go to userpage.mac file: there you add *createbutton. This will work.
0 -
Altair Forum User said:
@Hao Jiang Please write command : *writefile 'C:/Users/ABCD/Desktop/a11.hm' 1 in separate tcl file and save.
go to userpage.mac file: there you add *createbutton. This will work.
Thanks, Jouher, it work. However, how can I call a macro by click a button?
0 -
in the userpage.mac file add command in this way. then reload hm and go to utility users.
*createbutton(5, 'Name to be displayed on button', 0, 0, 10, BLUE, '',EvalTcl,'Path\Macroname.tcl')
0 -
Hi,
You have to pass parameters, separated by commas and enclosed in parentheses:
*writefile('D:/Documents/temp.hm', 1)
0 -
Altair Forum User said:
in the userpage.mac file add command in this way. then reload hm and go to utility users.
*createbutton(5, 'Name to be displayed on button', 0, 0, 10, BLUE, '',EvalTcl,'Path\Macroname.tcl')
Thank you Jouher, it work. And I test some times, following coad is work:
*beginmacro('macrosave') *writefile(D:\Documents\temp.hm, 1) *answer(yes) *endmacro()
Although syntax of “*answer” is 'answer yes', but it doesn't work. When I use '*answer(yes)', it work. I don't know why.
0 -
Altair Forum User said:
Hi,
You have to pass parameters, separated by commas and enclosed in parentheses:
*writefile('D:/Documents/temp.hm', 1)
Thank you akitoguc, I found that in .tcl file, '*writefile('D:/Documents/temp.hm', 1)' doesn't work, but '*writefile 'D:/Documents/temp.hm' 1 ' work, Is it because the TCL file and the MAC file are different?
0 -
You are right, Hao.
Syntax to call a command/procedure with parameters is different between Tcl file and command file. Take parentheses and commans away from Tcl statements to port the code to command file.
Regards,
0