Author Topic: [XDrX-PlugIn(95)] Generate QR code  (Read 231 times)

0 Members and 1 Guest are viewing this topic.

xdcad

  • Bull Frog
  • Posts: 469
[XDrX-PlugIn(95)] Generate QR code
« on: January 17, 2024, 03:13:58 AM »
Code: [Select]
(defun c:xdtb_mkqrcode (/ e pnt val)
  (setq xd_odcl_qrcode_data
'("YWt6A/AeAAB3dekuBuKTJqMRaitqgTMXyclO6Jvd2q9mXztePg8ZNQ8X8l/cWFZTXlruqqbKxaWM"
   "r6Ob3bY481rANtyxFII2Aow3Pmx6HNxfvn3Ch9xP+EG+dtZxuGZB1pmi55CyQ6OwEpe8EJywmqDj"
   "oeLnDZCpkYKQEgKMkFrCbEX83Tbd/nLMzn4CpXSy2SFI0DKss0rgOnR3VOWuc3m9CpuuqzgSWJVO"
   "I3Otq1ajkzhRozOvo1JDka7H76CXW9r9M8w5yImurd2kuACGRDOfp125tRbxXZpf150TXJHDKqwK"
   "2JZJPdZ5E87Hy3XG25b6zK56kd5OjaBjhoMz1daAO7LFFw9tqrl8wVSOa8oyH9CqMx9BH545rZY9"
   "72RK+p5WcC/5dPoNlrxwms/ztH8yLme4RqvRr01UGOfggWjv9HxVj4ILUuCU0akPi2zkb0aqN8lt"
   "AoI6/dFohYZJyCGKzwCANf9RdgIgngGCBhIuEd0LdDEMwlAdNCSiVweSBgI6o05Skx891qiGL9Et"
   "z5kvmwgDw+KLewWWq1zzik1GMIt6x7atXFRJKDMu2wCSjl0OeSqyDqSKg5AtR4v7ZqUNfLFpHe9J"
   "AqaDpvObKogtfbmXIvAZ12A9DjDojAWRd0FjwINOneNAoLkG6fGpTsAbuvsEoskBuYh/YUG8hjtP"
   "2aV7kGmGe/8f55PTHhjxrppOY6oUr6m+MllmpXh7YOD3Ei2AIswTq2o1ne6wWtQ7rpjS3qsX/7F2"
   "ggc6/GZRi7+7+Xqw64Qag7/iVnaFP/+hb4+Q6rituwmDmYvmg1ygwSOc3vUp9IkBi6W96xitXPNV"
   "He1d2dsN2BdXrmpK2BqILUy5EutRAEYmcae0/+fToPnn07guCae04BdnORtU5cO6S6JeJ2ql0ElN"
   "Qu5D7EVzULLvdQz5rSKUwBVxDps5Mp001cVdp0XGlIuaPmG8Jt1FDdHSh7QRu2PPcZ073aj3KHkm"
   "uvhe9dC8Gq9P+s32GVW23OEve2jn0ico8Eu5NlDwLKyxLYH5iqgJ/LhcZbTa4yqSSNRoFObuMhSl"
   "NJANutt8Vyz/SvnKFjLSuYh5svnDXOCaOSKe6ZX1QX8A0hjSujQKAgV4q6/zcOqv85keZQ99cgZ1"
   "WH3gGcKyhZDd3afzE1sKk5ZE1xU0ySl73Ql3GIp0hXTdQZIfPR6TJZ8iRXHtFTHfSIWV4glruMtT"
   "jirVI71OqzRIKtUI1NvBl7pwkeVJQAXbYMtUc+3XJ+bylTlGAVC/mjF0K6nUW5uGvGFInWvVKllr"
   "5emtPWRAU+fdgtFYqNaaCsg6z50/Fab29gk0HtcPp3azhda45ElUnDvOj3dPqXf/fRKDNc4rpX0S"
   "I7sGyLIiWmYL0TIz98YvoRRfMiB57bfhTiBR5qtTjiRvQToFDebYy7NwE4aGclSQ4Vm9Tbh75mfd"
   "cSu2ZuU7xbNyzM4ieEc/51096qEhp+ncxal3raIXgcxKSsnI5IWLHgMUEKqJn9nWx5gI+k3YLKOT"
   "/NnFNUryrCPZ38WBYaOj/MeXUEmUAJaQeebjkIz9P0ghPQsLKYUhX8y/UoroicC/Eo99kMWguN2A"
   "I3S1Z+nDoYF+g1rgxQ=="
  )
  )
  (defun c:xd_qrcode_form#OnInitialize (/)
    (if qrcode_txt
      (dcl-Control-SetText xd_qrcode_string qrcode_txt)
    )
    (if qrcode_wid
      (dcl-Control-SetText xd_qrcode_width qrcode_wid)
    )
    (if qrcode_mode
      (dcl-Control-SetText xd_qrcode_mode qrcode_mode)
    )
    (if (not (= (xdrx-get-language) "CHS"))
      (progn
(dcl-Control-SetCaption xd_qrcode_ok "OK")
(dcl-Control-SetCaption xd_qrcode_quit "Cancel")
(dcl-Control-SetTitleBarText xd_qrcode_form "Make QRCode")
(dcl-Control-SetCaption
  xd_qrcode_string_title
  "QRCode Content"
)
(dcl-Control-SetCaption xd_qrcode_width_title "Width")
(dcl-Control-SetCaption xd_qrcode_tol_title "TOL")
      )
    )
  )
  (defun c:xd_qrcode_ok#OnClicked (/)
    (setq qrcode_txt  (dcl-Control-GetText xd_qrcode_string)
  qrcode_wid  (dcl-Control-GetText xd_qrcode_width)
  qrcode_mode (dcl-Control-GetText xd_qrcode_mode)
    )
    (cond
      ((= qrcode_txt "")
       (dcl-messagebox
(xdrx-string-multilanguage
   "二维码字符串无内容."
   "QR code string has no content."
)
(xdrx-string-multilanguage "晓东提示" "XD Tips")
       )
      )
      ((= qrcode_wid "")
       (dcl-messagebox
(xdrx-string-multilanguage
   "请输入二维码图片宽度."
   "Please enter the width of the QR code image."
)
(xdrx-string-multilanguage "晓东提示" "XD Tips")
       )
      )
      ((= qrcode_mode "")
       (dcl-messagebox
(xdrx-string-multilanguage
   "请输入二维码图片生成精度."
   "Please enter the QR code image generation accuracy."
)
(xdrx-string-multilanguage "晓东提示" "XD Tips")
       )
      )
      (t
       (dcl-form-close xd_qrcode_form)
       (xdrx_entity_delete e)
       (setq e (xdrx_qrcode_make
qrcode_txt
'(0 0 0)
(atof qrcode_wid)
(atoi qrcode_mode)
       )
       )
       (if (= #xd_var_global_qrcode_mode "F")
(xd::drag:simplemove
   (entlast)
   (xdrx-string-multilanguage
     "\n点取插入位置:"
     "\nInsert Position:"
   )
   5
   t
)
(xdrx_setpropertyvalue e "position" pnt)
       )
      )
    )
  )
  (defun c:xd_qrcode_quit#OnClicked (/)
    (dcl-form-close xd_qrcode_form)
    (princ)
  )
  (dcl-project-import xd_odcl_qrcode_data)
  (xdrx_begin)
  (xdrx_initget "F E")
  (if (not #xd_var_global_qrcode_mode)
    (setq #xd_var_global_qrcode_mode "F")
  )
  (if (/= ""
  (setq
    val (getstring
  (xdrx_prompt
    (xdrx-string-formatex
      (xdrx-string-multilanguage
"\n操作模式[生成(F)/编辑(E)]<%s>:"
"\nOperating mode [Generate(F)/Edit(E)]<%s>:"
      )
      #xd_var_global_qrcode_mode
    )
    t
  )
)
  )
      )
    (setq #xd_var_global_qrcode_mode (strcase val))
  )
  (xdrx_initget)
  (if (= #xd_var_global_qrcode_mode "E")
    (progn
      (if
(and (setq e
    (car (xdrx_entsel
   (xdrx-string-multilanguage
     "\n拾取二维码<退出>:"
     "\nPick up the QR code <Exit>:"
   )
   '((-3 . "QRCode"))
)
    )
     )
     (setq qrcode     (xdrx-xdata-get e "QRCODE")
   qrcode_txt (car qrcode)
     )
)
(progn
   (setq qrcode_wid (rtos (cadr qrcode) 2 0)
pnt     (xdrx_getpropertyvalue e "position")
   )
   (dcl-form-show xd_qrcode_form)
)
      )
    )
    (dcl-form-show xd_qrcode_form)
  )
  (xdrx_end)
  (princ)
)
The code I wrote uses XDRX-API,which can be downloaded from github.com and is updated at any time.
===================================
[XDrx-Sub Forum]
https://www.theswamp.org/index.php?board=78.0
https://github.com/xdcad/XDrx-API
http://bbs.xdcad.net