0% found this document useful (0 votes)
3 views

Application Data _ AfraLISP

The document provides an overview of how to use the ACAD14.CFG file to store and retrieve application data in AutoLISP routines. It includes a simple example of a routine that tracks the number of times it has been run, demonstrating the use of the [AppData] section for usage control. Additionally, it mentions resources for learning AutoLISP and updates on the AfraLISP site.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Application Data _ AfraLISP

The document provides an overview of how to use the ACAD14.CFG file to store and retrieve application data in AutoLISP routines. It includes a simple example of a routine that tracks the number of times it has been run, demonstrating the use of the [AppData] section for usage control. Additionally, it mentions resources for learning AutoLISP and updates on the AfraLISP site.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Home

Site Map

Search

AutoLISP
Beginners' Tutorials
Intermediate Tutorials
Advanced Tutorials
Application Tutorials
Tips'n'Tricks
Visual LISP
Beginners' Tutorials
Intermediate Tutorials
DCL
Beginners' Tutorials
Intermediate Tutorials
VBA
VBA Tutorials
VBA Applications
Tips'nTricks
AutoCAD
Customization Tutorials
Tips'n'Tricks
Reference
AutoLISP Functions
Visual LISP Sample Files
DXF Group Codes
The AutoCAD APIs
DCL Tile Attributes
AutoLISP DCL Functions
System Variables
AutoCAD Object Model
Sin and Cos Functions
VLAX Enumeration
Download
Forum

Application Data
by Kenny Ramage

Have you ever looked at the ACAD14.CFG (Autocad Configuration) file?

This is simply a text file divided into sections. The only section that you have control over is the [AppData] section. Let's do something with it.

Say you wanted to store 2 bits of information that you use in one of your AutoLisp routines. You would store them like this :

(setcfg "appdata/test/bolt" "M24")


(setcfg "appdata/test/length "90")

After (setcfg must come "appdata" followed by your application name, which must be unique. Following this is the variable tag and then the information you wish to
store. If you open the ACAD14.CFG file, this is what the [AppData] section will look like :

[AppData/test]
bolt=4
length=90

To retrieve this data you would use the following syntax :

(setq a (getcfg "appdata/test/bolt"))


(setq b (getcfg "appdata/test/length"))

This would set a to "M24" and b to "90". Now this is great, I hear you say, but were would you use it. Here's a good example for you :

Say you've written a routine that you would like other people to use on a trial basis, say 5 times. After the 5 times they either pay up, or the routine ceases to work.

What we are going to do is first write a simple routine.


Then we will write a sub-routine that stores the number of times the routine is run in the [AppData] section. Next, we will check the number of times it has been run and
then decide whether the limit has expired or not. Have a look :
;Main function

(defun c:test8 ()
(register)
(if flagset
(alert "\nThe programme will now run.")
);if
(princ)
)defun

;Sub-function

(defun register ()
(setq v1 (getcfg "AppData/CadKen/test"))
(if (= v1 nil)
(progn
(setcfg "AppData/CadKen/test" "1")
(setq v1 (getcfg "AppData/CadKen/test"))
);progn
);if
(setq v2 5)
(setq v1 (atoi v1))
(if (< v1 v2)
(progn
(setq v1 (+ v1 1))
(cond
((= v1 1) (setcfg "AppData/CadKen/test" "1"))
((= v1 2) (setcfg "AppData/CadKen/test" "2"))
((= v1 3) (setcfg "AppData/CadKen/test" "3"))
((= v1 4) (setcfg "AppData/CadKen/test" "4"))
((= v1 5) (setcfg "AppData/CadKen/test" "5"))
);cond
(setq v3 v1)
(setq v3 (rtos (- v2 v1)))
(alert (strcat "\n You Have " v3 " more Loadings Left"))
(setq flagset T)
);progn
(progn
(alert "\nEvalution Period has Expired
\n Contact Kenny Ramage
\n [email protected]
\n For Licensed Copy")
(setq flagset nil)
);progn
);if
(princ)
);defun
(princ)

This is a very simple but usefull routine that demonstrates the use of [AppData]. You would still, of course, have to encrypt or compile your routine to stop the user
simply changing the variable that contains the usage control number. If you would like the source code, I have included it here.

AutoLISP
AutoLISP Beginners' Tutorials
AutoLISP Intermediate Tutorials
AutoLISP Advanced Tutorials
AutoLISP Application Tutorials
AutoLISP Tips'n'Tricks

AfraLISP Archive
‘Hey, what's happened to AfraLISP?’ If you've visited our site before, you'll notice some big changes. We're currently revamping the entire site to bring you updated
tutorials and a better user experience. However, if there's something you can't find, the AfraLISP Archive contains a full copy of the original site as originally created by
Kenny Ramage.

AutoLISP Learning Resources


Lee Mac - AutoLISP Tutorials and Programmes
Draftsperson.net - AutoLISP Tutorials
Jeffery P Sanders - AutoLISP Tutorials
Ron Leigh - AutoLISP Tutorials
Pixel Graphics Inc. - AutoLISP Tutorials
A'CAD Solutions - AutoLISP Tutorial
CAD Digest - AutoLISP Tutorials

Online Books
The ABC's of AutoLISP
The Visual LISP Developer's Bible

AutoLISP Forums
CADTutor
Autodesk Discussion Groups
Autodesk User Group International (AUGI)
The Swamp

122 Tutorials and reference documents published at AfraLISP so far.

Back to top
Home
Cared for by David Watson © 2024

You might also like