Files, Folders… and now File Handles!
The File and Folder commands, which appeared in 4D v17 R5, enable you to manage folders and files on disk in a modern and efficient way.
When it comes to writing and reading, the setText and getText functions are at your disposal to read or write the entire content. But what to do if you want to read or add one or more lines to an existing document? This can be done more efficiently than ever using the new “file handles” objects in 4D v19 R7.
Keep reading for details!
Tech Tips — The 4 Tips of April are Here!
by Add Komoncharoensiri, Director of Technical Services at 4D Inc
As a 4D developer, you have to keep up with the new advances 4D is continuously shipping. Besides tips and tricks provided by the product team, Tech Tips are another reference for learning some of the 4D concepts.
This article covers 4 tips:
- How to treat SQL wildcard characters as a literal string
- Programmatically get the project name
- Preemptive methods under the same call chain should also be preemptive
- Creating a new View Pro document based on a Sheet
LZMA: The new compression algorithm
Whenever we exchange files, we always go through the ritual of compressing the files before sending them. Since 4D v18, two commands are available, allowing you to create and read a ZIP archive using the standard zip compression algorithm.
With 4D V19 R3, the Zip Create Archive command supports a new compression algorithm: LZMA. The advantage of this algorithm is that it creates smaller archives than the standard zip compression algorithm. Let’s find out more!
Zip/unzip files and folders with these commands
Before exchanging files (by email for example), we often compress them to reduce their size before transmitting them. With 4D v18, you can compress and uncompress your files by programming without the need for external libraries or tools. Here are the new commands that allow you to do so:
Power of objects and dot notation
With 4D v17 R5, we showed you how easy it is to manipulate an object to retrieve the attributes of a file or folder. Things have gotten even easier thanks to object notation! In this blog post, we’re providing you an HDI with a user interface to manage files and folders. This isn’t new in 4D since you could do it with classic 4D commands, but now you can do it easier and with fewer lines of code!
Object notation to handle files and folders
4D already provides commands to handle files and folders, but what about new commands that take advantage of the power of object notation?
Objects have changed the way many 4D developers write code, making it more generic, flexible, easier, and faster. Now this wave of change is extended to files and folders. In this blog post, we’ll show you how easy it is to manipulate an object in order to retrieve the attributes of a file or folder (rather than calling several commands and storing the information in multiple variables). Things are getting a lot easier!
Contact us
Got a question, suggestion or just want to get in touch with the 4D bloggers? Drop us a line!
* Your privacy is very important to us. Please click here to view our Policy