Ignore:
Timestamp:
07/02/08 17:26:51 (16 years ago)
Author:
ra33
Message:

Added SearchItem and SearchStr

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/actions/Simple.java

    r115 r116  
    323323                        // an item without a link signals to run the current frame
    324324                        if (current.getLink() == null) {
    325                                 //Make a copy but hide it
     325                                // Make a copy but hide it
    326326                                current = current.copy();
    327327                                current.setLink(DisplayIO.getCurrentFrame().getName());
     
    352352         */
    353353        public static void DebugFrame(Text current, float pause, Color color) {
    354                 if(isProgramRunning()){
     354                if (isProgramRunning()) {
    355355                        stop();
    356356                }
     
    412412                        context.getPointers().setObject(SPointer.framePrefix + varName,
    413413                                        frame);
     414                        context.getPointers().setObject(SPointer.itemPrefix + varName,
     415                                        frame.getTitleItem());
    414416                        context.getPrimitives().add(SString.prefix + varName,
    415417                                        new SString(frame.getName()));
     
    481483                if (_step) {
    482484                        DisplayIO.removeFromBack();
    483                         if(DisplayIO.getCurrentFrame() != current.getParent())
     485                        if (DisplayIO.getCurrentFrame() != current.getParent())
    484486                                DisplayIO.setCurrentFrame(current.getParent());
    485487                }
     
    766768                        // Check if the user wants to display a message
    767769                        // Check for set statements
     770                } else if (tokens[0].startsWith("search")) {
     771                        if (tokens[0].equals("searchstr")) {
     772                                assertExactParametreCount(tokens, 5);
     773                                String searchStr = context.getPrimitives().getStringValue(
     774                                                tokens[1]);
     775                                String pattern = context.getPrimitives().getStringValue(
     776                                                tokens[2]);
     777                                String[] result = searchStr.split(pattern, 2);
     778                                boolean bFound = result.length > 1;
     779                                context.getPrimitives().setValue(tokens[3],
     780                                                new SBoolean(bFound));
     781                                if (bFound) {
     782                                        context.getPrimitives().setValue(tokens[4],
     783                                                        new SInteger(result[0].length() + 1));
     784                                        context.getPrimitives().setValue(tokens[5],
     785                                                        new SInteger(searchStr.length() - result[1].length()));
     786                                }
     787                        }else if (tokens[0].equals("searchitem")) {
     788                                assertExactParametreCount(tokens, 5);
     789                                assertVariableType(tokens[1], 1, SPointer.itemPrefix);
     790                                Text searchItem = (Text)context.getPointers().getVariable(tokens[1]).getValue();
     791                                String searchStr = searchItem.getText();
     792                                String pattern = context.getPrimitives().getStringValue(
     793                                                tokens[2]);
     794                                String[] result = searchStr.split(pattern, 2);
     795                                boolean bFound = result.length > 1;
     796                                context.getPrimitives().setValue(tokens[3],
     797                                                new SBoolean(bFound));
     798                                if (bFound) {
     799//                                      context.getPrimitives().setValue(tokens[4],
     800//                                                      new SInteger(1));
     801                                        context.getPrimitives().setValue(tokens[4],
     802                                                        new SInteger(result[0].length() + 1));
     803//                                      context.getPrimitives().setValue(tokens[6],
     804//                                                      new SInteger(1));
     805                                        context.getPrimitives().setValue(tokens[5],
     806                                                        new SInteger(searchStr.length() - result[1].length()));
     807                                }
     808                        }
    768809                } else if (tokens[0].startsWith("set")) {
    769810                        if (tokens[0].equals("set")) {
     
    794835                                assertExactParametreCount(tokens, 3);
    795836
    796                                 Map<String,String> map = (Map<String,String>) context.getPointers().getVariable(tokens[1])
    797                                                 .getValue();
     837                                Map<String, String> map = (Map<String, String>) context
     838                                                .getPointers().getVariable(tokens[1]).getValue();
    798839                                String attribute = context.getPrimitives().getStringValue(
    799840                                                tokens[2]);
Note: See TracChangeset for help on using the changeset viewer.