Changeset 7 for trunk/src/org/expeditee/actions/Simple.java
- Timestamp:
- 05/01/08 12:26:53 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/actions/Simple.java
r4 r7 13 13 import org.expeditee.gui.FrameGraphics; 14 14 import org.expeditee.gui.FrameIO; 15 import org.expeditee.gui.FrameKeyboardActions; 15 16 import org.expeditee.gui.FrameMouseActions; 16 17 import org.expeditee.gui.FrameUtils; … … 18 19 import org.expeditee.items.Dot; 19 20 import org.expeditee.items.Item; 21 import org.expeditee.items.ItemUtils; 20 22 import org.expeditee.items.Line; 21 23 import org.expeditee.items.Text; … … 59 61 }; 60 62 61 private static final String BREAK_TEXT = "exitrepeat"; 62 63 private static final String CONTINUE_TEXT = "nextrepeat"; 63 private static final String BREAK2_TEXT = "exitrepeat"; 64 65 private static final String BREAK_TEXT = "break"; 66 67 private static final String CONTINUE2_TEXT = "nextrepeat"; 68 69 private static final String CONTINUE_TEXT = "continue"; 64 70 65 71 private static final String RETURN_TEXT = "return"; … … 155 161 156 162 FrameIO.SaveFrame(DisplayIO.getCurrentFrame(), false); 157 158 163 FrameGraphics.DisplayMessage("Starting test suite: " + frameset, 159 164 Color.CYAN); … … 229 234 230 235 private static void FlagError(Item item) { 231 item.setColor(Color.CYAN);236 // item.setColor(Color.CYAN); 232 237 FrameUtils.DisplayFrame(item.getParent().getFrameName(), true); 238 item.showHighlight(true, Color.CYAN); 233 239 FrameIO.SaveFrame(item.getParent()); 234 240 } … … 306 312 Frame frame = i.getParent(); 307 313 308 if (i == frame.getTitle() || i == frame.get Name() || i.isAnnotation()) {314 if (i == frame.getTitle() || i == frame.getFrameNameItem() || i.isAnnotation()) { 309 315 return false; 310 316 } … … 319 325 * @return 320 326 */ 321 private static String[] parseStatement(String statement) { 322 return statement.split(TOKEN_SEPARATOR); 327 private static String[] parseStatement(Text code) throws Exception { 328 String statement = code.getTextNoList(); 329 ArrayList<String> tokens = new ArrayList<String>(); 330 331 for (int i = 0; i < statement.length(); i++) { 332 char c = statement.charAt(i); 333 // ignore spaces 334 if (c != ' ') { 335 int startOfToken = i; 336 if (c == '\"') { 337 int endOfToken = statement.length() - 1; 338 // find the end of the string literal 339 while (statement.charAt(endOfToken) != '\"') 340 endOfToken--; 341 if (endOfToken > startOfToken) { 342 tokens.add(statement.substring(startOfToken, 343 endOfToken + 1)); 344 } else { 345 throw new Exception("Expected matching \" " 346 + code.toString()); 347 } 348 break; 349 } else if (c == '#' || c == '/') { 350 break; 351 } else { 352 // read in a normal token 353 while (++i < statement.length() 354 && statement.charAt(i) != ' ') 355 ; 356 tokens.add(statement.substring(startOfToken, i) 357 .toLowerCase()); 358 } 359 } 360 } 361 362 String[] a = new String[tokens.size()]; 363 a = tokens.toArray(a); 364 code.setProcessedCode(a); 365 return a; 323 366 } 324 367 … … 464 507 private static Status RunItem(Text code, Context context, 465 508 Status lastItemStatus) throws Exception { 466 String codeText = code.getTextNoList(); 509 510 String[] tokens = code.getProcessedCode(); 511 512 if (tokens == null) { 513 tokens = parseStatement(code); 514 } 515 467 516 // Comments without links are a no-op 468 if ( codeText.startsWith("#") || codeText.startsWith("//")) {517 if (tokens.length == 0) { 469 518 if (code.getLink() == null) 470 519 return Status.OK; … … 473 522 } 474 523 475 // Now check for code statements476 codeText = codeText.trim();477 String[] tokens = parseStatement(codeText.toLowerCase());478 524 // At present only set statements can have literals so they 479 525 // are the only statements that we have to worry about string 480 526 // literals 481 assert (tokens.length > 0);482 527 if (tokens[0].equals("call") && tokens.length >= 2) { 483 528 return Call(tokens, code, context); … … 497 542 // check for strings enclosed in quotes 498 543 if (tokens[2].startsWith("\"")) { 499 if (tokens[tokens.length - 1].endsWith("\"")) { 500 context.getPrimitives().setValue( 501 tokens[1], 502 new SString(codeText.substring(codeText 503 .indexOf("\"") + 1, codeText 504 .length() - 1))); 505 return Status.OK; 506 } else 507 throw new Exception("Expected matching \" " 508 + code.toString()); 544 context.getPrimitives().setValue( 545 tokens[1], 546 new SString(tokens[2].substring(1, 547 tokens[2].length() - 1))); 548 return Status.OK; 549 509 550 // set a literal 510 551 } else if (tokens.length == 3) { … … 517 558 throw new RuntimeException(e.getMessage()); 518 559 } 560 } else if (tokens[0].equals("setframevalue")) { 561 assertMinParametreCount(tokens, 4); 562 assertVariableType(tokens[1], 1, SPointer.framePrefix); 563 564 // Get the attribute to be searched for on the target frame 565 Frame targetFrame = (Frame) context.getPointers().getVariable( 566 tokens[1]).getValue(); 567 String targetAttribute = context.getPrimitives() 568 .getStringValue(tokens[2]).toLowerCase() 569 + ":"; 570 String value = context.getPrimitives() 571 .getStringValue(tokens[3]); 572 Boolean found = false; 573 Text attributeItem = null; 574 Text valueItem = null; 575 // Begin the search 576 for (Text text : targetFrame.getBodyTextItems()) { 577 String s = text.getTextNoList().toLowerCase(); 578 if (s.startsWith(targetAttribute)) { 579 attributeItem = text; 580 AttributeUtils.setSingleValue(attributeItem, value); 581 found = true; 582 break; 583 } 584 } 585 // Keep looking for a matching value nearby if we found an 586 // attribute without the value in the same item 587 if (!found && attributeItem != null) { 588 Point endPoint = attributeItem.getEndParagraphPosition(); 589 590 for (Text text : targetFrame.getBodyTextItems()) { 591 Point startPoint = text.getPosition(); 592 if (Math.abs(startPoint.y - endPoint.y) < 10 593 && Math.abs(startPoint.x - endPoint.x) < 20) { 594 found = true; 595 valueItem = text; 596 text.setText(value); 597 break; 598 } 599 } 600 } 601 602 // Set the values of the output parametres 603 context.getPrimitives() 604 .setValue(tokens[4], new SBoolean(found)); 605 if (tokens.length > 5) { 606 context.getPointers().setObject(tokens[5], attributeItem); 607 if (tokens.length > 6) { 608 context.getPointers().setObject(tokens[6], valueItem); 609 } 610 } 611 612 return Status.OK; 519 613 } else if (tokens[0].startsWith("setitem")) { 520 614 if (tokens[0].equals("setitemposition")) { … … 651 745 throw new UnitTestFailedException("null", value.toString()); 652 746 return Status.OK; 747 } else if (tokens[0].equals("assertnotnull")) { 748 assertExactParametreCount(tokens, 1); 749 Object value = context.getPrimitives().getVariable(tokens[1]) 750 .getValue(); 751 if (value == null) 752 throw new UnitTestFailedException("not null", "null"); 753 return Status.OK; 754 } else if (tokens[0].equals("assertdefined")) { 755 assertExactParametreCount(tokens, 1); 756 if (!context.isDefined(tokens[1])) 757 throw new UnitTestFailedException("defined", "not defined"); 758 return Status.OK; 759 } else if (tokens[0].equals("assertnotdefined")) { 760 assertExactParametreCount(tokens, 1); 761 if (context.isDefined(tokens[1])) 762 throw new UnitTestFailedException("defined", "not defined"); 763 return Status.OK; 653 764 } else if (tokens[0].equals("assertequals")) { 654 765 assertExactParametreCount(tokens, 2); … … 751 862 context.getPrimitives().setValue(frameNameVar, 752 863 frame.getFrameName()); 864 return Status.OK; 865 } else if (tokens[0].startsWith("getframefilepath")) { 866 assertExactParametreCount(tokens, 2); 867 String frameName = context.getPrimitives().getStringValue( 868 tokens[1]); 869 String path = FrameIO.LoadFrame(frameName).path; 870 String filePath = FrameIO.getFrameFullPathName(path, 871 frameName); 872 context.getPrimitives().setValue(tokens[2], filePath); 753 873 return Status.OK; 754 874 } … … 862 982 new SInteger(AgentStats.getMilliSecondsElapsed())); 863 983 return Status.OK; 984 } else if (tokens[0].equals("getlastnumberinframeset")) { 985 String framesetNameVar = DEFAULT_STRING; 986 String countVar = DEFAULT_INTEGER; 987 if (tokens.length > 1) { 988 assertMinParametreCount(tokens, 2); 989 framesetNameVar = tokens[1]; 990 countVar = tokens[2]; 991 } 992 String frameset = context.getPrimitives().getStringValue( 993 framesetNameVar); 994 long count = FrameIO.getLastNumber(frameset); 995 context.getPrimitives().setValue(countVar, new SInteger(count)); 996 return Status.OK; 997 } else if (tokens[0].equals("getlistofframesets")) { 998 String stringVar = DEFAULT_ITEM; 999 if (tokens.length > 1) { 1000 assertMinParametreCount(tokens, 1); 1001 stringVar = tokens[1]; 1002 } 1003 context.getPrimitives().setValue(stringVar, 1004 FrameIO.getFramesetList()); 1005 return Status.OK; 864 1006 } 865 1007 } else if (tokens[0].equals("or")) { … … 903 1045 FrameGraphics.DisplayMessage(((Text) message).copy()); 904 1046 } catch (NullPointerException e) { 905 // Just ignore not text items!906 1047 FrameGraphics.DisplayMessage("null"); 907 1048 } catch (ClassCastException e) { … … 914 1055 } else if (tokens[0].equals("messageln") 915 1056 || tokens[0].equals("messageline") 1057 || tokens[0].equals("messagelnnospaces") 1058 || tokens[0].equals("messagelinenospaces") 916 1059 || tokens[0].equals("errorln") || tokens[0].equals("errorline")) { 917 StringBuilder message = new StringBuilder(); 918 if (tokens.length == 1) { 919 message.append(context.getPrimitives().getVariable( 920 DEFAULT_STRING).stringValue() 921 + " "); 922 } else { 923 for (int i = 1; i < tokens.length; i++) { 924 if (Primitives.isPrimitive(tokens[i])) { 925 message.append(context.getPrimitives().getVariable( 926 tokens[i]).stringValue() 927 + " "); 928 } else 929 throw new Exception("Illegal parametre: [" + tokens[i] 930 + "] in line " + code.toString()); 931 } 932 } 1060 String message = getMessage(tokens, context, code.toString(), 1061 tokens[0].endsWith("nospaces") ? "" : " "); 933 1062 934 1063 if (tokens[0].equals("errorln") || tokens[0].equals("errorline")) 935 FrameGraphics.ErrorMessage(message .toString());1064 FrameGraphics.ErrorMessage(message); 936 1065 else 937 FrameGraphics.DisplayMessageAlways(message.toString()); 1066 FrameGraphics.DisplayMessageAlways(message); 1067 return Status.OK; 1068 } else if (tokens[0].equals("typein") 1069 || tokens[0].equals("typeinnospaces")) { 1070 1071 String s = getMessage(tokens, context, code.toString(), tokens[0] 1072 .equals("typein") ? " " : ""); 1073 for (int i = 0; i < s.length(); i++) { 1074 FrameKeyboardActions.processChar(s.charAt(i)); 1075 Thread.sleep(25); 1076 } 938 1077 return Status.OK; 939 1078 } else if (tokens[0].startsWith("else")) { … … 1015 1154 tokens[2]) <= 0; 1016 1155 parametres = 2; 1156 } else if (tokens[0].equals("ifexistingframe")) { 1157 result = FrameIO.DoesFrameExist(context.getPrimitives() 1158 .getStringValue(tokens[1])); 1159 } else if (tokens[0].equals("ifexistingframeset")) { 1160 String framesetName = context.getPrimitives().getStringValue( 1161 tokens[1]); 1162 result = FrameIO.DoesFramesetExist(framesetName); 1017 1163 } else { 1018 1164 // assertVariableType(variable, 1, SPointer.itemPrefix); … … 1164 1310 1165 1311 return Status.OK; 1312 } else if (tokens[0].equals("deleteitem")) { 1313 assertMinParametreCount(tokens, 1); 1314 assertVariableType(tokens[1], 1, SPointer.itemPrefix); 1315 Item item = (Item) context.getPointers().getVariable(tokens[1]) 1316 .getValue(); 1317 item.delete(); 1318 return Status.OK; 1319 } else if (tokens[0].equals("deleteframe")) { 1320 assertMinParametreCount(tokens, 1); 1321 assertVariableType(tokens[1], 1, SPointer.framePrefix); 1322 Frame frame = (Frame) context.getPointers().getVariable(tokens[1]) 1323 .getValue(); 1324 boolean success = FrameIO.DeleteFrame(frame); 1325 1326 if (tokens.length > 2) { 1327 context.getPrimitives().setValue(tokens[2], 1328 new SBoolean(success)); 1329 } 1330 1331 return Status.OK; 1332 } else if (tokens[0].equals("deleteframeset")) { 1333 assertMinParametreCount(tokens, 1); 1334 String framesetName = context.getPrimitives().getStringValue( 1335 tokens[1]); 1336 boolean success = FrameIO.DeleteFrameset(framesetName); 1337 1338 if (tokens.length > 2) { 1339 context.getPrimitives().setValue(tokens[2], 1340 new SBoolean(success)); 1341 } 1342 1343 return Status.OK; 1344 } else if (tokens[0].equals("copyitem")) { 1345 assertMinParametreCount(tokens, 2); 1346 assertVariableType(tokens[1],1,SPointer.itemPrefix); 1347 assertVariableType(tokens[2],2,SPointer.itemPrefix); 1348 Item item = (Item)context.getPointers().getVariable(tokens[1]).getValue(); 1349 Item copy = item.copy(); 1350 context.getPointers().setObject(tokens[2], copy); 1351 1352 return Status.OK; 1353 }else if (tokens[0].equals("copyframeset")) { 1354 assertMinParametreCount(tokens, 2); 1355 String framesetToCopy = context.getPrimitives().getStringValue( 1356 tokens[1]); 1357 String copiedFrameset = context.getPrimitives().getStringValue( 1358 tokens[2]); 1359 boolean success = FrameIO.CopyFrameset(framesetToCopy, 1360 copiedFrameset); 1361 1362 if (tokens.length > 3) { 1363 context.getPrimitives().setValue(tokens[3], 1364 new SBoolean(success)); 1365 } 1366 1367 return Status.OK; 1368 } else if (tokens[0].equals("copyframe")) { 1369 assertMinParametreCount(tokens, 2); 1370 assertVariableType(tokens[1],1,SPointer.framePrefix); 1371 assertVariableType(tokens[2],2,SPointer.framePrefix); 1372 Frame frameToCopy = (Frame) context.getPointers().getVariable( 1373 tokens[1]).getValue(); 1374 FrameIO.SuspendCache(); 1375 Frame freshCopy = FrameIO.LoadFrame(frameToCopy.getFrameName()); 1376 // Change the frameset if one was provided 1377 if (tokens.length > 3) { 1378 String destinationFrameset = context.getPrimitives() 1379 .getStringValue(tokens[3]); 1380 freshCopy.setFrameset(destinationFrameset); 1381 }// Otherwise add it to the end of this frameset 1382 freshCopy.setFrameNumber(FrameIO.getLastNumber(freshCopy 1383 .getFramesetName()) + 1); 1384 context.getPointers().setObject(tokens[2], freshCopy); 1385 String fileContents = FrameIO.ForceSaveFrame(freshCopy); 1386 boolean success = fileContents != null; 1387 FrameIO.ResumeCache(); 1388 if (tokens.length > 4) { 1389 context.getPrimitives().setValue(tokens[4], 1390 new SBoolean(success)); 1391 } 1392 return Status.OK; 1166 1393 } else if (tokens[0].equals("createframe")) { 1167 1394 … … 1237 1464 context.getPrimitives().setValue(nextCharVarName, 1238 1465 new SCharacter(nextChar)); 1466 1467 return Status.OK; 1468 } else if (tokens[0].equals("openreadfile")) { 1469 assertVariableType(tokens[1], 1, SString.prefix); 1470 assertVariableType(tokens[2], 2, SPointer.filePrefix); 1471 1472 if (tokens.length > 3) { 1473 assertVariableType(tokens[3], 3, SBoolean.prefix); 1474 context.openReadFile(tokens[1], tokens[2], tokens[3]); 1475 } else 1476 context.openReadFile(tokens[1], tokens[2]); 1477 1478 return Status.OK; 1479 } else if (tokens[0].equals("readlinefile") 1480 || tokens[0].equals("readlnfile")) { 1481 assertVariableType(tokens[1], 1, SPointer.filePrefix); 1482 1483 if (tokens.length > 3) { 1484 assertVariableType(tokens[3], 3, SBoolean.prefix); 1485 context.readLineFile(tokens[1], tokens[2], tokens[3]); 1486 } else 1487 context.readLineFile(tokens[1], tokens[2]); 1488 1489 return Status.OK; 1490 } else if (tokens[0].equals("readitemfile")) { 1491 assertVariableType(tokens[1], 1, SPointer.filePrefix); 1492 assertVariableType(tokens[2], 1, SPointer.itemPrefix); 1493 1494 if (tokens.length > 3) { 1495 assertVariableType(tokens[3], 3, SBoolean.prefix); 1496 context.readItemFile(tokens[1], tokens[2], tokens[3]); 1497 } else 1498 context.readItemFile(tokens[1], tokens[2]); 1239 1499 1240 1500 return Status.OK; … … 1276 1536 1277 1537 return Status.OK; 1538 } else if (tokens[0].equals("displayframeset")) { 1539 assertMinParametreCount(tokens, 1); 1540 String framesetName = context.getPrimitives().getStringValue( 1541 tokens[1]); 1542 int lastFrameNo = FrameIO.getLastNumber(framesetName); 1543 int firstFrameNo = 0; 1544 double pause = 0.0; 1545 // get the first and last frames to display if they were proided 1546 if (tokens.length > 2) { 1547 firstFrameNo = (int) context.getPrimitives().getIntegerValue( 1548 tokens[2]); 1549 if (tokens.length > 3) { 1550 lastFrameNo = (int) context.getPrimitives() 1551 .getIntegerValue(tokens[3]); 1552 if (tokens.length > 4) { 1553 pause = context.getPrimitives().getDoubleValue( 1554 tokens[4]); 1555 } 1556 } 1557 } 1558 // Display the frames 1559 String adjustedFramesetName = FrameUtils 1560 .GetFramesetNameAdjusted(framesetName); 1561 for (int i = firstFrameNo; i <= lastFrameNo; i++) { 1562 Frame frame = FrameIO.LoadFrame(adjustedFramesetName + i); 1563 if (frame != null) { 1564 double thisFramesPause = pause; 1565 // check for change in delay for this frame only 1566 Item pauseItem = ItemUtils.FindTag(frame.getItems(), 1567 "@DisplayFramePause:"); 1568 if (pauseItem != null) { 1569 try { 1570 // attempt to read in the delay value 1571 thisFramesPause = Double.parseDouble(ItemUtils 1572 .StripTag( 1573 ((Text) pauseItem).getFirstLine(), 1574 "@DisplayFramePause:")); 1575 } catch (NumberFormatException nfe) { 1576 } 1577 } 1578 DisplayIO.setCurrentFrame(frame); 1579 pause(thisFramesPause); 1580 } 1581 } 1582 return Status.OK; 1583 } else if (tokens[0].equals("createframeset")) { 1584 String framesetName = DEFAULT_STRING; 1585 String successVar = null; 1586 if (tokens.length > 1) { 1587 framesetName = tokens[1]; 1588 if (tokens.length > 2) 1589 successVar = tokens[2]; 1590 } 1591 context.createFrameset(framesetName, successVar); 1592 return Status.OK; 1278 1593 } else if (tokens[0].equals("concatstr")) { 1279 1594 assertMinParametreCount(tokens, 3); … … 1436 1751 } 1437 1752 1438 double time = context.getPrimitives().getDoubleValue(lengthVar); 1439 for (int i = 0; i < time * 10; i++) { 1440 Thread.yield(); 1441 Thread.sleep(100); 1442 } 1753 pause(context.getPrimitives().getDoubleValue(lengthVar)); 1443 1754 return Status.OK; 1444 1755 } else if (tokens[0].equals("glidecursorto")) { … … 1473 1784 Thread.sleep(milliseconds % timeInterval); 1474 1785 DisplayIO.setCursorPosition(finalX, finalY); 1786 return Status.OK; 1787 } else if (tokens[0].equals("glideitemto")) { 1788 assertMinParametreCount(tokens, 3); 1789 assertVariableType(tokens[1], 1, SPointer.itemPrefix); 1790 Item item = (Item) context.getPointers().getVariable(tokens[1]) 1791 .getValue(); 1792 int finalX = (int) context.getPrimitives().getIntegerValue( 1793 tokens[2]); 1794 int finalY = (int) context.getPrimitives().getIntegerValue( 1795 tokens[3]); 1796 1797 // DisplayIO.setCursorPosition(item.getX(), item.getY()); 1798 // FrameMouseActions.pickup(item); 1799 1800 int milliseconds = 1000; 1801 if (tokens.length > 4) 1802 milliseconds = (int) (context.getPrimitives().getDoubleValue( 1803 tokens[4]) * 1000); 1804 1805 int initialX = item.getX(); 1806 int initialY = item.getY(); 1807 // int initialX = DisplayIO.getMouseX(); 1808 // int initialY = DisplayIO.getMouseY(); 1809 1810 final int timeInterval = 40; 1811 1812 int deltaX = (int) (finalX - initialX); 1813 int deltaY = (int) (finalY - initialY); 1814 1815 int intervals = milliseconds / timeInterval; 1816 for (double i = 0; i < intervals; i++) { 1817 int newX = initialX + (int) (deltaX * i / intervals); 1818 int newY = initialY + (int) (deltaY * i / intervals); 1819 Thread.yield(); 1820 Thread.sleep(timeInterval); 1821 // DisplayIO.setCursorPosition(newX, newY); 1822 1823 item.setPosition(newX, newY); 1824 DisplayIO.repaint(); 1825 } 1826 // Thread.yield(); 1827 Thread.sleep(milliseconds % timeInterval); 1828 item.setPosition(finalX, finalY); 1829 // DisplayIO.setCursorPosition(finalX, finalY); 1830 FrameMouseActions.anchor(item); 1831 Frame.FreeItems.clear(); 1832 FrameGraphics.Repaint(); 1833 // FrameMouseActions.updateCursor(); 1475 1834 return Status.OK; 1476 1835 } … … 1487 1846 status = Status.OK; 1488 1847 return status; 1489 } else if (tokens[0].equals(CONTINUE_TEXT)) { 1848 } else if (tokens[0].equals(CONTINUE_TEXT) 1849 || tokens[0].equals(CONTINUE2_TEXT)) { 1490 1850 return Status.Continue; 1491 } else if (tokens[0].equals(BREAK_TEXT)) { 1851 } else if (tokens[0].equals(BREAK_TEXT) 1852 || tokens[0].equals(BREAK2_TEXT)) { 1492 1853 return Status.Break; 1493 1854 } else if (tokens[0].equals(RETURN_TEXT)) { … … 1536 1897 assertVariableType(tokens[1], 1, SPointer.filePrefix); 1537 1898 context.closeWriteFile(tokens[1]); 1899 1900 return Status.OK; 1901 } else if (tokens[0].equals("closereadfile")) { 1902 assertVariableType(tokens[1], 1, SPointer.filePrefix); 1903 context.closeReadFile(tokens[1]); 1538 1904 1539 1905 return Status.OK; … … 1550 1916 } 1551 1917 } else if (tokens.length == 3) { 1552 if (tokens[0].equals("foreach")) { 1918 if (tokens[0].startsWith("foreach")) { 1919 Class itemType = Object.class; 1920 String type = tokens[0].substring("foreach".length()); 1921 // Check the type of foreach loop 1922 // and set the item type to iterate over 1923 if (type.equals("dot")) { 1924 itemType = Dot.class; 1925 } else if (type.equals("text")) { 1926 itemType = Text.class; 1927 } else if (type.equals("line")) { 1928 itemType = Line.class; 1929 } 1930 1553 1931 assertVariableType(tokens[1], 1, SPointer.itemPrefix); 1554 1932 assertVariableType(tokens[2], 2, SPointer.framePrefix); … … 1556 1934 tokens[2]).getValue(); 1557 1935 // Create the ip variable 1936 Item frameName = currFrame.getFrameNameItem(); 1937 Item frameTitle = currFrame.getTitle(); 1938 1558 1939 for (Item i : currFrame.getItems()) { 1940 if (i == frameName || i == frameTitle) 1941 continue; 1942 if (!(itemType.isInstance(i))) 1943 continue; 1944 1559 1945 context.getPointers().setObject(tokens[1], i); 1560 1946 Status status = RunFrameAndReportError(code, context); 1561 1947 // check if we need to exit this loop because of 1562 // statements in 1563 // the code that was run 1948 // statements in the code that was run 1564 1949 if (status == Status.Exit || status == Status.Return) 1565 1950 return status; … … 1633 2018 } 1634 2019 2020 private static void pause(double time) throws Exception { 2021 for (int i = 0; i < time * 10; i++) { 2022 Thread.yield(); 2023 Thread.sleep(100); 2024 } 2025 } 2026 1635 2027 public static int countCharsInString(String s, String pattern) { 1636 2028 String newString = s; … … 1668 2060 throw new IncorrectParametreCountException(parametreCount); 1669 2061 } 2062 2063 private static String getMessage(String[] tokens, Context context, 2064 String code, String separator) throws Exception { 2065 StringBuilder message = new StringBuilder(); 2066 if (tokens.length == 1) { 2067 message.append(context.getPrimitives().getVariable(DEFAULT_STRING) 2068 .stringValue()); 2069 } else { 2070 for (int i = 1; i < tokens.length; i++) { 2071 if (Primitives.isPrimitive(tokens[i])) { 2072 message.append(context.getPrimitives().getVariable( 2073 tokens[i]).stringValue() 2074 + separator); 2075 } else 2076 throw new Exception("Illegal parametre: [" + tokens[i] 2077 + "] in line " + code); 2078 } 2079 } 2080 return message.toString(); 2081 } 1670 2082 }
Note:
See TracChangeset
for help on using the changeset viewer.