is Ben Rudgers

The Argument Button: Toggle Black and White Preferences

I wrote some useful code [all files dated 2009/8/18]  – actually auto-generated it for all the preferences, more on that below – added a nice icon and posted it up with instructions on how to use it.

What do you get for writing a simple tool which attempted to hack it’s way past the limitations of VectorScript? Zealous defense of that limitation as rational. By Royals no less.

Here’s the offending code which cannot be run from an icon :

Procedure toggle_pref_Black_and_White_Only;


   SetPref(10, NOT GetPref(10));


Run (toggle_pref_Black_and_White_Only);

And the icon    

As I suggested earlier, I generated commands for all the preference files:

  1. Copy the html documentation – an older version of this.
  2. Paste massage it into Excel.
  3. Use Word to mail merge it with a VectorScript code template and output it to a single file.
    V:\vector Scripts\toggle prefs\«function_name».txt
    Procedure toggle_pref_«function_name»;
    	SetPref(«selector_», NOT GetPref(«selector_»));
    Run (toggle_pref_«function_name»);
  4. Run this Vectorscript against the output file:
    PROCEDURE bar_parse_mergefile;
     	i : INTEGER;
    	merge_source_file : STRING;
    	vs_output_file : STRING;
    	bar_readline1,bar_readline2,bar_readline3,bar_readline4,bar_readline5  : string;
    	merge_source_file := 'V:\vector Scripts\toggle prefs\master parts\proceduremenu.txt';
    OPEN (merge_source_file);
    FOR i:=1 TO 131 DO BEGIN
    READLN (vs_output_file);
    READLN (bar_readline1,bar_readline2,bar_readline3,bar_readline4,bar_readline5); 
    ALRTDIALOG (vs_output_file);
    ALRTDIALOG (bar_readline5);
    REWRITE (vs_output_file);
    WRITELN (bar_readline1,CHR(13));
    WRITELN (bar_readline2,CHR(13));
    WRITELN (bar_readline3,CHR(13));
    WRITELN (bar_readline4,CHR(13));
    WRITELN (bar_readline5,CHR(13));
    CLOSE (vs_output_file);
    {\\\\\\\ALRTDIALOG (vs_output_file);\\\\\\\\\\\}
    ALRTDIALOG ('ended loop');
    CLOSE (merge_source_file);
    RUN (bar_parse_mergefile);
  5. This generated a separate VectorScript file for each available preference. One of which was the offending code. Being mentally in VectorScript mode, it was much easier to generate the files using Vectorscript than to attempt to program Word to handle them just the way I wanted.

A similar technique was used for commands – and ultimately for the Kludge-o-matic. More on that, hopefully, later.