/* * [Prepare.java] * * Summary: Prepare code and HTML docs for KeyPlayer Keyboard and Mouse Event Tutor. * * Copyright: (c) 1999-2017 Roedy Green, Canadian Mind Products, http://mindprod.com * * Licence: This software may be copied and used freely for any purpose but military. * http://mindprod.com/contact/nonmil.html * * Requires: JDK 1.8+ * * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/ * * Version History: * 1.0 2010-01-24 initial version */ package com.mindprod.keyplayer; import com.mindprod.common18.BigDate; import com.mindprod.csv.CSVReader; import java.io.BufferedReader; import java.io.EOFException; import java.io.FileReader; import java.io.IOException; import java.util.BitSet; import static java.lang.System.*; /** * Prepare code and HTML docs for KeyPlayer Keyboard and Mouse Event Tutor. *

* reads vk.csv file and prepares code to be manually inserted in KeyPlayer and HTML * tables to summarise VK codes. * Must run from directory with vk.csv. * This is a rough and ready one-shot program. Normally only Roedy would run it. * * @author Roedy Green, Canadian Mind Products * @version 1.0 2010-01-24 initial version * @since 2010-01-24 */ public final class Prepare { private static final String DO_NOT_EDIT = "\n"; public static void main( String[] args ) throws IOException { // reader, separatorChar, quoteChar, commentChars, hideComments, trimQuoted, trimUnquoted, // allowMultipleLineFields CSVReader r = new CSVReader( new BufferedReader( new FileReader( "vk.csv" ), 10000 ), ',', '\"', "#", true, true /* trimQuoted */, true /* trimUnquoted */, false ); BitSet done = new BitSet( 0x10000 ); // check for dups try { while ( true ) { String vkName = r.get(); String hexString = r.get(); r.skipToNextLine(); int num = Integer.parseInt( hexString.substring( 2 ), 16 ); if ( done.get( num ) ) { err.println( "dup " + vkName ); } else { done.set( num ); } } } catch ( EOFException e ) { } r = new CSVReader( new BufferedReader( new FileReader( "vk.csv" ), 10000 ), ',', '\"', "#", true, true /* trimQuoted */, true /* trimUnquoted */, false ); try { while ( true ) { String vkName = r.get(); String hexString = r.get(); r.skipToNextLine(); out.println( "lookup[ " + hexString + " ] = \"" + vkName + "\";" ); } } catch ( EOFException e ) { } r = new CSVReader( new BufferedReader( new FileReader( "vk.csv" ), 10000 ), ',', '\"', "#", true, true /* trimQuoted */, true /* trimUnquoted */, false ); try { out.print( DO_NOT_EDIT ); int everyTenthLine = 0; while ( true ) { String vkName = r.get(); String hexString = r.get(); r.skipToNextLine(); int num = Integer.parseInt( hexString.substring( 2 ), 16 ); out.println( "" + vkName + "" + hexString + "" + num + "\n" ); } } catch ( EOFException e ) { } r.close(); } }