Run Post

From Macros Wiki
Jump to: navigation, search
!    Set post parameters, prompt user for post and
!    run the post to create code
 
a1$ = "This macro will prompt for a post, set some"
a2$ = "post parameters and run the post to create code"
 
message "%a1$\n%a2$"
 
check part_open, "You must have a part open to run this macro"
 
!    create a file open dialog and get post filename
!    -----------------------------------------------
 
file_dialog_new "Select Post"
file_dialog_extension "Post files (*.pst)", "pst"
file_dialog_show open, post_file$
 
!    create a file save dialog and get code filename
!    -----------------------------------------------
 
file_dialog_new "Post Output File"
file_dialog_extension "All files (*.*)", "*"
file_dialog_show open, output_file$
 
!    get some post parameters
!    ------------------------
 
get_post_data, start_prog_num, post_start_prog_num
get_post_data, seq_from, post_seq_from
get_post_data, seq_by, post_seq_by
 
a$ = "Original Post Parameters\n"
 
b$ = "Start Program Number = " + format$(post_start_prog_num, "#####0")
a$ = a$ + "\n" + b$
 
b$ = "Sequence From = " + format$(post_seq_from, "#####0")
a$ = a$ + "\n" + b$
 
b$ = "Sequence By = " + format$(post_seq_by, "#####0")
a$ = a$ + "\n" + b$
 
!    change these post parameters
!    ----------------------------
 
set_post_data, start_prog_num, 1234
set_post_data, seq_from, 12
set_post_data, seq_by, 15
 
!    get them again, to show they have been changed
!    ----------------------------------------------
 
get_post_data, start_prog_num, post_start_prog_num
get_post_data, seq_from, post_seq_from
get_post_data, seq_by, post_seq_by
 
b$ = "New Post Parameters\n"
a$ = a$ + "\n\n" + b$
 
b$ = "Start Program Number = " + format$(post_start_prog_num, "#####0")
a$ = a$ + "\n" + b$
 
b$ = "Sequence From = " + format$(post_seq_from, "#####0")
a$ = a$ + "\n" + b$
 
b$ = "Sequence By = " + format$(post_seq_by, "#####0")
a$ = a$ + "\n" + b$
 
!    run the post
!    ------------
 
a$ = a$ + "\n\nOK to run the post?"
yesno a$, iyesno
if iyesno = 0 then stop "Stopped without running post"
 
set_post_data, post_file, post_file$
set_post_data, output_file, output_file$
 
run_post
 
message "Finished - output file = %output_file$"
 
yesno "View the output ?", iyesno
if iyesno = 0 then stop "Finished"
 
run_exe "\Windows\System32\Notepad.exe", output_file$