View Full Version : modified version of Bob Hood's gendata.ls

01-01-2013, 12:39 PM
ps_Multi-GenData.lsc v0.99
based on Bob Hood's gendata.ls script

In case you are unaware of the old gendata LScript by Bob Hood - it converts binary files to text data sections which can be embedded into an LScript. Typically this is a good way to include graphics into your text-based .ls file or compiled .lsc file. I've found that script very useful for my LScripts, but I've often needed to run it several times in order to create data sections to embed my graphics. So I've quickly slapped together a new interface around his awesome script -- I'm assuming it is o.k. to distribute this - I have no way of getting in contact with him to ask, and the original gendata.ls was available openly - so hopefully he doesn't mind me giving the interface a little usability facelift and redistributing it. The data conversion is still the same as the original gendata script.

To use the script:

It is a Layout generic script - run by clicking the Utilities > LScript RT button and selecting this script in Layout
Click the Save checkbox near the file box you'd like to choose a file with. (Only files that Save is checked next to will be saved when serializing the binary data.)
Enter text of the suffix you would like appended to the filenames of each file to act as that file's data identifier in the resulting LScript output
Choose the destination folder to save the output .ls data files to
Choose whether the output data files will be created individually (one for each file you convert) OR combined (one file total with all data sections appended within this one file).
the Clear Form button just clears out the settings on the Script to the default
the GO -serialize button actually creates the output files from your input (graphic) files
Pressing OK ends the script and saves your settings for next time - pressing Cancel ends the script without saving your settings for next time

This script has a few updates - see the screenshot for details:


It lets you convert up to 10 files (usually image files) in one go
It lets you choose whether to save each of the binary (image) files as its own *.ls file or combined into 1 single file named after the 1st one in the list
It automatically names the data id identifiers of the data sections for each of the files after the name of the file itself + the given suffix you have entered into the suffix text box. In doing so, it tries to clean up unsafe LScript variable characters from the filename replacing them with underscores. So if you have a file named "NewTek's funky# image.jpg" It will name the data id identifier in the file "Newtek_s_funky__image" + whatever you put in the suffix. Typically we put the extension of the graphic file denoting the type with an underscore - such as "_png" or "_jpg".
file names are exactly the same name as the graphic files + .ls -- if you choose to combine - then all of them go into a file named after the first selected graphic.
It remembers the last folder you browsed to - so you don't have to click a bunch of times if you are looking for graphics to convert
This also remembers the last settings you used this with the last time you ran it, provided you hit the OK button.
This zip also contains a batch file which runs on Windows and is launched by this script upon completion. The batch file merely opens up a file explorer to where your output files were saved. The reason we need a bat file is because just doing a spawn to explorer.exe within LScript would not bring the explorer window to the front and give it focus. This bat file is only launched when the script is run from Windows. If you run this from a Mac it should ignore that bat file -- I can tweak the script to launch finder for the Mac if someone tells me what the command is for that on the Mac.


It's pretty basic, but hope it's as useful to you as it is to me. I'm just throwing it out there just in case it saves someone some time. Let me know if you'd prefer a script that just scans an entire folder and converts those - if so, I may update this to have that feature as well. :)

01-01-2013, 04:14 PM
Would you plan to share the original uncompiled script as well? I'm always a fan of learning from others, if they'll let me :D

01-01-2013, 10:53 PM
Would you plan to share the original uncompiled script as well? I'm always a fan of learning from others, if they'll let me :D

it's not super clean code, as I just slapped it together, so not sure it's worth learning from, plus the guts of it are Bob Hood's - however if you still want it, PM me your email addy and I'll send it to you...