Trying to understand syntax hilighting (please run code provided)

Can someone enlighten me here - I've searched the API, but cannot get this to work - I have also seen and used camrickr's superb code - the point is here I'm trying to get a handle on how that works by simplifying the processes. The following code is supposed to hilight in red or blue. At present the first 2 lines are in blue and the rest is black which I find a bit odd.
1. Base Application: SyntaxTest.javaimport java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.text.*;
import java.io.*;
public class SyntaxTest{
   JTextPane textPane;
   public static void main(String a[]){
      new SyntaxTest();
   SyntaxTest(){   
      textPane = new JTextPane();
      EditorKit editorKit = new StyledEditorKit(){
         public Document createDefaultDocument(){
            return new SimpleHighlight();
      textPane.setEditorKitForContentType("text", editorKit);
      textPane.setContentType("text");
      JButton button = new JButton("Load someText");
      button.addActionListener( new ActionListener(){
         public void actionPerformed(ActionEvent e){
            try{
               FileInputStream fis = new FileInputStream( "someText.txt" );
               textPane.read( fis, null );
            catch(Exception e2) {}
      JFrame frame = new JFrame("Syntax Highlighting");
      frame.getContentPane().add(new JScrollPane(textPane) );
      frame.getContentPane().add(button, BorderLayout.SOUTH);
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setSize(600,300);
      frame.setVisible(true);
2. The hilighter: SimpleHighlight.java
import java.awt.*;
import javax.swing.text.*;
public class SimpleHighlight extends DefaultStyledDocument{
   private DefaultStyledDocument doc;
   private SimpleAttributeSet red, blue;
   int tally;
   protected SimpleHighlight(){
      doc=this;
      red = new SimpleAttributeSet();
      StyleConstants.setForeground(red, Color.red);
      blue = new SimpleAttributeSet();
      StyleConstants.setForeground(blue, Color.blue);
   public void insertString(int offset, String str, AttributeSet as) throws BadLocationException{
      super.insertString(offset, str, as);
      highlight(str, str.length());
   public void remove(int offset, int length) throws BadLocationException{
      super.remove(offset, length);
System.out.print("remove:"); // doesn't appear to do anything
   private void highlight(String thisLine, int length){
      if(thisLine.startsWith("1"))
         doc.setCharacterAttributes(0, length, red, false);
      else doc.setCharacterAttributes(0, length, blue, false);
System.out.print(thisLine+" "+length);
3. And this is the text file I'm accessing;- someText.txt
01234
12345
01234
12345
1234567890

Thanks again camrckr - let me know whether you approve of the amendendments;-import java.awt.*;
import java.awt.event.*;
import java.awt.Toolkit.*;
import java.util.*;
import javax.swing.*;
import javax.swing.text.*;
class SyntaxDocument extends DefaultStyledDocument{
   private DefaultStyledDocument doc;
   private Element rootElement;
   private boolean multiLineComment;
   private MutableAttributeSet normal;
   private MutableAttributeSet keyword;
   private MutableAttributeSet comment;
   private MutableAttributeSet quote;
   private MutableAttributeSet symbol; // NEW
   private MutableAttributeSet number; // NEW
   private Hashtable keywords;
   private boolean started;
   public SyntaxDocument(){
      doc = this;
      rootElement = doc.getDefaultRootElement();
      putProperty( DefaultEditorKit.EndOfLineStringProperty, "\n" );
      normal = new SimpleAttributeSet();
      StyleConstants.setForeground(normal, Color.black);
      symbol = new SimpleAttributeSet();
      StyleConstants.setForeground(symbol, Color.black);
      StyleConstants.setBold(symbol, true);
      number = new SimpleAttributeSet();
      Color purple = new Color(160, 0, 160);
      StyleConstants.setForeground(number, purple);
      comment = new SimpleAttributeSet();
      Color green = new Color(0, 120, 0);
      StyleConstants.setForeground(comment, green);
      keyword = new SimpleAttributeSet();
      Color blue = new Color(0, 0, 160);
      StyleConstants.setForeground(keyword, blue);
      StyleConstants.setBold(keyword, true);
      quote = new SimpleAttributeSet();
      Color red = new Color(160,0,0);
      StyleConstants.setForeground(quote, red);
      Object dummyObject = new Object(); 
      keywords = new Hashtable();
      keywords.put( "abstract", dummyObject );
      keywords.put( "boolean", dummyObject );
      keywords.put( "break", dummyObject );
      keywords.put( "byte", dummyObject );
      keywords.put( "case", dummyObject );
      keywords.put( "catch", dummyObject );
      keywords.put( "char", dummyObject );
      keywords.put( "class", dummyObject );
      keywords.put( "continue", dummyObject );
      keywords.put( "default", dummyObject );
      keywords.put( "do", dummyObject );
      keywords.put( "double", dummyObject );
      keywords.put( "else", dummyObject );
      keywords.put( "extends", dummyObject );
      keywords.put( "false", dummyObject );     // string literal
      keywords.put( "final", dummyObject );
      keywords.put( "finally", dummyObject );
      keywords.put( "float", dummyObject );
      keywords.put( "for", dummyObject );
      keywords.put( "goto", dummyObject );     
      keywords.put( "if", dummyObject );
      keywords.put( "implements", dummyObject );
      keywords.put( "import", dummyObject );
      keywords.put( "instanceof", dummyObject );
      keywords.put( "int", dummyObject );
      keywords.put( "interface", dummyObject );
      keywords.put( "long", dummyObject );
      keywords.put( "native", dummyObject );
      keywords.put( "new", dummyObject );
      keywords.put( "null", dummyObject );      // string literal
      keywords.put( "package", dummyObject );
      keywords.put( "private", dummyObject );
      keywords.put( "protected", dummyObject );
      keywords.put( "public", dummyObject );
      keywords.put( "return", dummyObject );
      keywords.put( "short", dummyObject );
      keywords.put( "static", dummyObject );
      keywords.put( "strictfp", dummyObject );
      keywords.put( "super", dummyObject );
      keywords.put( "switch", dummyObject );
      keywords.put( "synchronized", dummyObject );
      keywords.put( "this", dummyObject );
      keywords.put( "throw", dummyObject );
      keywords.put( "throws", dummyObject );
      keywords.put( "transient", dummyObject );
      keywords.put( "true", dummyObject );       // string literal
      keywords.put( "try", dummyObject );
      keywords.put( "void", dummyObject );
      keywords.put( "volatile", dummyObject );
      keywords.put( "while", dummyObject );
   /* Override to apply syntax highlighting after the document has been updated */
   public void insertString(int offset, String str, AttributeSet a) throws BadLocationException{
      if (str.equals("{"))
      str = addMatchingBrace(offset);
      super.insertString(offset, str, a);
      processChangedLines(offset, str.length());
   /* Override to apply syntax highlighting after the document has been updated */
   public void remove(int offset, int length) throws BadLocationException{
      super.remove(offset, length);
      processChangedLines(offset, 0);
   /* Determine how many lines have been changed, then apply highlighting to each line */
   private void processChangedLines(int offset, int length) throws BadLocationException {
      String content = doc.getText(0, doc.getLength());
      // The lines affected by the latest document update
      int startLine = rootElement.getElementIndex( offset );
      int endLine = rootElement.getElementIndex( offset + length );
      // Make sure all comment lines prior to the start line are commented
      // and determine if the start line is still in a multi line comment
      setMultiLineComment( commentLinesBefore( content, startLine ) );
      // Do the actual highlighting
      for (int i=startLine; i <=endLine; i++) applyHighlighting(content, i);
      // Resolve highlighting to the next end multi line delimiter
      if (isMultiLineComment()) commentLinesAfter(content, endLine);
      else highlightLinesAfter(content, endLine);
   /* Highlight lines when a multi line comment is still 'open' */
   private boolean commentLinesBefore(String content, int line){
      int offset = rootElement.getElement( line ).getStartOffset();
      // Start of comment not found, nothing to do
      int startDelimiter = lastIndexOf( content, getStartDelimiter(), offset-2);
      if (startDelimiter < 0)return false;
      // Matching start/end of comment found, nothing to do
      int endDelimiter = indexOf( content, getEndDelimiter(), startDelimiter );
      if (endDelimiter < offset & endDelimiter != -1)return false;
      // End of comment not found, highlight the lines
      doc.setCharacterAttributes(startDelimiter, offset - startDelimiter + 1, comment, false);
      return true;
   /* Highlight comment lines to matching end delimiter */
   private void commentLinesAfter(String content, int line){
      int offset = rootElement.getElement( line ).getEndOffset();
      // End of comment not found, nothing to do
      int endDelimiter = indexOf( content, getEndDelimiter(), offset );
      if (endDelimiter < 0) return;
      // Matching start/end of comment found, comment the lines
      int startDelimiter = lastIndexOf( content, getStartDelimiter(), endDelimiter );
      if (startDelimiter < 0 || startDelimiter <= offset){
         doc.setCharacterAttributes(offset, endDelimiter - offset + 1, comment, false);
   /* Highlight lines to start or end delimiter */
   private void highlightLinesAfter(String content, int line) throws BadLocationException{
      int offset = rootElement.getElement( line ).getEndOffset();
      // Start/End delimiter not found, nothing to do
      int startDelimiter = indexOf( content, getStartDelimiter(), offset );
      int endDelimiter = indexOf( content, getEndDelimiter(), offset );
      if (startDelimiter < 0)     startDelimiter = content.length();
      if (endDelimiter < 0)endDelimiter = content.length();
      int delimiter = Math.min(startDelimiter, endDelimiter);
      if (delimiter < offset)return;
      // Start/End delimiter found, reapply highlighting
      int endLine = rootElement.getElementIndex( delimiter );
      for (int i = line + 1; i < endLine; i++){
         Element branch = rootElement.getElement( i );
         Element leaf = doc.getCharacterElement( branch.getStartOffset() );
         AttributeSet as = leaf.getAttributes();
         if ( as.isEqual(comment) ) applyHighlighting(content, i);
   /* Parse the line to determine the appropriate highlighting */
   private void applyHighlighting(String content, int line) throws BadLocationException{
      int startOffset = rootElement.getElement( line ).getStartOffset();
      int endOffset = rootElement.getElement( line ).getEndOffset() - 1;
      int lineLength = endOffset - startOffset;
      int contentLength = content.length();
      if (endOffset >= contentLength)endOffset = contentLength - 1;
         // check for multi line comments
         // (always set the comment attribute for the entire line)
         if( ( endingMultiLineComment(content, startOffset, endOffset) )
            ||( isMultiLineComment() )
            ||( startingMultiLineComment(content, startOffset, endOffset) ) ){
               doc.setCharacterAttributes(startOffset, endOffset - startOffset + 1, comment, false);
               return;
      // set normal attributes for the line
      doc.setCharacterAttributes(startOffset, lineLength, normal, true);
      int index = content.indexOf(getSingleLineDelimiter(), startOffset);
      if ( (index > -1) && (index < endOffset) ){
         doc.setCharacterAttributes(index, endOffset - index + 1, comment, false);
         endOffset = index - 1;
      if(startOffset>endOffset) tokensInBold(content, startOffset);  // NEW
      else checkForTokens(content, startOffset, endOffset);
/* This line contain the start delimiter */
   private boolean startingMultiLineComment(String content, int startOffset, int endOffset) throws BadLocationException{
      int index = indexOf( content, getStartDelimiter(), startOffset );
      if( (index < 0) || (index > endOffset) ) return false;
      else{
         setMultiLineComment( true );
         return true;
   /* Does this line contain the end delimiter */
   private boolean endingMultiLineComment(String content, int startOffset, int endOffset) throws BadLocationException{
      int index = indexOf( content, getEndDelimiter(), startOffset );
      if( (index < 0) || (index > endOffset) ) return false;
      else{
         setMultiLineComment( false );
         return true;
   /* We have found a start delimiter and are still searching for the end delimiter */
   private boolean isMultiLineComment(){
      return multiLineComment;
   private void setMultiLineComment(boolean value){
      multiLineComment = value;
   /* Wait for all other painting before painting these once */
   private void tokensInBold(String content, int length){  // NEW
      for(int i=0; i<length; i++){        
         if(isDelimiterBold(content.substring(i, i+1)))
            doc.setCharacterAttributes(i, 1, symbol, false);        
   private void checkForTokens(String content, int startOffset, int endOffset){
      while (startOffset <= endOffset){
         // skip the delimiters to find the start of a new token
         while (isDelimiter(content.substring(startOffset, startOffset+1))){
            if(startOffset < endOffset) startOffset++;
            else return;
         // Extract and process the entire token
         if (isQuoteDelimiter( content.substring(startOffset, startOffset + 1)))
            startOffset = getQuoteToken(content, startOffset, endOffset);
         else startOffset = getOtherToken(content, startOffset, endOffset);        
   private int getQuoteToken(String content, int startOffset, int endOffset){
      String quoteDelimiter = content.substring(startOffset, startOffset + 1);
      String escapeString = getEscapeString(quoteDelimiter);
      int index;
      int endOfQuote = startOffset;
      // skip over the escape quotes in this quote
      index = content.indexOf(escapeString, endOfQuote + 1);
      while ( (index > -1) && (index < endOffset) ){
         endOfQuote = index + 1;
         index = content.indexOf(escapeString, endOfQuote);
      // now find the matching delimiter
      index = content.indexOf(quoteDelimiter, endOfQuote + 1);
      if( (index < 0) || (index > endOffset) ) endOfQuote = endOffset;
      else endOfQuote = index;
      doc.setCharacterAttributes(startOffset, endOfQuote-startOffset+1, quote, false);
      return endOfQuote + 1;
   private int getOtherToken(String content, int startOffset, int endOffset){
      int endOfToken = startOffset + 1;
      while(endOfToken <= endOffset ){
         if(isDelimiter(content.substring(endOfToken, endOfToken+1)))
            break;
         endOfToken++;
      String token = content.substring(startOffset, endOfToken);
      try{                                              // NEW
        Long.parseLong(token);
        doc.setCharacterAttributes(startOffset, endOfToken-startOffset, number, false);
      }catch(NumberFormatException nfe){}
      if( isKeyword( token ) )
         doc.setCharacterAttributes(startOffset, endOfToken-startOffset, keyword, false);
         return endOfToken + 1;
      private int indexOf(String content, String needle, int offset){
         int index;
         while( (index = content.indexOf(needle, offset)) != -1 ){
            String text = getLine( content, index ).trim();
            if(text.startsWith(needle) || text.endsWith(needle)) break;
            else offset = index + 1;
         return index;
   private int lastIndexOf(String content, String needle, int offset){
      int index;
      while ( (index = content.lastIndexOf(needle, offset)) != -1 ){
         String text = getLine( content, index ).trim();
         if( (text.startsWith(needle)) || (text.endsWith(needle)) ) break;
         else offset = index - 1;
      return index;
   private String getLine(String content, int offset){
      int line = rootElement.getElementIndex( offset );
      Element lineElement = rootElement.getElement( line );
      int start = lineElement.getStartOffset();
      int end = lineElement.getEndOffset();
      return content.substring(start, end - 1);
   protected boolean isDelimiter(String character){
      String operands = ";:{}()[]+-/%<=>!&|^~*,.\\\n";     
      if (Character.isWhitespace( character.charAt(0) ) ||
         operands.indexOf(character)!= -1 )
      return true;
      else return false;
   protected boolean isQuoteDelimiter(String character){
      String quote = "\"'";
      if (quote.indexOf(character) < 0) return false;
      else return true;
   protected boolean isDelimiterBold(String character){  // NEW
      String symbolDelimiters = "{}[]();&|";
        if ( symbolDelimiters.indexOf(character)< 0) return false;
      else return true;
   protected boolean isKeyword(String token){
      Object o = keywords.get( token );
      return o == null ? false : true;
   protected String getStartDelimiter(){
      return "/*";
   protected String getEndDelimiter(){
      return "*/";
   protected String getSingleLineDelimiter(){
      return "//";
   protected String getEscapeString(String quoteDelimiter){
      return "\\" + quoteDelimiter;
   protected String addMatchingBrace(int offset) throws BadLocationException{
      StringBuffer whiteSpace = new StringBuffer();
      int line = rootElement.getElementIndex( offset );
      int i = rootElement.getElement(line).getStartOffset();
      while(true){
         String temp = doc.getText(i, 1);
         if (temp.equals(" ") || temp.equals("\t")){
            whiteSpace.append(temp);
            i++;
         else break;
      return "{\n" + whiteSpace.toString() + whiteSpace.toString()+"\n" + whiteSpace.toString() + "}";
}

Similar Messages

  • Trying to understand syntax

    Hi,
    I'm trying to follow some Java code but I don't understand the syntax being used. If you define a class and then define a method within that class, is it automatically run? I'm attaching some sample code. I don't understand how public void map (line 18) is ever called or run, yet it is.
    1.      package org.myorg;
    2.      
    3.      import java.io.IOException;
    4.      import java.util.*;
    5.      
    6.      import org.apache.hadoop.fs.Path;
    7.      import org.apache.hadoop.conf.*;
    8.      import org.apache.hadoop.io.*;
    9.      import org.apache.hadoop.mapred.*;
    10.      import org.apache.hadoop.util.*;
    11.      
    12.      public class WordCount {
    13.      
    14.      public static class Map extends MapReduceBase implements Mapper<LongWritable, Text, Text, IntWritable> {
    15.      private final static IntWritable one = new IntWritable(1);
    16.      private Text word = new Text();
    17.      
    18.      public void map(LongWritable key, Text value, OutputCollector<Text, IntWritable> output, Reporter reporter) throws IOException {
    19.      String line = value.toString();
    20.      StringTokenizer tokenizer = new StringTokenizer(line);
    21.      while (tokenizer.hasMoreTokens()) {
    22.      word.set(tokenizer.nextToken());
    23.      output.collect(word, one);
    24.      }
    25.      }
    26.      }
    27.      
    28.      public static class Reduce extends MapReduceBase implements Reducer<Text, IntWritable, Text, IntWritable> {
    29.      public void reduce(Text key, Iterator<IntWritable> values, OutputCollector<Text, IntWritable> output, Reporter reporter) throws IOException {
    30.      int sum = 0;
    31.      while (values.hasNext()) {
    32.      sum += values.next().get();
    33.      }
    34.      output.collect(key, new IntWritable(sum));
    35.      }
    36.      }
    37.      
    38.      public static void main(String[] args) throws Exception {
    39.      JobConf conf = new JobConf(WordCount.class);
    40.      conf.setJobName("wordcount");
    41.      
    42.      conf.setOutputKeyClass(Text.class);
    43.      conf.setOutputValueClass(IntWritable.class);
    44.      
    45.      conf.setMapperClass(Map.class);
    46.      conf.setCombinerClass(Reduce.class);
    47.      conf.setReducerClass(Reduce.class);
    48.      
    49.      conf.setInputFormat(TextInputFormat.class);
    50.      conf.setOutputFormat(TextOutputFormat.class);
    51.      
    52.      FileInputFormat.setInputPaths(conf, new Path(args[0]));
    53.      FileOutputFormat.setOutputPath(conf, new Path(args[1]));
    54.      
    55.      JobClient.runJob(conf);
    57.      }
    58.      }

    If you define a class and then define a method within that class, is it automatically run?No.
    However, if you start the JVM from the command line, the main() method is invoked. In the main() method of your class, you pass the WordCount class to the JobConf constructor then use something called JobClient to call runJob on that JobConf, so presumably map() is invoked indirectly that way.

  • Trying to understand the code???

    Hi,
    I am trying to understand the following bit of code, currently the code puts each catalogue into a different row of the table but i want each catalogue to be put in the next column
    (so the catalogues appear across the page on the actual web page). The following code is for the page in question but im not sure how much is relevant so i will paste it all and highlight the section i think is relevant:
    <html>
    <%-- DECLARATIONS --%>
    <%@ page import="se.ibs.ns.cf.*,  se.ibs.ccf.*, se.ibs.bap.*, se.ibs.bap.util.*, se.ibs.bap.web.*,  java.util.*, se.ibs.ns.icat.*, se.ibs.bap.asw.cf.*, java.lang.*" %>
    <% ItemCatalogueBean bean = (ItemCatalogueBean)SessionHelper.getSessionObject("ItemCatalogueBean",session);
       String resourcePath = bean.getResourcePath(null);
       String title = "Product catalogue";
       String languageCode = bean.getLanguageCode();
    %>
    <%@ include file="FuncHead.jsp" %>
    <BODY class="IBSBody" onLoad="loaded = true;">
    <form method="POST" action=<%= bean.getEncodedServlet("se.ibs.ns.icat.ItemCatalogueSearchServlet", response) %> name="basicForm">
    <%@ include file="FuncSubmitScript.jsp" %>
    <%@ include file="FuncPageBegin.jsp" %>
    <div align="center">
      <table border="0" width="895">
        <tr>
          <td align="left" width="502">
    <div align="left">
      <table border="0" width="500">
        <tr>
          <td class="IBSPageTitleText" align="left" valign="top" width="238">
              <%@ include file="FuncPageTitle.jsp" %>
              <%@ include file="FuncPageTitleImage.jsp" %>
                    <br>
           On this page you can see the product catalogues. Click on one of the
           links to go to the next level. Alternatively you can click the <b>Search
           catalogue</b> button to find the products of interest.</td>
               <td width="248" valign="bottom">
                <div align="left"><%@ include file="FuncShoppingCart.jsp" %></div>
               </td>
        </tr>
      </table>
    </div></td></tr></table></div>
    <input type="submit" value="Search catalogue" name="ACTION_NONE" onClick="submitButtonOnce(this); return false">
    <hr>
    <%-- REPEAT CATALOGUES --%>
    <div align="left">
    <table border="0" width="100%">
    <% Vector catalogues = bean.getItemCatalogues();
            int cataloguesSize = catalogues.size();
               for (int i = 0; i < cataloguesSize; i++){
                      BAPItemCatalogue cat =  (BAPItemCatalogue) catalogues.elementAt(i); %>
              <%-- LINK AND MARK AS NEW --%>
                  <tr>
                         <td width="23%"><a class="IBSMenuLink" href="link" onClick="javascript:invokeLink('<%= bean.getEncodedServlet("se.ibs.ns.icat.ItemCatalogueCategoryServlet", response) %>?CODE=<%= ToolBox.encodeURLParameter(cat.getCode())%>'); return false">
                              <%= cat.getDescription(languageCode) %></a>
                         </td>
                         <td width="40%" align="right">
                              <% if (cat.isNew()) {%>
                                     <img border=0 src="<%= resourcePath %>new.gif">
                              <% } %>
                        </td>
                  </tr>
              <%--  CATALOGUES IMAGE AND INTERNET INFORMATION (text, multimedia objects,downloads, links...) --%>
                  <tr>
                         <td width="23%" valign="top" align="left">
                              <% if (bean.isAdvanced(cat) && bean.hasMultimediaImage(cat)) { %>
                                   <a href="link" onClick="javascript:invokeLink('<%= bean.getEncodedServlet("se.ibs.ns.icat.ItemCatalogueCategoryServlet", response) %>?CODE=<%= ToolBox.encodeURLParameter(cat.getCode())%>'); return false">
                                   <img border="0" src="<%= bean.getMultimediaImage(cat) %>"></a>
                        <% } else {%>     
                                   <img border="0" src="<%= resourcePath %>Catalog.gif">
                              <% } %>
                         </td>
                         <td class="IBSTextNormal" width="40%" valign="top">
                              <%= bean.getWebText(cat) %>
                         </td>
                  </tr>
                  <tr>
                         <td width="23%">
                         </td>
                         <td width="40%">
                         <% Vector mmLinks = bean.getMultimediaLinks(cat);
                      int mmLinksSize = mmLinks.size();     
                              for (int ml=0; ml<mmLinksSize; ml++){
                                   BAPCodeAndDescription mmLink = (BAPCodeAndDescription)mmLinks.elementAt(ml); %>
                                   <a class="IBSLink" href="<%= mmLink.getCode() %>" target="_blank"><%= mmLink.getDescription() %></a><br>
                         <% } %>
                   <% Vector webLinks = bean.getWebLinks(cat);
                        int webLinksSize = webLinks.size();
                        for (int wl=0; wl<webLinksSize; wl++){
                                   BAPCodeAndDescription webLink = (BAPCodeAndDescription)webLinks.elementAt(wl); %>
                                   <a class="IBSLink" href="<%= webLink.getCode() %>" target="_blank"><%= webLink.getDescription() %></a><br>
                        <% } %>
                         </td>
                  </tr>
                <%}%>
    </table>
    </div>
    <%@ include file="FuncPageLinks.jsp" %>
    <%@ include file="FuncPageEnd.jsp" %>
    </form>
    </body>
    </html>i hope someone could help me to understand this,
    thank you for your help

    You've probably already seen these, but here are a couple of links that may help.
    http://help.adobe.com/en_US/FlashPlatform//reference/actionscript/3/operators.html#array_a ccess
    http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/Array.html
    What's basically happening is that the "for" loop goes through each item in the array.  Don't be confused by the fact that two of the items in the array are Strings and one is an Integer - variable i being a String has nothing to do with the data type of the elements in the array.
    The following code:
    private function createLabels():void
         var myArray:Array = ['one', 'two', 3];
         for(var i:String in myArray)
              trace("i = " + i);
              trace(myArray[i]);
    gives the following results:
    i = 0
    one
    i = 1
    two
    i = 2
    3
    From that we can see that the "for" loop is assigning the index number of each array element, not the actual array element ('one', 'two', or 3) to the variable i.  So calling myArray[i] is the same as calling myArray[0] the first time through the loop.  This type of "for" loop is just a shorter way of doing the following, which produces exactly the same results:
    private function createLabels():void
         var myArray:Array = ['one', 'two', 3];
         for(var i:int = 0; n < myArray.length; i++)
              trace("i = " + i);
              trace(myArray[i]);
    Hope that helps.
    Cheers!

  • Trying to understand OIM - Please help

    Hello All,
    I am pretty new to OIM, just trying to understand how OIM works. For the past 4 years I was in Sun IdM and planning to switch over to OIM.
    I read some documentation, I think OIM will perform basic provisioning and it contains out of box connectors to do basic provisoning. I have some questions can anybody please help
    - Sun IdM uses Express language to develop custom workflows or forms, in OIM to develop workflows which language did you use, is it Java or any other language?
    - If I want to provision users on AS/400, HP Open VMS or AIX systems, how can I do that I don't see any out of box connectors for these resources, so in order to integrate these resources do we need to write our own custom connectors?
    - If the out of box connector does not support a specific function on a resource what are the options do we have? for example if the AD connector does not support to delete the exchange mailbox, how your going to perform this in OIM? Do we need to write a Java code for this?
    - How much Java coding is necessary in OIM?
    - Is OIM supports role based provisioning?
    Please share any information.
    Thanks in advance.

    Sun IdM uses Express language to develop custom workflows or forms, in OIM to develop workflows which language did you use, is it Java or any other language?
    - JAVA
    If I want to provision users on AS/400, HP Open VMS or AIX systems, how can I do that I don't see any out of box connectors for these resources, so in order to integrate these resources do we need to write our own custom connectors?
    - If OOTB connectors are not available then you'll have build you own connector as per Target Resource.
    If the out of box connector does not support a specific function on a resource what are the options do we have?
    - You'll have customize their connector as per your requirements or write your own
    How much Java coding is necessary in OIM?
    - We can't calculate how much java. It's totally depends on requirements how much code you'll ahve to write. But everything will be done using Java only.
    - Is OIM supports role based provisioning?
    Here Group represent Role. At a small scale it supports. But for large scale you'll have to use Oracle Role Manager as you do in Sun Role Manager.

  • Dreamweaver syntax hilight (color scheme) in Edge Code

    It's not the fact that I'm so much in love with DW syntax hilighting..
    But I'm so used to it that for code writing speed and immediacy I'd like to have the html/php/css/js code colored exactly as in Dreamweaver..
    Is there a way to achieve that?
    I also tried to load some Brackets extensions but it outputs me an error and places them into the "disabled" folder..
    Thanks a lot!!

    Edge Code is a re-branding of Brackets, but it's not updated with every new release of Brackets. You'll need to install Brackets (http://brackets.io) which has Themes built-in to the latest version (0.43), then you can install Themes extensions. If you don't see Themes that you like, you can create your own.
    Randy

  • Syntax error when running ActionFileToXML.jsx or trying to install xtools

    I have an action set (actually a few) that I would REALLY love to rename but the actions are calling "sub" actions within the action set which means that the action set name is hard-coded into the actions in many places.
    Originally, I tried to edit my actions with a hex editor to try and change the name and references but realised I was limited to renaming with the same number of characters unless I parsed the file first... so I gave up on that. Then I came across Xbytor's awesome ActionFileToXML script, but I get a syntax error when running both the To and From XML scripts at root.@date = Stdlib.toISODateString();
    I then figured I would go straight for the latest xtools instead but when running the install (in CS2) I get a rather long syntax error and so the install fails. The script mentioned that there is a log file that I should email to Xbytor, but I figured I would post here instead of bothering him directly so he has more of a choice about whether he wants to be bothered by me Or maybe someone else can answer if it is a stupid newbie problem.
    Thanks heaps!
    Gab
    ETA: I'm running CS2 on XP if that makes any difference. If so, I may be able to use a friend's Mac with CS3.

    Thanks for the quick (and very useful) response!
    I made the changes to the mentioned files and the scripts were able to
    progress further, but only until the next E4X syntax (node.@key=key;).
    Rather than continue to hack at your code, I figured I should downgrade to a
    previous version (as you also suggested).  I initially tried v1.5 and the
    ActionFileToXML worked perfectly but ActionFileFromXML failed with an
    illegal argument error.
    Before looking too deeply into the error, I figured I would try v1.6 and
    found that both the scripts were able to complete successfully. The
    resulting atn file has a couple of bugs in it (such as "Set current layer"
    having a knockout setting of  which causes the action to crash),
    but nothing that I can't just copy back from my original script.
    Thanks HEAPS for your assistance and for the awesome scripts in the first
    place! Extremely greatly appreciated!

  • Not able to open PDF or do any changes even if the PDF opens. Run Time Error is shown every time when trying to open PDF. Please help

    Hi,
    Not able to open PDF or do any changes even if the PDF opens. Run Time Error is shown every time when trying to open PDF. Please help

    Hi Shilpa ,
    Please refer to the following link and see if that helps you out.
    https://helpx.adobe.com/acrobat/kb/runtime-error-roaming-profile-workflows.html
    Are you trying to access the PDF with Acrobat or Adobe Reader?
    Regards
    Sukrit Dhingra

  • HT1926 My iTunes installer was interrupted & now it's telling me "Your system has not been modified.  To complete these operations at a later time, please run the installer again". The only problem is, I've tried to run it about six or seven times.  Can s

    My iTunes installer was interrupted &amp; now it's telling me "Your system has not been modified.  To complete these operations at a later time, please run the installer again". The only problem is, I've tried to run it about six or seven times.

    I'm not sure anyone here knows more about the Java plugin than you do...
    Were you starting the control panel from disk as administrator because it didn't work starting it through the Start menu (if you have Control Panel set to View by Category, the Java control panel is under "Programs").

  • I've tried to open itunes but just get error message saying this version of itunes has not been correctly localized for this language. Please run the english version

    Looking for some help.  I am trying to open itunes and I keep getting an error message saying "This version of itunes  has not been correctly localized for this language. Please run the english version"
    Can anyone help.

    Hi there nisbetk,
    I would recommend taking a look at the troubleshooting steps found in the article below.
    iTunes for Windows Vista or Windows 7: Troubleshooting unexpected quits, freezes, or launch issues
    http://support.apple.com/kb/ts1717
    -Griff W.

  • After restoring Windows I tries to open iTunes and got a message saying 'This version of iTunes has not been correctly localized for this language. Please run the English version.' how do I do this?

    After restoring Windows I tried to open iTunes and got a message saying 'This version of iTunes has not been correctly localized for this language. Please run the English version.
    What do I do? I don't want to lose my entire liberary!

    Hi there computerfailure,
    You may want to try removing and reinstalling iTunes as an initial troubleshooting step. Take a look at the article below for more information.
    Removing and reinstalling iTunes and other software components for Windows Vista, Windows 7, or Windows 8
    http://support.apple.com/kb/ht1923
    -Griff W.

  • Has anyone gotten a message when trying to access their itunes that says this version of Itunes has not been correctly localized for this language. Please run the English version.

    Has anyone gotten a message when trying to access their itunes that says this version of Itunes has not been correctly localized for this language. Please run the English version

    Hello didomeda
    Check out the troubleshooting steps in the first article. If it is not resolved, then try and remove iTunes and its related software in the right order and then reinstall.
    iTunes for Windows Vista or Windows 7: Troubleshooting unexpected quits, freezes, or launch issues
    http://support.apple.com/kb/ts1717
    Removing and reinstalling iTunes and other software components for Windows Vista, Windows 7, or Windows 8
    http://support.apple.com/kb/HT1923
    Thanks for using Apple Support Communities.
    Regards,
    -Norm G.

  • Trying to open itunes but a window opens and says  . this version of itunes has not been correctly localised for this language. please run. the English version. i have never had this before. please help

    Trying to open itunes but a window opens and says , this version of itunes has not been correctly localised for this language. Please run the English version. Please help.

    Hey mcooper156,
    I would try the troubleshooting steps in this first article:
    iTunes for Windows Vista or Windows 7: Troubleshooting unexpected quits, freezes, or launch issues
    http://support.apple.com/kb/TS1717
    If that doesn't resolve the issue, then I would try and remove iTunes (and its related software) then reinstall:
    Removing and reinstalling iTunes and other software components for Windows Vista, Windows 7, or Windows 8
    http://support.apple.com/kb/HT1923
    Regards,
    Delgadoh

  • Receive an A12E1 Error Code when trying to update Photoshop CC.  Running an iMac with 10.7.5.  My OS Drive is formatted to Mac OS Extended (journaled).  Any suggestions?

    Receive an A12E1 Error Code when trying to update Photoshop CC.  Running an iMac with 10.7.5.  My OS Drive is formatted to Mac OS Extended (journaled).  Any suggestions?

    A12E1 download & install error http://forums.adobe.com/thread/1289484
    -more A12E1 discussion http://forums.adobe.com/thread/1045283?tstart=0
    Case sensitive https://forums.adobe.com/thread/1483096 may also help... or may not, I'm on Windows

  • Trying to log into my account an error message "this version of itunes has not been correctly localized for this language please run English version

    Today logging into my Itunes account an error message comes up, "This versionof Itunes has not been correctly localized for this language.  Please run English version.  Don't know why Im getting this and cannot get into account at all

    For general advice see Troubleshooting issues with iTunes for Windows updates.
    The steps in the second box are a guide to removing everything related to iTunes and then rebuilding it which is often a good starting point unless the symptoms indicate a more specific approach. Review the other boxes and the list of support documents further down page in case one of them applies.
    Your library should be unaffected by these steps but there is backup and recovery advice elsewhere in the user tip.
    tt2

  • TS1717 Itunes will not open. It just says" This version of Itunes has not been correctly localized fro this language. Please run the English version". I have tried to open with Shift/Control but it will not open. Help?

    Itunes will not open from my desk top. It just says "This version of Itunes has not been correctly localized for this language. Please run the English version". How can I change versions or whatever if unable to open at all? TIA

    Let's try a repair install of iTunes.
    Restart the PC first.
    If you're using Vista or 7, now head into your Uninstall a program control panel, select "iTunes" and then click "Repair".
    If you're using XP, head into your Add or Remove Programs control panel, select "iTunes", and click "Change". Select "Repair" and click "Next" as per the following screenshot:
    Can you launch your iTunes now?

Maybe you are looking for

  • Opening a new form using a different connect string

    Hi All I have the following requirement. I want to open an new form (when button pressed) using a different connect string. I am planning to use open form so that the new form has its own session. But I donot want the new form to connect to the same

  • Writing XMP Thumbnail Metadata to AE Preset (Scripting)

    Hi guys. I am working on a script to basically insert a gif as metadata into a fx preset file. If you open Adobe bridge and browse to the After effects text presets you will see that you can click on a preset and in the preview there is an animated G

  • IMessage geht nicht immer.

    Bei vielen Freunden mit IPhone wird immer eine SMS Versand. Woran liegt das?.

  • FCP 7 Freezes During Simultaneous Finder SMB Transfer

    Hi everyone!  I'm supporting our video team who uses Final Cut Pro 7 on their new 27" iMacs (OS 10.8.5, 3.4ghz, 3tb Fusion Drive, 32gb RAM) and need some insight into a strange issue.  Every time they conduct a file transfer to our SMB servers on cam

  • Why the dialog dosent come up ?

    I have 2 files j003Dialog.java and j003.java in j003 java which is an applet, I try to pop up an dialog, but it doent work, anyone can fine the error ? it compiles.. but nothing more happends.. here is j003.java package j001; import java.applet.*; im