Hello Steve,

The following message contains a solution which worked well
when tested here.
Sorry I'm too tired to improve the long messy message.

What you are asking for is probably wanted by many people.
Therefore it would be a good idea to develop a really neat
solution which could be uploaded as a kit in our files section.

I have make a start on it (see below). It works but it could
probably be improved with ideas by other people too.

S> If I wrote a program to maintain a text file of macros,
S> how would I get this to update the pcf file?

I question whether it is a good plan to update the pcf file.
You can do that with cl.savepcf()
[Note: keep the empty () at the end of that command]
but that might also save other stuff to the pcf which you don't
want to be made permanent.
If you never use commands like cl.Set<Something> or cl.Addleft
(etc) in any of your other scripts, then that is not an issue.

You need to decide between these three methods:

[A] keep the JanesMacros command list in the pcf.
Use cl.savepcf() after changing any macro which you want to be
remembered between boots.

[B] keep your macros in a command list which is only in memory
not in the pcf. If it is imported with Configure ImportCL
(not with the pproconf dialog) then any cl.savepcf() commands
which may be needed by your other scripts will not save it
in the pcf, so this plan seems safer.
Have an item in the Reconfigure command list with command:
[EMAIL PROTECTED]
That's because clicking OK or Apply in pproconf destroys any
command lists which are only in memory from a Configure ImportCL.
Also make a Scheduler startup item with the same command.

[C] a mixture of the two - some permanent items, some volatile.
IMHO that can easily go wrong.

It is difficult and complicated to understand how these two
departments of PowerPro work, and how the two interact with each
other: (1) the Help Contents chapters "Configuring with text files"
(2) the Help Contents chapters "Configuring with CL functions".

To save you getting lost in that maze, here is a fairly simple plan
which only uses method [B].

You have a choice of how many commands to provide.

The simplest plan is to only provide the essential EditList
command which enables you to Add, Edit, or Delete any macro(s).
Your secretary will find it easier and quicker to edit a simple list
(as used in my recipe below) rather than using pproconf or editing
the importable command list.

The second most important command is the hotkey which creates
a new macro using the current selected text as the sendstring.

You can make it more sophisticated by including more permanent
commands such as: Delete one from menu (shows a list of all current
macros - click one to delete it); Edit one from menu; etc.
Those other possible commands are not so necessary and I haven't
completed them. It works OK without them.

Note: There are two degrees of permanence:

1: The "command macros" which are items in your importable command list
of macros such as #edit to edit the list, #-- for Delete Macro, etc.

2: The "Keys macros" which you want remembered until you change them,
such as #co for your company's name and #za for Mr Z����ski who is
a regular customer.

You need an importable ini file called JanesMacrosImport.ini for the
command list called JanesMacros. It only has the Permanent command items
and is never edited.
You also need a plain ini file (not importable, not a command list)
for the Remembered keys macros, called JanesMacrosList.ini. Every time
the user edits this file (using the #edit command provided), the script
automatically uses it to refresh the command list in memory.
And you need a script to run it all, JanesMacros.powerpro.


;;-------- ...\powerpro\JanesMacrosList.ini ------

[Macros]
co = Our Company Name
za = Mr Z����ski

;; ... and more lines with abc = result

;; --------- end of JanesMacrosList.ini --------


;;-------- ...\powerpro\JanesMacrosImport.ini ------
;; this is an importable command list
;; the Format1 and Format2 lines seem irrelevant but Powerpro
;; complains in some situations if you don't include them.

[JanesMacros:Properties]
Format1 = Position: Floating
Format2 = MaxText: 531

[1]
Label = edit
LCmd1 = [EMAIL PROTECTED]
MCmd1 = (none)
RCmd1 = (none)

;; Note: For the simplest design, you only need item [1] above.
;; The following items could be future additions.
;; Leave them out for the first version

[2]
Label = +m
LCmd1 = [EMAIL PROTECTED]
MCmd1 = (none)
RCmd1 = (none)

[3]
Label = -m
LCmd1 = [EMAIL PROTECTED]
MCmd1 = (none)
RCmd1 = (none)

[4]
Label = --
LCmd1 = [EMAIL PROTECTED]
MCmd1 = (none)
RCmd1 = (none)

;; Note do NOT add an item like the following, because
;; @AddMacroFromSelection needs to be run from a hotkey
;; such as Win+#, not from a macro.
;; [8]
;; Label = ++
;; LCmd1 = [EMAIL PROTECTED]
;; MCmd1 = (none)
;; RCmd1 = (none)

;; --------- end of JanesMacrosImport.ini --------

;;----------- JanesMacros.powerpro -------------
;; watch out for Yahoo splitting several long lines below

@EditMacrosList
file.runwait(0,"notepad","C:\Shells\PowerPro\JanesMacrosList.ini")

@RefreshFromMacrosList
Configure ImportCL C:\Shells\PowerPro\JanesMacrosImport.ini
local MacrosList = ini.enum_keys("C:\Shells\PowerPro\JanesMacrosList.ini", 
"Macros")
win.debug(MacrosList)
local CountMacros = line(MacrosList,0)
win.debug(CountMacros)
local i
for(i = 1; i <= CountMacros; i = i+1)
  local nextmacro = line(MacrosList,i)
  local nextkeystring = ini.get("C:\Shells\PowerPro\JanesMacrosList.ini", 
"Macros", NextMacro)
win.debug(nextmacro)
win.debug(nextkeystring)
  cl.Insert("JanesMacros", cl.length("JanesMacros"))
  cl.SetLabel("JanesMacros", cl.length("JanesMacros")-1, NextMacro)
  cl.AddLeft("JanesMacros", cl.length("JanesMacros")-1, "Keys", Nextkeystring)
endfor

quit

;; For the most simple design you only need the routines above.
;; Jane can easily learn to edit the lines: abc = keystrokes
;; to add or edit or delete any macro in JanesMacrosList.ini.
;; Then Save and close notepad.
;; When the Notepad which is editing JanesMacrosList.ini is closed,
;; then the script continues into @RefreshFromMacrosList so the
;; JanesMacros command list [in memory] is automatically updated.

@AddMacroFromSelection
  local SendstringToAdd = clip.get
win.debug("zzz",SendstringToAdd)
@EditMacroFromInput
@AddNewMacroFromInput


;; Those three all start here. If you try to add a "new" macro which
;; already exists, you are given the chance to edit the existing
;; sendstring for that macro. If it doesn't already exist then it
;; will be added as a new one.

;; Add/EditMacroFromInput could be called from a permanent command macro,
;; such as #ed1 or #++.

;; AddMacroFromSelection must be called from a single hotkey
;; such as Win+#, not from a macro [if you want the input dialog
;; to contain the currently selected text as a default sendstring]
;; because typing a macro would deselect the selected text
;; therefore our clip.copy will not work.

local MacroToAdd = inputcancel("Enter the macro keys without the leading #")

;; now we check if it already exists
local SavedList = ini.enum_keys("C:\Shells\PowerPro\JanesMacrosList.ini", 
"Macros")
if(index(SavedList,MacroToAdd))do
  ;; the MacroToAdd already exists so we retrieve its sendstring.
  local SendstringToAdd = ini.get("C:\Shells\PowerPro\JanesMacrosList.ini", 
"Macros", MacroToAdd)
endif

local SendstringToAdd = inputdefault(SendstringToAdd, "Enter the result for 
macro #" ++ MacroToAdd)
ini.set("C:\Shells\PowerPro\JanesMacrosList.ini", "Macros", MacroToAdd, 
SendstringToAdd)

jump RefreshFromMacrosList

quit

;; For another day:

@EditOneMacroFromMenu
;; show a menu based on JanesMacroList.ini
;; using file.readline() instead of ini plugin so the menu's
;; items look like the complete: za = Mr Z����ski
;; and clicking that item returns only the: za
;; then show an inputdefault to change the sendstring for za
;; then call @RefreshFromMacrosList
quit

@DeleteOneMacroFromMenu
;; show a menu based on JanesMacroList.ini
;; then remove the selected item from JanesMacroList.ini using:
;; ini.deletekey(pprofolder++"JanesMacrosList.ini", "Macros", MacroToDelete)
;; then call @RefreshFromMacrosList
quit

@DeleteOneMacroFromInput
;; unlike DeleteOneMacroFromMenu, she needs to know the macro.
;; Just typing: #--abc<Enter> will do the trick.
quit

;; --------- end of JanesMacros.powerpro --------

Now create a new hotkey using pproconf: Win+3
Command: [EMAIL PROTECTED]
Note that it is Win+3 but you think of it as Win+#
to remember that it relates to our #macros [i.e. Shift+3].

Create a command list in the pcf called Reconfigure
(or if it already exists, add a new item to it)
Item Name: whatever
Command: [EMAIL PROTECTED]

Create a new Scheduler item, check "Startup"
Command: [EMAIL PROTECTED]
(or if you already have a script scheduled for Startup,
add that command to it)

___________________________________________________

Possible improvements:

Instead of using Keys commands, which are slow for long strings,
you could use clip.setpaste() in a routine which doesn't destroy
the current clip:

local oldclip = clip.get
clip.setpaste(sendstring)
clip.set(oldclip)

I am not sure whether it would be easy for that method to
work with sendstrings containing Carriage Returns.
You can't use {en} like you can in Keys commands
so CRs would need to be \r\n
in the sendstrings in JanesMacrosList.ini

Maybe that would add problems, maybe not.
It was too much for me to think about and test so I stayed with
your choice of "Keys" as the command.



Attention: PowerPro's Web site has moved: http://www.ppro.org 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/power-pro/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to