FavDoc

Title FavDoc
File Name FavDoc.txt
Description Create menu with favorite files to open
Author Vochomurka
Parameters "%P%N"
Plugins Called ini, win, vec, file
Icon
Version 1.1
Updated on 15.11.2017
args Path
static Quote = ?+"+

if(Path[0] == Quote)
	Path = trim(Path, Quote, 3)

static Base = pprofolder ++ "scripts\ini\FavDoc.ini"
static Sec = "Documents"
local i, Item, Num, Mouse
static Items
static D = "Doc"
static D1 = "Doc1"

if(ini.check_exists(Base, Sec, D1) != 1)
	Items = line(ini.enum_keys(Base, Sec), 0)

flag set 1

static v = vec.create(Items + 2)

if(not v) do
	messagebox("ok error", "Vector not created", "VEC plugin error #1")
	quit
endif

for(i = 1; i <= Items; i++)
	Item = ini.get(Base, Sec, D ++ i)
	v[i + 1] = Item
	if(Item == Path) do
		flag clear 1
		Num = i + 1
	endif
endfor

v[0] = ifelse(pproflag(1), "Add ", "Remove ") ++ Quote ++ Path ++ Quote
v[1] = "*sep"

win.lastmouse(1)
Item = v.showmenu("", "", 1)
local Mouse = win.lastmouse(0)

if(abs(Item) == 1) do
	quit
elseif(Item == 0)
	if(pproflag(1)) do
		ini.set(Base, Sec, D1, Path)

		for(i = 2; i < Items + 2; i++)
			ini.set(Base, Sec, D ++ i, v[i])
		endfor
	else
		.@Delete(Num)
	endif
else
	if(Mouse == 1) do
		file.doverb(v[Item], "Open")
	else
		.@Delete(Item)
	endif
endif

quit
//===================================================
Function Delete(Num)
local Shift, i

ini.delete_section(Base, Sec)

for(i = 2; i < Num; i++)
	Shift = i - 1
	ini.set(Base, Sec, D ++ Shift, v[i])
endfor

for(i = Num + 1; i < Items + 2; i++)
	Shift = i - 2
	ini.set(Base, Sec, D ++ Shift, v[i])
endfor

Comments:

First, put this file into the pprofolder\scripts\ini\ directory, where pprofolder - home directory of PowerPro, usually c:\Program Files\PowerPro).

Then, place cursor on your favorite file and run the script. At the first run the menu with only item "Add " and your file name, is shown. After clicking this command the file name is added to the menu. The same operation can be done many times on different files.

At left clicking the file name the file is opened in the associated application.

File name can be removed from the menu by right clicking it, and by placing the cursor on the file again and running the script. In this case the first command is "Remove " and file name.


All Scripts Total Commander TotalCmd.net PowerPro