Author Topic: make a function  (Read 1891 times)

0 Members and 1 Guest are viewing this topic.

AIberto

  • Guest
make a function
« on: July 11, 2015, 05:17:51 AM »
_1$ (setq item "HKEY_CURRENT_USER\\Software\\Data")
      (mapcar '(lambda (x) (vl-registry-read item x)) (vl-registry-descendents item ""))

returns
("134" "500" "530" "540" )

I don't know what is  this  value ?  I need know keynmame

so
_1$(setq item "HKEY_CURRENT_USER\\Software\\Data")
     (mapcar '(lambda (x) (list x (vl-registry-read item x))) (vl-registry-descendents item ""))   

returns
(("Width" "134") ("Length1" "500") ("Length3" "530") ("Length2" "540"))


Is it possible? Defined a Function

( defun get_reg_lst ( patch keylist) 
.........
..........
..........

call :
(get_reg_lst  item  '(Length1  Length2 Length3))

returns
( "500" "540" "530" )

« Last Edit: July 11, 2015, 05:21:46 AM by AIberto »

kpblc

  • Bull Frog
  • Posts: 396
Re: make a function
« Reply #1 on: July 11, 2015, 08:20:36 AM »
(setq item "HKEY_CURRENT_USER\\Software\\Data")
(mapcar '(lambda (x) (cons x (vl-registry-read item x))) (vl-registry-descendents item ""))
Sorry for my English.

AIberto

  • Guest
Re: make a function
« Reply #2 on: July 11, 2015, 10:03:40 PM »
(setq item "HKEY_CURRENT_USER\\Software\\Data")
(mapcar '(lambda (x) (cons x (vl-registry-read item x))) (vl-registry-descendents item ""))

Not I want ,

Hi kpblc ,You didn't see this one ? It's the same.
Quote
so
_1$(setq item "HKEY_CURRENT_USER\\Software\\Data")
     (mapcar '(lambda (x) (list x (vl-registry-read item x))) (vl-registry-descendents item ""))   

returns
(("Width" "134") ("Length1" "500") ("Length3" "530") ("Length2" "540"))



This is I want.
( defun get_reg_lst ( patch keylist) 
.........
..........
..........

call :
(get_reg_lst  item  '(Length1  Length2 Length3))

returns
( "500" "540" "530" )

kpblc

  • Bull Frog
  • Posts: 396
Re: make a function
« Reply #3 on: July 12, 2015, 12:19:35 AM »
There are many ways to get what you want:
Code: [Select]
(setq item "HKEY_CURRENT_USER\\Software\\Data"
      lst  '("Length1" "Length2" "Length3")
      ) ;_ end of setq

(vl-remove-if-not
  (function
    (lambda (x)
      (member (car x) lst)
      ) ;_ end of lambda
    ) ;_ end of function
  (mapcar '(lambda (x) (cons x (vl-registry-read item x))) (vl-registry-descendents item ""))
  ) ;_ end of vl-remove-if-not
Code: [Select]
(mapcar
  (function
    (lambda (key)
      (cons key (vl-registry-read item key))
      ) ;_ end of lambda
    ) ;_ end of function
  '("Length1" "Length2" "Length3")
  ) ;_ end of mapcar
and more ways. Unfortunally i have no time to write them (and i think you can create some more ways and codes ;))
Sorry for my English.

AIberto

  • Guest
Re: make a function
« Reply #4 on: July 12, 2015, 07:46:40 AM »
There are many ways to get what you want:
Code: [Select]
(setq item "HKEY_CURRENT_USER\\Software\\Data"
      lst  '("Length1" "Length2" "Length3")
      ) ;_ end of setq

(vl-remove-if-not
  (function
    (lambda (x)
      (member (car x) lst)
      ) ;_ end of lambda
    ) ;_ end of function
  (mapcar '(lambda (x) (cons x (vl-registry-read item x))) (vl-registry-descendents item ""))
  ) ;_ end of vl-remove-if-not
Code: [Select]
(mapcar
  (function
    (lambda (key)
      (cons key (vl-registry-read item key))
      ) ;_ end of lambda
    ) ;_ end of function
  '("Length1" "Length2" "Length3")
  ) ;_ end of mapcar
and more ways. Unfortunally i have no time to write them (and i think you can create some more ways and codes ;))


Thank you kpblc
Code - Auto/Visual Lisp: [Select]
  1.     (lambda (key)
  2.       (cons key (vl-registry-read item key))
  3.       )
  4.     )
  5.   '("Length1" "Length2" "Length3")
  6.   ))
  7.  
  8. ("100" "200" "300")
  9.  

kpblc

  • Bull Frog
  • Posts: 396
Re: make a function
« Reply #5 on: July 12, 2015, 08:00:03 AM »
you can make code more simple:
Code: [Select]
(mapcar
  (function
    (lambda (key)
      (vl-registry-read item key)
      ) ;_ end of lambda
    ) ;_ end of function
  '("Length1" "Length2" "Length3")
  ) ;_ end of mapcar
But i prefer to proceed with dotpairs and use assoc function: codes used this method are more scalable and clear.
Sorry for my English.