Notifications
Clear all

[Closed] Basic little question

i have made a .ms file of all the macros my main script need in it i wrote 3 functions each containing a macro definition

now i want this file to be imported into my main script ( without evaluating because that will install all 3 macros )
i want to only install the macro i need by calling its function without the rest

unfortuantely both include and filein commands evaluate the code
so whatever i do i always end up having all my macros installed at startup

is there any way to achieve this ?

6 Replies
1 Reply
(@serejah)
Joined: 10 months ago

Posts: 0

docs say that you can alternatively define it like this
macros.new <category_string> <name_string> <toolTip_string> <buttonText_string> <body_string>

sorry but i don’t understand how that will help

i know how to define macro
i just don’t want to write the macro scripts in my main script code
i want to import them without evaluating

I thought it was pretty obvious. Define your macro inside of some function and call it when you need them to evaluate

i can’t get the < body_string > to work it gives me errors whatever i do
my macro work with a filein command that reads the <macro_script_body> from some ms file

no matter how i put my filein string path to that <body_string> it wont work

and i also use the on ischecked do & on execute do commands and both gives me errors now

also i cant find a place for iconname to be defined in this way

and if it work how would i call that function in my main script ? with include or filein wouldn’t that evaluate them after all ?

then simply substring needed macro and execute it

example

tmp.ms contents

–macroName_1
macroScript macroName_1
category:“xxx”
tooltip:””
icon:#(“iconFileName”,1)
(

)
–macroName_1_end

–macroName_2
macroScript macroName_2
category:“xxx”
tooltip:””
icon:#(“iconFileName”,1)
(

)
–macroName_2_end

–macroName_3
macroScript macroName_3
category:“xxx”
tooltip:””
icon:#(“iconFileName”,1)
(

)
–macroName_3_end



fn MakeMacro index = 
(
	local txt = (dotNetClass "System.io.File").readalltext @"C:\temp\tmp.ms"
	
	start = findString txt ("--macroName_" + index as string)
	end   = findString txt ("--macroName_" + index as string + "_end")
	
	execute (substring txt start (end - start))	
)

MakeMacro 2

i got it to work finally
my knowledge is still lacking and am learning alot
you solution was too much for me atm

thanks alot you and denisT help alot