Topic: Tool for customizing macros via dialog menu (1 of 4), Read 52 times, 2 File Attachments
Conf: VEDIT Macro Library
From: Christian Ziemski
Date: Sunday, November 17, 2002 11:24 AM

Did you ever wish to be able to modify/customize your macro via dialog menu and save the changes permanently?

As you may know the original VEDIT macro COMPDIR.VDM saves it's configuration and the changes in itself.

I used that technique in my new FILEVERS.VDM too (see thread "File Version Generator (Multi-BAK :-)" here) and added a dialog for changing the values.

Now I developed a more flexible way for that purpose.
So it's no longer necessary to include that macro code in every macro again.
Just prepare one text register and call my CUSTOMIZE.VDM.

I attached an example CUSTDEMO.VDM as little demonstration.
Imagine it as your main macro with some functionality and one or more "Customize" buttons.

Here a little summary how to call the macro functions:


// First set up T-Reg 104 with the variable parts:

Reg_Set(104, "
$91=FAVEDITOR
#71=VERSION
")

// Then call one of the following functions:


//--- Read the config out of the macro's config section into the registers
//
#104=Macro_Num Reg_Set(103, "READCONFIG")
Call_File(101, "CUSTOMIZE.VDM", EXTRA)


//--- Save the registers into the macro's config section
//
#104=Macro_Num Reg_Set(103, "SAVECONFIG")
Call_File(101, "CUSTOMIZE.VDM", EXTRA)



//--- Automatically generate a dialog and let the user change values
//
#104=Macro_Num Reg_Set(103, "DIALOG")
Call_File(101, "CUSTOMIZE.VDM", EXTRA)


//--- Combined: Generate the dialog and save the registers to the config section
//
#104=Macro_Num Reg_Set(103, "DIALOG+SAVE")
Call_File(101, "CUSTOMIZE.VDM", EXTRA)




The setup register 104 can contain additional infos:

//--- For reading the config there can be optional default values:

Reg_Set(104, "
$91=FAVEDITOR=vedit
#71=VERSION=6
")


//---For creating the dialog there can be optional labels for every input box:

Reg_Set(104, "
$91=FAVEDITOR=My favourite editor:
#71=VERSION=Current version:
")



Hopefully the macro has enough comments in it to understand what to do.

If not: Simply come back to here! :-)


Christian

History:
--- 1st version: Nov. 11, 2002
--- New version: Nov. 13, 2002
--- New version: Nov. 17, 2002: Bugfixes, more comments

 
CUSTDEMO.VDM (6KB)
 
CUSTOMIZE.VDM (13KB)

 


Topic: Re: Tool for customizing macros via dialog menu (2 of 4), Read 45 times
Conf: VEDIT Macro Library
From: Ted Green
Date: Saturday, November 16, 2002 06:11 PM

At 05:15 AM 11/11/2002, you wrote:
>Did you ever wish to be able to modify/customize your macro via dialog menu and save the changes permanently?
>
>As you may know the original VEDIT macro COMPDIR.VDM saves it's configuration and the changes in itself.

I eventually would like to implement a VED-MAC.INI file (similar to the VEDIT.INI file) and new macro commands which can write/read this file to save config values for macros.

Until then, Christian's method will be useful.

Ted.

 


Topic: Re: Tool for customizing macros via dialog menu (3 of 4), Read 45 times
Conf: VEDIT Macro Library
From: Christian Ziemski
Date: Sunday, November 17, 2002 12:11 PM

On Sat, 16 Nov 2002 18:12:11 -0500, Ted wrote:

>I eventually would like to implement a VED-MAC.INI file
>(similar to the VEDIT.INI file) and new macro commands
>which can write/read this file to save config values for macros.


Something like the following may be an idea:


Read_Ini_String(r, section, name [, default])
- Returns
- 0 : o.k.
- 1 : default used or "not found" when no default given

Read_Ini_Num(section, name [, default] )
- Returns
- the read value or the default
- 0 : if not found


Write_Ini_String("text", section, name)
Write_Ini_Num(n, section, name)
- Returns
- 0 : if successful written
- 1 : on error


Those commands could use an INI file with a name configured in
VEDIT.CFG (and changeable via Config()) and look for that file in a
similar way VEDIT looks for a VDM macro file:
Current dir -- USER_MACRO -- MACRO -- HOME.


Example:
--------

;ini-file:
;
[MACRO1]
Name1=Peter
Name2=Jane
Age1=41
Age2=28

[DEMO]
Language=English
NumOfDays=4


// The macro commands in action:

Read_Ini_String(90, "DEMO", "Language")
#85=Read_Ini_Num("DEMO", "NumOfDays")

#85--
Write_Ini_Num(#85, "DEMO", "NumOfDays")

Reg_Set(90, "German")
Write_Ini_String(@90, "DEMO", "Language")



Christian

 


Topic: Re: Tool for customizing macros via dialog menu (4 of 4), Read 47 times
Conf: VEDIT Macro Library
From: Ted Green
Date: Sunday, November 17, 2002 02:57 PM

At 12:12 PM 11/17/2002, you wrote:
>Something like the following may be an idea:
>Read_Ini_String(r, section, name [, default])...

Yes, that is exactly what I have in mind. The macro commands would have similar format to the Windows API GetPrivateProfileString() and WritePrivateProfileString() functions.

Ted.