Revision: 20819
          http://sourceforge.net/p/jmol/code/20819
Author:   hansonr
Date:     2015-10-13 16:34:48 +0000 (Tue, 13 Oct 2015)
Log Message:
-----------
Jmol.___JmolVersion="14.3.16_2015.10.13"

code: compatibility checks with new brace-less if/for/while

note: Use of multi-line IF/END IF, FOR/END FOR, WHILE/END WHILE
      is not compatible with newer JavaScript-like single-line non-brace flow:
      
      Java/JavaScript style:
            
        function test () {
                 for (var i = 0; i < 5; i++)
                  if (i < 2) 
                    print -i 
                }
   
      VB style:
      
        function test () 
                 for (var i = 0; i < 5; i++)
                  if (i < 2) 
                    print -i
                  end if 
                 end for
                end function
   
      The compiler is set to start with assumption that Java/JavaScript
      is the active mode but switches to VB style if END XXX is found
      
Note: Use of single-line   if (...) ..... else ..... endif   is allowed
      in either mode. In this syntax, the final "endif" is optional

Note: END DATA is not affected

Modified Paths:
--------------
    trunk/Jmol/src/org/jmol/api/JmolDataManager.java
    trunk/Jmol/src/org/jmol/jvxl/readers/IsoSolventReader.java
    trunk/Jmol/src/org/jmol/renderspecial/DrawRenderer.java
    trunk/Jmol/src/org/jmol/script/ScriptCompiler.java
    trunk/Jmol/src/org/jmol/script/ScriptContext.java
    trunk/Jmol/src/org/jmol/script/ScriptFlowContext.java
    trunk/Jmol/src/org/jmol/viewer/DataManager.java
    trunk/Jmol/src/org/jmol/viewer/FileManager.java
    trunk/Jmol/src/org/jmol/viewer/Jmol.properties
    trunk/Jmol/src/org/jmol/viewer/Viewer.java

Modified: trunk/Jmol/src/org/jmol/api/JmolDataManager.java
===================================================================
--- trunk/Jmol/src/org/jmol/api/JmolDataManager.java    2015-10-12 12:31:17 UTC 
(rev 20818)
+++ trunk/Jmol/src/org/jmol/api/JmolDataManager.java    2015-10-13 16:34:48 UTC 
(rev 20819)
@@ -40,4 +40,6 @@
                int matchField, int matchFieldColumnCount, int dataField,
                int dataFieldColumnCount);
 
+  Object[] createFileData(String strModel);
+
 }

Modified: trunk/Jmol/src/org/jmol/jvxl/readers/IsoSolventReader.java
===================================================================
--- trunk/Jmol/src/org/jmol/jvxl/readers/IsoSolventReader.java  2015-10-12 
12:31:17 UTC (rev 20818)
+++ trunk/Jmol/src/org/jmol/jvxl/readers/IsoSolventReader.java  2015-10-13 
16:34:48 UTC (rev 20819)
@@ -833,12 +833,12 @@
           if ((f = validateFace(ia, ib, ic, edge, ptS1)) != null) {
             vFaces.addLast(f);
             isOK = true;
-            f.dump();
+            //f.dump();
           }
           if ((f = validateFace(ia, ib, ic, edge, ptS2)) != null) {
             vFaces.addLast(f);
-            if (!isOK)
-              f.dump();
+            //if (!isOK)
+              //f.dump();
             isOK = true;
           }
           if (isOK) {

Modified: trunk/Jmol/src/org/jmol/renderspecial/DrawRenderer.java
===================================================================
--- trunk/Jmol/src/org/jmol/renderspecial/DrawRenderer.java     2015-10-12 
12:31:17 UTC (rev 20818)
+++ trunk/Jmol/src/org/jmol/renderspecial/DrawRenderer.java     2015-10-13 
16:34:48 UTC (rev 20819)
@@ -121,7 +121,6 @@
     int nPoints = vertexCount;
     boolean isCurved = ((drawType == EnumDrawType.CURVE
         || drawType == EnumDrawType.ARROW || drawType == EnumDrawType.ARC) && 
vertexCount > 2);
-    boolean isSegments = (drawType == EnumDrawType.LINE_SEGMENT);
     if (width > 0 && isCurved || drawType == EnumDrawType.ARROW) {
       pt1f.set(0, 0, 0);
       int n = (drawType == EnumDrawType.ARC ? 2 : vertexCount);
@@ -154,12 +153,12 @@
     switch (drawType) {
     default:
       render2b(false);
-      break;
+      return;
     case CIRCULARPLANE:
       if (dmesh.scale > 0)
         width *= dmesh.scale;
       render2b(false);
-      break;
+      return;
     case CIRCLE:
       tm.transformPtScr(vertices[0], pt1i);
       if (diameter == 0 && width == 0)
@@ -174,10 +173,13 @@
         g3d.drawFilledCircle(colix, mesh.fillTriangles ? colix : 0, diameter,
             pt1i.x, pt1i.y, pt1i.z);
       }
-      break;
+      return;
+    case LINE_SEGMENT:
+      for (int i = 0; i < nPoints - 1; i++)
+        drawEdge(i, i + 1, true, vertices[i], vertices[i + 1], screens[i],
+            screens[i + 1]);
+      return;
     case CURVE:
-    case LINE_SEGMENT:
-      //unnecessary
       break;
     case ARC:
       //renderArrowHead(controlHermites[nHermites - 2], 
controlHermites[nHermites - 1], false);
@@ -199,9 +201,9 @@
       pt1f.setT(pt2);
       break;
     case ARROW:
-      if (vertexCount == 2) {
+      if (!isCurved) {
         renderArrowHead(vertices[0], vertices[1], 0, false, true, 
dmesh.isBarb);
-        break;
+        return;
       }
       int nHermites = 5;
       if (controlHermites == null || controlHermites.length < nHermites + 1) {
@@ -215,6 +217,7 @@
           controlHermites[nHermites - 1], 0, false, false, dmesh.isBarb);
       break;
     }
+    // CURVE ARC ARROW only
     if (diameter == 0)
       diameter = 3;
     if (isCurved) {
@@ -225,10 +228,8 @@
                 + (i == nPoints - 2 ? 1 : 2)]);
         i0 = i;
       }
-    } else if (isSegments) {
-      for (int i = 0; i < nPoints - 1; i++)
-        drawEdge(i, i + 1, true, vertices[i], vertices[i + 1], screens[i],
-            screens[i + 1]);
+    } else {
+      render2b(false);
     }
 
   }

Modified: trunk/Jmol/src/org/jmol/script/ScriptCompiler.java
===================================================================
--- trunk/Jmol/src/org/jmol/script/ScriptCompiler.java  2015-10-12 12:31:17 UTC 
(rev 20818)
+++ trunk/Jmol/src/org/jmol/script/ScriptCompiler.java  2015-10-13 16:34:48 UTC 
(rev 20819)
@@ -124,6 +124,7 @@
   private final static int CONTINUE = 2;
   private final static int EOL = 3;
   private final static int ERROR = 4;
+  private final static int RESTART = 5;
 
   private int tokLastMath;
   private boolean checkImpliedScriptCmd;
@@ -140,6 +141,9 @@
   private int afterWhite;
   private boolean isDotDot;
   private String ident, identLC;
+  private Lst<T> vPush = new Lst<T>();
+  private int pushCount;
+  private ScriptFlowContext lastFlowContext;
 
   synchronized ScriptContext compile(String filename, String script,
                                      boolean isPredefining, boolean isSilent,
@@ -208,7 +212,7 @@
     return (thisFunction != null ? thisFunction.isVariable(ident)
         : contextVariables != null && contextVariables.containsKey(ident));
   }
-
+  
   /**
    * allows for three kinds of comments. NOTE: closing involves asterisks and
    * slash together, but that can't be shown here.
@@ -256,9 +260,10 @@
       lastToken = token;
   }
 
+  private boolean haveENDIF;
+  
   private boolean compile0(boolean isFull) {
-    vFunctionStack = new Lst<ScriptFunction>();
-    htUserFunctions = new Hashtable<String, Boolean>();
+    haveENDIF = false;
     script = cleanScriptComments(script);
     ichToken = script.indexOf(JC.STATE_VERSION_STAMP);
     isStateScript = (ichToken >= 0);
@@ -272,160 +277,176 @@
     }
     cchScript = script.length();
 
-    // these four will be returned:
-    contextVariables = null;
-    lineNumbers = null;
-    lineIndices = null;
-    aatokenCompiled = null;
-    thisFunction = null;
-    flowContext = null;
-    errorType = null;
-    errorMessage = null;
-    errorMessageUntranslated = null;
-    errorLine = null;
+    main: while (true) {
+      vFunctionStack = new Lst<ScriptFunction>();
+      htUserFunctions = new Hashtable<String, Boolean>();
+      // these four will be returned:
+      contextVariables = null;
+      lineNumbers = null;
+      lineIndices = null;
+      aatokenCompiled = null;
+      thisFunction = null;
+      flowContext = null;
+      errorType = null;
+      errorMessage = null;
+      errorMessageUntranslated = null;
+      errorLine = null;
 
-    nSemiSkip = 0;
-    ichToken = 0;
-    ichCurrentCommand = 0;
-    ichComment = 0;
-    ichBrace = 0;
-    lineCurrent = 1;
-    iCommand = 0;
-    tokLastMath = 0;
-    lastToken = T.tokenOff;
-    vBraces = new Lst<T>();
-    vPush = new Lst<T>();
-    pushCount = 0;
-    iBrace = 0;
-    braceCount = 0;
-    parenCount = 0;
-    isDotDot = false;
-    ptSemi = -10;
-    cchToken = 0;
-    lnLength = 8;
-    lineNumbers = new short[lnLength];
-    lineIndices = new int[lnLength][2];
-    isNewSet = isSetBrace = false;
-    ptNewSetModifier = 1;
-    isShowScriptOutput = false;
-    iHaveQuotedString = false;
-    checkImpliedScriptCmd = false;
-    lltoken = new Lst<T[]>();
-    ltoken = new Lst<T>();
-    tokCommand = T.nada;
-    lastFlowCommand = null;
-    tokenAndEquals = null;
-    tokInitialPlusPlus = T.nada;
-    setBraceCount = 0;
-    bracketCount = 0;
-    forPoint3 = -1;
-    setEqualPt = Integer.MAX_VALUE;
-    endOfLine = false;
-    comment = null;
-    isEndOfCommand = false;
-    needRightParen = false;
-    theTok = T.nada;
-    short iLine = 1;
-
-    for (; true; ichToken += cchToken) {
-      if ((nTokens = ltoken.size()) == 0) {
-        if (thisFunction != null && thisFunction.chpt0 == 0)
-          thisFunction.chpt0 = ichToken;
-        ichCurrentCommand = ichToken;
-        iLine = lineCurrent;
-      }
-      if (lookingAtLeadingWhitespace())
-        continue;
+      nSemiSkip = 0;
+      ichToken = 0;
+      ichCurrentCommand = 0;
+      ichComment = 0;
+      ichBrace = 0;
+      lineCurrent = 1;
+      iCommand = 0;
+      tokLastMath = 0;
+      lastToken = T.tokenOff;
+      vBraces = new Lst<T>();
+      vPush = new Lst<T>();
+      pushCount = 0;
+      iBrace = 0;
+      braceCount = 0;
+      parenCount = 0;
+      isDotDot = false;
+      ptSemi = -10;
+      cchToken = 0;
+      lnLength = 8;
+      lineNumbers = new short[lnLength];
+      lineIndices = new int[lnLength][2];
+      isNewSet = isSetBrace = false;
+      ptNewSetModifier = 1;
+      isShowScriptOutput = false;
+      iHaveQuotedString = false;
+      checkImpliedScriptCmd = false;
+      lltoken = new Lst<T[]>();
+      ltoken = new Lst<T>();
+      tokCommand = T.nada;
+      lastFlowCommand = null;
+      tokenAndEquals = null;
+      tokInitialPlusPlus = T.nada;
+      setBraceCount = 0;
+      bracketCount = 0;
+      forPoint3 = -1;
+      setEqualPt = Integer.MAX_VALUE;
       endOfLine = false;
-      if (!isEndOfCommand) {
-        endOfLine = lookingAtEndOfLine();
-        switch (endOfLine ? OK : lookingAtComment()) {
-        case CONTINUE: //  short /*...*/ or comment to completely ignore 
-          continue;
-        case EOL: // /* .... \n ... */ -- flag as end of line but ignore
-          isEndOfCommand = true;
-          continue;
-        case OK2: // really just line-ending comment -- mark it for later 
inclusion
-          isEndOfCommand = true;
-          // start-of line comment -- include as Token.nada 
-          comment = script.substring(ichToken, ichToken + cchToken).trim();
-          break;
-        }
-        isEndOfCommand = isEndOfCommand || endOfLine || lookingAtTerminator();
-      }
+      comment = null;
+      isEndOfCommand = false;
+      needRightParen = false;
+      lastFlowCommand = null;
+      lastFlowContext = null;
 
-      if (isEndOfCommand) {
-        isEndOfCommand = false;
-        switch (processTokenList(iLine, isFull)) {
-        case CONTINUE:
-          continue;
-        case ERROR:
-          return false;
+      theTok = T.nada;
+      short iLine = 1;
+
+      for (; true; ichToken += cchToken) {
+        if ((nTokens = ltoken.size()) == 0) {
+          if (thisFunction != null && thisFunction.chpt0 == 0)
+            thisFunction.chpt0 = ichToken;
+          ichCurrentCommand = ichToken;
+          iLine = lineCurrent;
         }
-        checkImpliedScriptCmd = false;
-        if (ichToken < cchScript)
+        if (lookingAtLeadingWhitespace())
           continue;
-        if (flowContext != null) {
-          ichCurrentCommand = ichToken = cchScript;
-          while (flowContext != null) {
-            fixFlowAddLine(flowContext);
-            if (flowContext.checkForceEndIf(0)) {
-              forceFlowEnd(flowContext.token);
-              processTokenList(iLine, isFull);
-            } else {
-              lineCurrent = (short) flowContext.lineStart; 
-              iCommand = flowContext.pt0;
-              ichCurrentCommand = lineIndices[iCommand][0];
-              ichToken = ichEnd = lineIndices[iCommand][1];
-              return errorStr(ERROR_missingEnd,
-                      (flowContext.function == null ? 
T.nameOf(flowContext.token.tok)
-                          : flowContext.function.getSignature()));            }
+        endOfLine = false;
+        if (!isEndOfCommand) {
+          endOfLine = lookingAtEndOfLine();
+          switch (endOfLine ? OK : lookingAtComment()) {
+          case CONTINUE: //  short /*...*/ or comment to completely ignore 
+            continue;
+          case EOL: // /* .... \n ... */ -- flag as end of line but ignore
+            isEndOfCommand = true;
+            continue;
+          case OK2: // really just line-ending comment -- mark it for later 
inclusion
+            isEndOfCommand = true;
+            // start-of line comment -- include as Token.nada 
+            comment = script.substring(ichToken, ichToken + cchToken).trim();
+            break;
           }
-          lltoken.addLast(new T[]{T.o(T.nada, "// end of script")});
+          isEndOfCommand = isEndOfCommand || endOfLine || 
lookingAtTerminator();
         }
-        setAaTokenCompiled();
-        return true;
-      }
 
-      if (nTokens > 0 && !isDotDot) {
-        switch (checkSpecialParameterSyntax()) {
-        case CONTINUE:
-          continue;
-        case ERROR:
-          return false;
+        if (isEndOfCommand) {
+          isEndOfCommand = false;
+          switch (processTokenList(iLine, isFull)) {
+          case CONTINUE:
+            continue;
+          case ERROR:
+            return false;
+          }
+          checkImpliedScriptCmd = false;
+          if (ichToken < cchScript)
+            continue;
+          if (flowContext != null) {
+            ichCurrentCommand = ichToken = cchScript;
+            while (flowContext != null) {
+              fixFlowAddLine(flowContext);
+              if (!haveENDIF && flowContext.checkForceEndIf(0)) {
+                forceFlowEnd(flowContext.token);
+                processTokenList(iLine, isFull);
+              } else {
+                lineCurrent = (short) flowContext.lineStart;
+                iCommand = flowContext.pt0;
+                ichCurrentCommand = lineIndices[iCommand][0];
+                ichToken = ichEnd = lineIndices[iCommand][1];
+                return errorStr(
+                    ERROR_missingEnd,
+                    (flowContext.function == null ? T
+                        .nameOf(flowContext.token.tok) : flowContext.function
+                        .getSignature()));
+              }
+            }
+            lltoken.addLast(new T[] { T.o(T.nada, "// end of script") });
+          }
+          setAaTokenCompiled();
+          return true;
         }
-      }
-      if (lookingAtLookupToken(ichToken)) {
-        switch (parseKnownToken()) {
-        case CONTINUE:
-          continue;
-        case ERROR:
-          return false;
+
+        if (nTokens > 0 && !isDotDot) {
+          switch (checkSpecialParameterSyntax()) {
+          case CONTINUE:
+            continue;
+          case ERROR:
+            return false;
+          }
         }
-        switch (parseCommandParameter(iLine, isFull)) {
-        case CONTINUE:
+        if (lookingAtLookupToken(ichToken)) {
+          switch (parseKnownToken()) {
+          case CONTINUE:
+            continue;
+          case ERROR:
+            return false;
+          case RESTART:
+            haveENDIF = true;
+            continue main;
+          }
+          switch (parseCommandParameter(iLine, isFull)) {
+          case CONTINUE:
+            continue;
+          case ERROR:
+            return false;
+          case RESTART:
+            haveENDIF = true;
+            continue main;
+          }
+          addTokenToPrefix(theToken);
           continue;
-        case ERROR:
-          return false;
         }
-        addTokenToPrefix(theToken);
-        continue;
-      }
-      if (nTokens == 0 || (isNewSet || isSetBrace)
-          && nTokens == ptNewSetModifier) {
-        if (nTokens == 0) {
-          if (lookingAtString(true)) {
-            addTokenToPrefix(setCommand(T.tokenScript));
-            cchToken = 0;
-            continue;
+        if (nTokens == 0 || (isNewSet || isSetBrace)
+            && nTokens == ptNewSetModifier) {
+          if (nTokens == 0) {
+            if (lookingAtString(true)) {
+              addTokenToPrefix(setCommand(T.tokenScript));
+              cchToken = 0;
+              continue;
+            }
+            if (lookingAtImpliedString(true, true, true))
+              ichEnd = ichToken + cchToken;
           }
-          if (lookingAtImpliedString(true, true, true))
-            ichEnd = ichToken + cchToken;
+          return commandExpected();
         }
-        return commandExpected();
+        return errorStr(ERROR_unrecognizedToken,
+            script.substring(ichToken, ichToken + 1));
       }
-      return errorStr(ERROR_unrecognizedToken,
-          script.substring(ichToken, ichToken + 1));
     }
   }
 
@@ -462,14 +483,21 @@
     if (parenCount > 0 || bracketCount > 0)
       return true;
     switch (tokCommand) {
+    case T.function:
+    case T.parallel:
+      flowContext.forceEndIf = false;
+      return false;
     case T.forcmd:
     case T.whilecmd:
     case T.ifcmd:
+      //$FALL-THROUGH$
     case T.elsecmd:
     case T.elseif:
+      if (!haveENDIF) {
       // end of a line, after (...), no {
-      flowContext.addLine = 1;
-      flowContext.forceEndIf = true;
+        flowContext.addLine = 1;
+        flowContext.forceEndIf = true;
+      }
       return false;
     case T.set:
       if (nTokens > 1 && ltoken.get(1).tok == T.echo)
@@ -696,8 +724,7 @@
           iBrace++;
           T t = ContextToken.newContext(true);
           addTokenToPrefix(setCommand(t));
-          pushCount++;
-          vPush.addLast(t);
+          pushContext(t);
           vBraces.addLast(tokenCommand);
         } else {
           parenCount = setBraceCount = 0;
@@ -706,6 +733,7 @@
             ltoken.remove(0);
           lastFlowCommand = null;
           lastFlowContext = flowContext;
+//          lastFlowImplicitEnd = flowContext.nextFlowImplicitEnd;
         }
       }
       if (bracketCount > 0 || setBraceCount > 0 || parenCount > 0
@@ -785,14 +813,14 @@
 
     }
     if (endOfLine) {
-      if (flowContext != null && flowContext.checkForceEndIf(-1)) {
+      if (!haveENDIF && flowContext != null && 
flowContext.checkForceEndIf(-1)) {
         boolean isOneLine = (flowContext.addLine == 0); // if (....) xxxxx;
         if (isComment) {
           if (!isOneLine) {
             flowContext.addLine++;
             flowContext.forceEndIf = true;
           }
-        } else if (n > 0 || isOneLine) {
+        } else if (n > 0 && !haveENDIF || isOneLine) {
           forceFlowEnd(flowContext.token);
           if (!isOneLine) {
             lastFlowContext.forceEndIf = true;
@@ -827,6 +855,11 @@
     return OK;
   }
 
+  private void pushContext(T t) {
+    pushCount++;
+    vPush.addLast(t);
+  }
+
   /**
    * Check for improperly parsed implied script command:
    * 
@@ -1424,10 +1457,14 @@
     case T.end:
       if (tokCommand == T.cgo || tokCommand == T.capture && nTokens == 1)
         return OK;
+      if (!haveENDIF)
+        return RESTART;
+      // end for, end function
       //$FALL-THROUGH$
     case T.endifcmd:
       if (flowContext != null)
         flowContext.forceEndIf =  false;
+      
       //$FALL-THROUGH$
     case T.elsecmd:
       if (nTokens > 0) {
@@ -1575,7 +1612,7 @@
         ltoken.add(0, tokenCommand);
     }
     nTokens = ltoken.size();
-    addTokenToPrefix(T.tokenEquals);
+    addTokenToPrefix (T.tokenEquals);
     setEqualPt = 0;
     for (int i = 1; i < nTokens; i++)
       addTokenToPrefix(ltoken.get(i));
@@ -1631,6 +1668,8 @@
         braceCount++;
         isEndOfCommand = true;
         return OK;
+      case T.end:
+        return OK;
       case T.elsecmd:
       case T.elseif:
         // unexpectedly allows if (x) { print x else print y}
@@ -1667,8 +1706,14 @@
         //$FALL-THROUGH$
       default:
         if (isFlowCmd) {
-          if (!checkFlowCommand((String) tokenCommand.value))
+          switch (checkFlowCommand((String) tokenCommand.value)) {
+          case ERROR:
             return ERROR;
+          case CONTINUE:
+            return CONTINUE;
+          case RESTART:
+            return RESTART;
+          }
           theToken = tokenCommand;
           if (theTok == T.casecmd) {
             addTokenToPrefix(tokenCommand);
@@ -1676,7 +1721,7 @@
           }
           return OK;
         }
-        if (flowContext != null && flowContext.addLine > 0) {
+        if (flowContext != null && !haveENDIF && flowContext.addLine > 0) {
           fixFlowAddLine(flowContext);
           while (flowContext != null) {
             if (flowContext.checkForceEndIf(0)) {
@@ -1832,7 +1877,7 @@
     case T.end:
       if (nTokens != 1)
         return ERROR(ERROR_badArgumentCount);
-      if (!checkFlowEnd(theTok, ident, ichCurrentCommand))
+      if (!checkFlowEnd(theTok, ident, ichCurrentCommand, true))
         return ERROR;
       if (theTok == T.function || theTok == T.parallel) {
         return CONTINUE;
@@ -2043,10 +2088,6 @@
     return true;
   }
 
-  Lst<T> vPush = new Lst<T>();
-  int pushCount;
-  private ScriptFlowContext lastFlowContext;
-
   private int checkFlowEndBrace() {
 
     if (iBrace <= 0 || vBraces.get(iBrace - 1).tok != T.rightbrace)
@@ -2081,34 +2122,36 @@
     return forceFlowEnd(token);
   }
   private int forceFlowEnd(T token) {
-    // need to be able to UNDO this.
     T t0 = tokenCommand;
     lastFlowContext = flowContext;
-    setCommand(T.o(T.end, "end"));
-    if (!checkFlowCommand("end"))
-      return T.nada;
-    addTokenToPrefix(tokenCommand);
+    token = flowStart(token);
+    if (!checkFlowEnd(token.tok, (String) token.value, ichBrace, false))
+      return ERROR;
+    switch (token.tok){
+    case T.function:
+    case T.parallel:
+    case T.trycmd:
+      break;
+    default:
+      addTokenToPrefix(token);
+    }
+    setCommand(t0);
+    return CONTINUE;
+  }
+
+  private T flowStart(T token) {
     switch (token.tok) {
     case T.ifcmd:
     case T.elsecmd:
     case T.elseif:
-      token = T.tokenIf;
-      break;
+      return T.tokenIf;
     case T.defaultcmd:
     case T.casecmd:
-      token = T.tokenSwitch;
-      break;
+      return T.tokenSwitch;
     default:
-      token = T.getTokenFromName((String) token.value);
-      break;
+      return T.getTokenFromName((String) token.value);
     }
-    if (!checkFlowEnd(token.tok, (String) token.value, ichBrace))
-      return ERROR;
-    if (token.tok != T.function && token.tok != T.parallel
-        && token.tok != T.trycmd)
-      addTokenToPrefix(token);
-    setCommand(t0);
-    return CONTINUE;
+    
   }
 
   static boolean isBreakableContext(int tok) {
@@ -2116,143 +2159,158 @@
         || tok == T.casecmd || tok == T.defaultcmd;
   }
 
-  private boolean checkFlowCommand(String ident) {
+  private int checkFlowCommand(String ident) {
     int pt = lltoken.size();
-    boolean isEnd = false;
-    boolean isNew = true;
     switch (tokCommand) {
+    case T.endifcmd:
+      if (!isFlowIfContextOK(flowContext, tokCommand)){
+        if (!haveENDIF)
+          return RESTART;
+        errorStr(ERROR_badContext, ident);
+        return ERROR;
+      }
+      flowContext.token.intValue = flowContext.setPt0(pt, false);
+      setFlowEnd(tokCommand, ident);
+      flowContext = flowContext.parent;
+      return OK;
+    case T.breakcmd:
+    case T.continuecmd:
+      ScriptFlowContext f = (flowContext == null ? null : flowContext
+          .getBreakableContext(0));
+      if (tokCommand == T.continuecmd)
+        while (f != null && f.token.tok != T.forcmd
+            && f.token.tok != T.whilecmd)
+          f = f.parent;
+      if (f == null) {
+        errorStr(ERROR_badContext, ident);
+        return ERROR;
+      }
+      setCommand(T.tv(tokCommand, f.pt0, ident)); //copy
+      return OK;
     case T.function:
     case T.parallel:
-      if (flowContext != null)
-        return errorStr(ERROR_badContext, T.nameOf(tokCommand));
+      if (flowContext != null) {
+        errorStr(ERROR_badContext, T.nameOf(tokCommand));
+        return ERROR;
+      }
       break;
-    case T.end:
-      if (flowContext == null)
-        return errorStr(ERROR_badContext, ident);
-      isEnd = true;
-      if (flowContext.token.tok != T.function
-          && flowContext.token.tok != T.parallel
-          && flowContext.token.tok != T.trycmd)
-        setCommand(T.tv(tokCommand,
-            (flowContext.ptDefault > 0 ? flowContext.ptDefault
-                : -flowContext.pt0), ident)); //copy
-      break;
+      
+    case T.ifcmd:
+      //$FALL-THROUGH$
     case T.trycmd:
     case T.catchcmd:
-      break;
     case T.forcmd:
-    case T.ifcmd:
     case T.process:
     case T.switchcmd:
     case T.whilecmd:
       break;
     case T.elseif:
     case T.elsecmd:
-      if (flowContext != null && !isFlowIfContextOK(flowContext, tokCommand))
+      if (flowContext != null && !isFlowIfContextOK(flowContext, tokCommand)) {
         flowContext = flowContext.parent;
-      if (!isFlowIfContextOK(flowContext, tokCommand))
-        return errorStr(ERROR_badContext, ident);
+      }
+      if (!isFlowIfContextOK(flowContext, tokCommand)) {
+        if (!haveENDIF)
+          return RESTART;
+        errorStr(ERROR_badContext, ident);
+        return ERROR;
+      }
       flowContext.token.intValue = flowContext.setPt0(pt, false);
       break;
-    case T.endifcmd:
-      isEnd = true;
-      if (flowContext == null || flowContext.token.tok != T.ifcmd
-          && flowContext.token.tok != T.process
-          && flowContext.token.tok != T.elsecmd
-          && flowContext.token.tok != T.elseif)
-        return errorStr(ERROR_badContext, ident);
-      break;
-    case T.breakcmd:
-    case T.continuecmd:
-      isNew = false;
-      ScriptFlowContext f = (flowContext == null ? null : flowContext
-          .getBreakableContext(0));
-      if (tokCommand == T.continuecmd)
-        while (f != null && f.token.tok != T.forcmd
-            && f.token.tok != T.whilecmd)
-          f = f.parent;
-      if (f == null)
-        return errorStr(ERROR_badContext, ident);
-      setCommand(T.tv(tokCommand, f.pt0, ident)); //copy
-      break;
     case T.casecmd:
     case T.defaultcmd:
       if (flowContext == null
           || flowContext.token.tok != T.switchcmd
           && flowContext.token.tok != T.casecmd
           && (tokCommand == T.defaultcmd ? flowContext.ptDefault > 0
-              : flowContext.token.tok != T.defaultcmd))
-        return errorStr(ERROR_badContext, ident);
+              : flowContext.token.tok != T.defaultcmd)) {
+        errorStr(ERROR_badContext, ident);
+        return ERROR;
+      }
       flowContext.token.intValue = flowContext.setPt0(pt,
           tokCommand == T.defaultcmd);
       break;
     }
-    if (isEnd) {
-      flowContext.token.intValue = (tokCommand == T.catchcmd ? -pt : pt);
-      if (tokCommand == T.endifcmd)
-        flowContext = flowContext.parent;
-    } else if (isNew) {
-      ContextToken ct = ContextToken.newCmd(tokCommand, tokenCommand.value);
-      if (tokCommand == T.switchcmd)
-        ct.addName("_var");
-      setCommand(ct); //copy
-      switch (tokCommand) {
-      case T.trycmd:
-        flowContext = new ScriptFlowContext(this, ct, pt, flowContext);
-        if (thisFunction != null)
-          vFunctionStack.add(0, thisFunction);
-        thisFunction = newScriptParallelProcessor("", tokCommand);
-        flowContext.setFunction(thisFunction);
-        pushCount++;
-        vPush.addLast(ct);
-        break;
-      case T.casecmd:
-      case T.defaultcmd:
-        ct.contextVariables = flowContext.token.contextVariables;
-        //$FALL-THROUGH$
-      case T.elsecmd:
-      case T.elseif:
-        flowContext.token = ct;
-        break;
-      case T.process:
-      case T.forcmd:
-      case T.whilecmd:
-      case T.catchcmd:
-        pushCount++;
-        vPush.addLast(ct);
-        //$FALL-THROUGH$
-      case T.ifcmd:
-      case T.switchcmd:
-      default:
-        flowContext = new ScriptFlowContext(this, ct, pt, flowContext);
-        break;
-      }
+    // we do need a new context token
+    ContextToken ct = ContextToken.newCmd(tokCommand, tokenCommand.value);
+    if (tokCommand == T.switchcmd)
+      ct.addName("_var");
+    setCommand(ct); //copy
+    switch (tokCommand) {
+    case T.trycmd:
+      flowContext = new ScriptFlowContext(this, ct, pt, flowContext,
+          ichCurrentCommand, lineCurrent);
+      if (thisFunction != null)
+        vFunctionStack.add(0, thisFunction);
+      thisFunction = newScriptParallelProcessor("", tokCommand);
+      flowContext.setFunction(thisFunction);
+      pushContext(ct);
+      break;
+    case T.casecmd:
+    case T.defaultcmd:
+      ct.contextVariables = flowContext.token.contextVariables;
+      //$FALL-THROUGH$
+    case T.elsecmd:
+    case T.elseif:
+      flowContext.token = ct;
+      break;
+    case T.process:
+    case T.forcmd:
+    case T.whilecmd:
+    case T.catchcmd:
+      pushContext(ct);
+      //$FALL-THROUGH$
+    case T.ifcmd:
+    case T.switchcmd:
+    default:
+      flowContext = new ScriptFlowContext(this, ct, pt, flowContext,
+          ichCurrentCommand, lineCurrent);
     }
-    return true;
+    return OK;
   }
 
-  private boolean isFlowIfContextOK(ScriptFlowContext f, int tokCommand) {
-    return (f != null && (f.token.tok == T.ifcmd
-        || f.token.tok == T.elseif
-        || f.token.tok == T.elsecmd && tokCommand != T.elsecmd));
+  private void setFlowEnd(int tokCommand, String ident) {
+    setCommand(T.tv(tokCommand,
+        (flowContext.ptDefault > 0 ? flowContext.ptDefault
+            : -flowContext.pt0), ident)); //copy
   }
 
-  private boolean checkFlowEnd(int tok, String ident, int pt1) {
-    if (flowContext == null || flowContext.token.tok != tok) {
-      boolean isOK = true;
-      switch (tok) {
-      case T.ifcmd:
-        isOK = (flowContext.token.tok == T.elsecmd || flowContext.token.tok == 
T.elseif);
-        break;
-      case T.switchcmd:
-        isOK = (flowContext.token.tok == T.casecmd || flowContext.token.tok == 
T.defaultcmd);
-        break;
-      default:
-        isOK = false;
+  private boolean isFlowIfContextOK(ScriptFlowContext f, int tokCommand) {
+    switch (f == null ? T.nada : f.token.tok) {
+    case T.elsecmd:
+      return tokCommand != T.elsecmd;
+    case T.ifcmd:
+    case T.elseif:
+      return true;
+    }
+    return false;
+  }  
+
+  private boolean checkFlowEnd(int tok, String ident, int pt1,
+                               boolean isExplicitEnd) {
+    if (isExplicitEnd) {
+        if (flowContext == null)
+          return errorStr(ERROR_badContext, "end " + ident);
+        flowContext.addLine = 0;
+        flowContext.forceEndIf = false;
+        switch (flowContext.token.tok) {
+        case T.function:
+        case T.parallel:
+        case T.trycmd:
+          
+          break;
+        default:
+          setFlowEnd(T.end, "end");
+          ltoken.set(0, tokenCommand);
       }
-      if (!isOK)
-        return errorStr(ERROR_badContext, "end " + ident);
+    } else {
+      setFlowEnd(T.end, "end");
+      addTokenToPrefix(tokenCommand);
     }
+    if (flowContext == null || tok != flowContext.tok0)
+      return errorStr(ERROR_badContext, "end " + ident);
+    int pt = lltoken.size();
+    flowContext.token.intValue = (tokCommand == T.catchcmd ? -pt : pt);
     switch (tok) {
     case T.ifcmd:
     case T.switchcmd:
@@ -2261,7 +2319,8 @@
     case T.forcmd:
     case T.process:
     case T.whilecmd:
-      vPush.remove(--pushCount);
+      if (!isExplicitEnd)
+        vPush.remove(--pushCount);
       break;
     case T.parallel:
     case T.function:

Modified: trunk/Jmol/src/org/jmol/script/ScriptContext.java
===================================================================
--- trunk/Jmol/src/org/jmol/script/ScriptContext.java   2015-10-12 12:31:17 UTC 
(rev 20818)
+++ trunk/Jmol/src/org/jmol/script/ScriptContext.java   2015-10-13 16:34:48 UTC 
(rev 20819)
@@ -144,13 +144,14 @@
     }
     pointers = new int[aa.length];
     for (int i = pointers.length; --i >= 0;)
-      pointers[i] = aa[i][0].intValue;
+      pointers[i] = (aa[i] == null ? -1 : aa[i][0].intValue);
   }
   
   T[][] restoreTokens() {
     if (pointers != null)
       for (int i = pointers.length; --i >= 0;)
-        aatoken[i][0].intValue = pointers[i];
+        if (aatoken[i] != null)
+          aatoken[i][0].intValue = pointers[i];
     return aatoken;
   }
 

Modified: trunk/Jmol/src/org/jmol/script/ScriptFlowContext.java
===================================================================
--- trunk/Jmol/src/org/jmol/script/ScriptFlowContext.java       2015-10-12 
12:31:17 UTC (rev 20818)
+++ trunk/Jmol/src/org/jmol/script/ScriptFlowContext.java       2015-10-13 
16:34:48 UTC (rev 20819)
@@ -150,13 +150,19 @@
   boolean forceEndIf = true;
   String ident;
   int addLine;
+  int tok0;
+  public int ichCommand;
+  short line0;
   
-  ScriptFlowContext(ScriptCompiler compiler, ContextToken token, int pt0, 
ScriptFlowContext parent) {
+  ScriptFlowContext(ScriptCompiler compiler, ContextToken token, int pt0, 
ScriptFlowContext parent, int ich, short line0) {
     this.compiler = compiler;
     this.token = token;
+    tok0 = token.tok;
     this.ident = (String)token.value;
     this.pt0 = pt0;
+    this.line0 = line0;
     this.parent = parent;
+    ichCommand = ich;
     lineStart = ptLine = this.compiler.lineCurrent;
     commandStart = ptCommand = this.compiler.iCommand;
     //System.out.println ("FlowContext: init " + this);  

Modified: trunk/Jmol/src/org/jmol/viewer/DataManager.java
===================================================================
--- trunk/Jmol/src/org/jmol/viewer/DataManager.java     2015-10-12 12:31:17 UTC 
(rev 20818)
+++ trunk/Jmol/src/org/jmol/viewer/DataManager.java     2015-10-13 16:34:48 UTC 
(rev 20819)
@@ -347,4 +347,13 @@
     return haveData;
   }
 
+  @Override
+  public Object[] createFileData(String strModel) {
+    Object[] o = new Object[4];
+    o[JmolDataManager.DATA_LABEL] = "model";
+    o[JmolDataManager.DATA_VALUE] = strModel;
+    o[JmolDataManager.DATA_TYPE] = Integer.valueOf(DATA_TYPE_STRING);
+    return o;
+  }
+
 }

Modified: trunk/Jmol/src/org/jmol/viewer/FileManager.java
===================================================================
--- trunk/Jmol/src/org/jmol/viewer/FileManager.java     2015-10-12 12:31:17 UTC 
(rev 20818)
+++ trunk/Jmol/src/org/jmol/viewer/FileManager.java     2015-10-13 16:34:48 UTC 
(rev 20819)
@@ -612,14 +612,16 @@
       BufferedInputStream bis = (BufferedInputStream) t;
       if (Rdr.isGzipS(bis))
         bis = Rdr.getUnzippedInputStream(vwr.getJzt(), bis);
-      if (forceInputStream)
-        return  bis;
+      // if we have a subFileList, we don't want to return the stream for the 
zip file itself
+      if (forceInputStream && subFileList == null)
+        return bis;
       if (Rdr.isCompoundDocumentS(bis)) {
         // very specialized reader; assuming we have a Spartan document here
         GenericBinaryDocument doc = (GenericBinaryDocument) Interface
             .getInterface("javajs.util.CompoundDocument", vwr, "file");
         doc.setStream(vwr.getJzt(), bis, true);
-        return Rdr.getBR(doc.getAllDataFiles("Molecule", "Input").toString());
+        String s = doc.getAllDataFiles("Molecule", "Input").toString();
+        return (forceInputStream ? Rdr.getBIS(s.getBytes()) : Rdr.getBR(s));
       }
       if (Rdr.isPickleS(bis))
         return bis;
@@ -631,7 +633,7 @@
             forceInputStream);
         return (o instanceof String ? Rdr.getBR((String) o) : o);
       }
-      return Rdr.getBufferedReader(bis, null);
+      return (forceInputStream ? bis : Rdr.getBufferedReader(bis, null));
     } catch (Exception ioe) {
       return ioe.toString();
     }

Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties
===================================================================
--- trunk/Jmol/src/org/jmol/viewer/Jmol.properties      2015-10-12 12:31:17 UTC 
(rev 20818)
+++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties      2015-10-13 16:34:48 UTC 
(rev 20819)
@@ -43,8 +43,9 @@
 }
 
 
-such that any call to yyy outside of the SPT sees those variable "xxx"?
+such that any call to yyy outside of the SPT sees variable x from xxx.spt?
 
+
 TODO: there is something wrong with JSmol and zoneDemo. Just slow? or what?
 
 TODO: curved arrows overextend and with width settings do not truncate shaft 
properly
@@ -63,8 +64,49 @@
 
 
 
-Jmol.___JmolVersion="14.3.16_2015.10.11"
+Jmol.___JmolVersion="14.3.16_2015.10.13"
 
+code: compatibility checks with new brace-less if/for/while
+
+note: Use of multi-line IF/END IF, FOR/END FOR, WHILE/END WHILE
+      is not compatible with newer JavaScript-like single-line non-brace flow:
+      
+      Java/JavaScript style:
+            
+        function test () {
+                for (var i = 0; i < 5; i++)
+                 if (i < 2) 
+                   print -i 
+               }
+   
+      VB style:
+      
+        function test () 
+                for (var i = 0; i < 5; i++)
+                 if (i < 2) 
+                   print -i
+                 end if 
+                end for
+               end function
+   
+      The compiler is set to start with assumption that Java/JavaScript
+      is the active mode but switches to VB style if END XXX is found
+      
+Note: Use of single-line   if (...) ..... else ..... endif   is allowed
+      in either mode. In this syntax, the final "endif" is optional
+
+Note: END DATA is not affected
+
+JmolVersion="14.3.16_2015.10.12"
+
+code fix: debug comments in isosurface solvent slowing it down significantly
+
+bug fix: PARALLEL/PROCESS not working
+bug fix: SHOW DATA does not return model data
+bug fix: draw CURVE pt1 pt2   does not work
+bug fix: pmesh command cannot read files from zip files 
+         because "binary" option is set, and FileManager is returning the 
wrong input stream 
+
 new feature: unitcell() function
   -- returns unitcell as an array in the form [origin, va, vb, vc]
   -- first parameter is optional unitcell itself; absence uses current model's 
unit cell. 

Modified: trunk/Jmol/src/org/jmol/viewer/Viewer.java
===================================================================
--- trunk/Jmol/src/org/jmol/viewer/Viewer.java  2015-10-12 12:31:17 UTC (rev 
20818)
+++ trunk/Jmol/src/org/jmol/viewer/Viewer.java  2015-10-13 16:34:48 UTC (rev 
20819)
@@ -1447,7 +1447,7 @@
 
   @Override
   public BufferedInputStream getBufferedInputStream(String fullPathName) {
-    // used by some JVXL readers
+    // used by some JVXL readers, also OutputManager.writeZipFile and 
ScriptManager.openFileAsync
     return fm.getBufferedInputStream(fullPathName);
   }
 
@@ -1869,7 +1869,9 @@
     if (haveFileData) {
       strModel = (String) htParams.get("fileData");
       if (htParams.containsKey("isData")) {
-        return loadInlineScript(strModel, '\0', isAppend, htParams);
+        Object o = loadInlineScript(strModel, '\0', isAppend, htParams);
+        lastData = (g.preserveState ? 
getDataManager().createFileData(strModel) : null);
+        return o;
       }
     } else if (isString) {
       strModel = ms.getInlineData(-1);

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
_______________________________________________
Jmol-commits mailing list
Jmol-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-commits

Reply via email to