🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

how to fix the macro to save file?

User: "Altair Forum User"
Altair Employee
Updated by Altair Forum User

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:

 

image.png.f02f9a67cc5a054a28d61099962e951d.png

 

Find more posts tagged with

Sort by:
1 - 9 of 91
    User: "Jouher_20929"
    Altair Community Member
    Updated by Jouher_20929

    Hi @Hao Jiang To save file use only this command:

    *writefile 'C:/Users/ABCD/Desktop/a11.hm' 1

    User: "Altair Forum User"
    Altair Employee
    OP
    Updated by Altair Forum User

    Hi Jouher, only *writefile can work, but I want to create a button, when the button is clicked, macro is called.

    User: "Jouher_20929"
    Altair Community Member
    Updated by Jouher_20929

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

    User: "Altair Forum User"
    Altair Employee
    OP
    Updated by Altair Forum User

    @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?

    User: "Jouher_20929"
    Altair Community Member
    Updated by Jouher_20929

    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')

     

    User: "Altair Forum User"
    Altair Employee
    OP
    Updated by Altair Forum User

    Hi,

    You have to pass parameters, separated by commas and enclosed in parentheses:

     *writefile('D:/Documents/temp.hm', 1) 

     

    User: "Altair Forum User"
    Altair Employee
    OP
    Updated by Altair Forum User

    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.

     

    User: "Altair Forum User"
    Altair Employee
    OP
    Updated by Altair Forum User

    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?

    User: "Altair Forum User"
    Altair Employee
    OP
    Updated by Altair Forum User

    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,