Concatenating inside brackets

I have some buttons named StrAdd, DexAdd, and ConAdd inside a movie clip. When you click on them, they all call the same function which tries to make some calculations on element 0 in an array on the main timeline based on the name of the button. The names of the arrays are StrArray, DexArray, and ConArray.
StrAdd.addEventListener(MouseEvent.CLICK, plus);
DexAdd.addEventListener(MouseEvent.CLICK, plus);
ConAdd.addEventListener(MouseEvent.CLICK, plus);
function plus(evt:MouseEvent):void {
     trace(MovieClip(root)[evt.target.name.slice(0,-3) + "Array[0]"]);
What I've got there traces as "undefined". My syntax must be off. Does anyone know how to do it properly? Basically what I'm trying to do is make it so that if you click on the StrAdd button, the evt.target.name.slice(0,-3) part turns it into just Str because it chops off the last 3 letters, then that concatenates with "Array[0]" to it to make StrArray[0] which is in brackets to turn it into MovieClip(root).StrArray[0].

try:
StrAdd.addEventListener(MouseEvent.CLICK, plus);
DexAdd.addEventListener(MouseEvent.CLICK, plus);
ConAdd.addEventListener(MouseEvent.CLICK, plus);
function plus(evt:MouseEvent):void {
     trace(MovieClip(root)[evt.currentTarget.name.substr(0,3) + "Array"][0]);  // or, MovieClip(root)[evt.currentTarget.name.split("Add").join("Array")][0]

Similar Messages

  • Get string inside brackets - Using Scan from string

    I have a very basic question here. I would like extract a portion of a string which is inside brackets (Example: I work with [National Instruments]). In the string I only want to extract National Instruments, I do know logic to extract by finding the brackets and extracting them. But I am interested in using the Scan from string or possibly any other primitive in one shot. Please suggest if anyone has any idea, I am really not use to the format specifiers. I got this link for reference but I am not able to figure out a solution.
    The best solution is the one you find it by yourself
    Solved!
    Go to Solution.

    Hi,
    I cannot say that it is the best solution, I use two Scan From String functions instead of one but it does work, so far ;-)
    I use Characters in set.
    I could not attach VI so FP is below.
    Duri

  • How to remove brackets on Print version of report?

    I have several reports that give the users the ability to print the report without all the navigation, etc. For these pop-up pages, however, any items get displayed inside brackets. Is there any way to remove the brackets? I'm using Read-Only items for most of them.

    blarman74 wrote:
    I have several reports that give the users the ability to print the report without all the navigation, etc. For these pop-up pages, however, any items get displayed inside brackets. Is there any way to remove the brackets? Upgrade to 4.1: it doesn't do this.

  • Newbee,Having problem with submit button

    Hi All,
    I am very new to servlet.I am trying to delete record from my list which i am loading and showing from same servlet.It is compiling fine but when I press delete button it is not deleting the record.I don't know what's wrong with it? After delete happes i just want to see the list.
    please somebody help me.
    Here is my code:
    public class Delete extends HttpServlet
    private static final String title = "Delete Messages";
    private int load_count = 0; // to verify reloading
    private Exception initial_exception = null;
    private Connection cx = null;
    private ResourceBundle rb = null;
    private String table = null;
    private List messages = null;
    public void init()
    try {
    rb = ResourceBundle.getBundle( "Settings" );
    table = rb.getString("table");
    Common.load_driver( rb );
    catch (Exception x) { initial_exception = x; }
    public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException
    doGet(request,response);
    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException
    HttpSession session = request.getSession();
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    if (initial_exception != null)
    out.println(initial_exception);
    return;
    messages = (List) session.getAttribute( "messages" );
    try {
    if (cx == null || cx.isClosed())
         cx = Common.get_connection( rb );
    if (messages == null)
         if (Common.DEBUG) System.out.println( "\n=> initial load of table" );
    messages = Common.getTable( cx, table );
    session.setAttribute( "messages", messages );
    catch(Exception x) { out.println("FIRST" + x); return; }
    out.println( "<html>"
              + "<head><title>" + title + "</title></head>"
              + "<body>"
              + Common.debug_display( request, load_count++ )
              + "<h3 align=center>"
              + title
              + "</h3>"
              + "<form action='..'>"
              + "<input type=submit value='top' />"
              + "</form>"
         String selected_index = request.getParameter("index");
         System.out.println("index=" + selected_index);
    if (messages.size() == 0)
    out.println( "<h4 style='color:red'>NO MESSAGES</h4>"
              +"</body></html>" );
    return;
    out.println( "<form>"
         + "<select name=index size=5 onchange='submit()'>\n"
         + Common.selection_list( messages, selected_index )
         + "</select>"
         + "</form>"
    if (selected_index != null)
         Message m = null;
    try {
    m = (Message) messages.get(Integer.parseInt(selected_index));
    catch(Exception x) { out.println("SECOND: " + x); return; }
    out.println( "<table>\n"
    + "<tr valign=top>\n"
    + "<td align=right>Creation:</td>\n"
    + "<td>"
    + "<input type=text onfocus='blur()' size=30 value="
    + Common.sgml_quote(Message.time2str(m.getCreation()))
    + ">"
    + "</td>"
    + "</tr>"
    + "<tr valign=top>\n"
    + "<td align=right>Subject:</td>\n"
    + "<td>"
    + "<input type=text onfocus='blur()' size=50 value="
    + Common.sgml_quote(m.getSubject())
    + ">"
    + "</td>"
    + "</tr>"
    + "<tr valign=top>\n"
    + "<td align=right>Body:</td>\n"
    + "<td>"
    + "<textarea onfocus='blur()' cols=50 rows=10>"
    + m.getBody()
    + "</textarea>"
    + "</td>\n"
    + "</tr>"
    + "</table>\n"
    + "<input type=submit name='action1' value='Delete'>"
    out.println( "</body></html>" );
    if (request.getParameter("action1") != null)
    Message m = null;
    String subject = request.getParameter("subject");
    String body = request.getParameter("body");
    try {
    String date = request.getParameter("creation");
    System.out.println( "\n=> date" + m.getCreation() );
    String sql_delete = "DELETE FROM" + messages + "WHERE creation = "+ Common.mysql_quote(m.getCreation());
    Statement st = cx.createStatement();
    st.executeUpdate( sql_delete );
    messages.remove( selected_index);
    session.setAttribute( "messages", messages );
    catch(Exception x) { out.println("SECOND" + x); return; }
    out.println( "<h4 style='color:red'>Message successfully deleted</h4>" );
    subject = body = null;
    out.println( "<html>"
    + "<head><title>" + title + "</title></head>"
    + "<body>"
    + Common.debug_display( request, load_count++ )
    + "<h3 align=center>"
    + title
    + "</h3>"
    + "<form action='..'>"
    + "<input type=submit value='top' />"
    + "</form>"

    I don't understand very well your code because it has no organization. Try to put all your code between a tag that is the word code inside brackets, and close that tag at the end of your code.
    For the code that I read, you're trying to get the parameters of a form that is in the same servlet. And the forms that you print didn't have an action. So, first of all, put an action on those forms, otherwise they will do noting, at least that you supply some javascript, which isn't the case. Later, don't think that you can call or continue the methods on a servlet just because you press a button which is printed in the same servlet.
    Nevertheless, put that code into brackets and we will try to help you better.
    Regards.

  • How to read a data file combining strings and data

    Hello,
    I'm having a data file combining strings and datas to read. I'm trying to read the filename, time, constants and comments into four seperate string indicators (the lines for the comments varies for different files). And read the data into a 2-D numeric array. How can I do this? Is there any function that can serch special characters in the spreadsheet file so I can exactly locate where I should start reading the specific data. The following is how the data file appears. Thank you very much.
    Best,
    Richard
    filename.dat
    14:59:00 12/31/2009
    Sample = 2451
    Frequency = 300, Wait time = 2500
    Temperature = 20
    some comments
    some comments
    some comments
    some comments
    some comments
    7.0000E+2    1.5810E-5
    7.0050E+2    1.5400E-5
    7.0100E+2    1.5500E-5
    7.0150E+2    1.5180E-5
    Message Edited by Richard1017 on 10-02-2009 03:10 PM
    Solved!
    Go to Solution.

    Hi,
         I'm fairly new to the NI forums too and I think you just have to wait longer.  Your post was done right.  I do a similiar function as to what you are talking about except I read in numbers from a file.  I create an ini file (just a notepad file of type *.ini) that is is set up with sections inside brackets [] and keys with whatever name followed by an = sign.  You may be able to use a *.dat file too, I just haven't.  Then the vi attached goes to that file and reads the keys from those sections.  You just repeat for the different sections and keys you want to read.  You can use similar provide VI's to write to that same file or create it.  Let me know how that works. 
    Attachments:
    Help1.ini ‏1 KB
    Help1.vi ‏10 KB

  • PSFunction - problem with the syntax

    Hi folks,
    I grabbed a Function-Example from: get-help about_Functions.
    I'm having some problems to understand that simple function. It goes like that:
    function Get-NewPix
    $start = Get-Date -Month 1 -Day 1 -Year 2013
    $allpix = Get-ChildItem -Path $env:UserProfile\*.jpg -Recurse
    $allpix | where {$_.LastWriteTime -gt $Start}
    Get-NewPix
    I do understand what the 3 line of code is for, but I don't understand why it's in a separate line? It's because the code in the 2-nd line is broken in the new (3-rd) line?
    And why the function doesn't work (gets no results) when I write:
    function Get-NewPix
    $start = Get-Date -Month 1 -Day 1 -Year 2013
    $allpix = Get-ChildItem -Path $env:UserProfile\*.jpg -Recurse | where {$_.LastWriteTime -gt $Start}
    Get-NewPix
    Thanks for your help.
    Pruclot

    function Get-NewPix
    $start = Get-Date -Month 1 -Day 1 -Year 2013
    $allpix = Get-ChildItem -Path $env:UserProfile\*.jpg -Recurse | where {$_.LastWriteTime -gt $Start}
    Get-NewPix
    As SeanQuinlan says, your line isn't working because it's storing all pictures in the $allpix variable before piping to your where.
    It's an order of operations problem. Another way to solve if you wanted the results in $allpix (which doesn't really make sense in this very simple example) is to wrap the portion you want to execute fully inside (brackets). This way it will process and
    then assign to your variable. Since this is a function, you'll also need to return the $allpix variable, otherwise it will appear that your function does nothing at all:
    function Get-NewPix
    $start = Get-Date -Month 1 -Day 1 -Year 2013
    $allpix = (Get-ChildItem -Path $env:UserProfile\*.jpg -Recurse | where {$_.LastWriteTime -gt $Start})
    return $allpix
    Jason Warren
    @jaspnwarren
    jasonwarren.ca
    habaneroconsulting.com/Insights

  • NEAR operator alternative when not using. oracle Text ?

    hi,
    I'm working on a project where i would need a Oracle Text 'NEAR like' operator ...
    here is my scenario ...
    in db we have Customers ... and every customer has some criterias like different search words( names, towns,cars,etc...) so for every customer i can create an SQL query out of criterias . ....
    now .... we can have a criteria like. ...... WHERE fulltext like 'john%'. or even distance search line NEAR inside CONTAINS. ... but then the Oracle text index is needed .....
    the only tAble on which Text index is created is our storage table that holds more then 4mil records and growing...
    my question is ... is there any way to have a query that would do the same thing as NEAR but without Text index ?
    here is how I start ....
    I get full newspaper article text from our OCR library ......
    then i need to check customer's criterias against this text to see which article is for which customer and then bind the article to the customer
    I could do it without Oracle using RegEx , but criterias can get really complicated ... like customer wants only specific MEDIA, or specific category , type , only articles that are from medias that are from specific country etc ... and many more different criterias ... and all this can be wrapped inside brackets with ANDs, ORs, NOT. ....
    So the only way to do it is to put it in Oracle and execute the correct query and let Oracle decide if the result is true or false .... but due to NEAR operator I need Oracle text ...
    So if I decide to first insert article into our storage table which has Oracle text index to be able to do the correct search .... how fast will this be ????
    will the the search become slower when there are 6mil records ? I know I can use FILTER BY to help Text index to do a better and quicker seach ... and how to optimize index ....but still
    I'm always asking my self..... why insert the article in a table where there are already 6mil articles and execute query when I only need to check data on one single article and. i already know this article ...
    I see two solutions :
    - if there is alternative for NEAR without using Oracle text index then i would insert data into temporary table and execute query on this table..... table would always contain only this one article. maybe one option would be to have one 'temp' table with Oracle text index in which i insert this one article and with help of Oracle text based on this one article do the search , and then maybe on a daily basis clear index ..... or when the article is removed from the table ... but this would mean having two Orcle text indexes, cause we already have Oracle text index on our storage table anyway....
    - another is to use Oracle text index and insert it into our storage table and hope for the best quick results ....
    Maybe I'm exaggerating and query like WHERE id=1234 and CONTAINS(...). will execute faster then I think
    If anyone would have any other suggestion I will be happy to try it ..
    thanks,
    Kris

    Hi,
    this is to my knowledge not possible. It is hard for Oracle to do, think about a table with many rows, every row with that column must be checked. So I think only a single varchar2 is possible. Maybe for you will a function work. It is possible to give a function as second parameter.
    function return_signup
    return varchar2
    is
      l_signup_name signup.signup_name%type;
    begin
      select signup_name
      into l_signup_name
      from signup
      where signup_id = 1
      and rownum = 1
      return l_signup_name;
    exception
      when no_data_found
      then
        l_signup_name := 'abracadabra'; -- hope does not exist
        return l_signup_name;
    end;Now you can use above function in the contains.
    select * from user_history_view users --, signup new_user
    --where new_user.signup_id = 1
    where contains(users.user_name, return_signup)>0;I didn't test the code! Maybe you have to adjust the function for your needs. But it is a idea how this can be done.
    Otherwise you must make the check by normaly check the columns by simple using a join:
    select * from user_history_view users, signup new_user
    where new_user.signup_id = 1
    and users.user_name = new_user.signup_name;Herald ten Dam
    htendam.wordpress.com

  • Translating a date format in a filename string

    Hi,
    Basically I have a property like:
    filename=MyFile(yyyy-MM-dd@HHmmss).logWhen I create the file I want to translate the embedded date format string using the current date.
    My solution is as follows:
       private static void createFile(String fName) {
          String[] fNameArray = new String[3];
          int openBracket = fName.indexOf("(");
          int closeBracket = fName.indexOf(")");
          // Split the file name into prefix, text inside brackets ie to be tranlated to a date and suffix
          fNameArray[0] = fName.substring(0, openBracket+1);
          fNameArray[1] = fName.substring(openBracket+1, closeBracket);
          fNameArray[2] = fName.substring(closeBracket);
          String dateFormat = fNameArray[1];
          DateFormat df = new SimpleDateFormat(dateFormat);
          String date = df.format(new Date());
          fNameArray[1] = date;
          fName = fNameArray[0].concat(fNameArray[1].concat(fNameArray[2]));
          ...This seems a little long winded to me (it works though). Does anyone know of a simpler way to code this?
    Many Thanks

    I've been looking around and came across String.format() which can be used to format strings using substitutions variables.
    This works a treat but I must admit the property now looks a bit complex!
       String fName = "MyFile_%1$tY%1$tm%1$td%1$tH%1$tM%1$tS.log";
       fName = String.format(fName, Calendar.getInstance());
       // fName = MyFile_20060803132200.logThanks for your help.

  • ViewObjects Order by clause with DECODE

    Hello!
    I am using Jdeveloper 11g, version 11.1.1.2.0.
    The problem I'm having is this.
    If I use a DECODE statement in view objects ORDER BY clause, I get an error: "java.util.regex.PatternSyntaxException: Unmatched closing ')' near index 2".
    Let me give an example. I'll be using EmployeesView view object, which is using Employees entity from HR schema.
    This is a part of view objects XML.
    <ViewObject
    xmlns="http://xmlns.oracle.com/bc4j"
    Name="EmployeesView"
    Version="11.1.1.55.36"
    SelectList="Employees.EMPLOYEE_ID,
    Employees.FIRST_NAME,
    Employees.LAST_NAME,
    Employees.EMAIL,
    Employees.PHONE_NUMBER,
    Employees.HIRE_DATE,
    Employees.JOB_ID,
    Employees.SALARY,
    Employees.COMMISSION_PCT,
    Employees.MANAGER_ID,
    Employees.DEPARTMENT_ID"
    FromList="EMPLOYEES Employees"
    BindingStyle="OracleName"
    CustomQuery="false"
    PageIterMode="Full"
    UseGlueCode="false"
    OrderBy="Employees.MANAGER_ID">
    As you can see in this case, the Order by clause is very simple. This works like a charm.
    But, if put something like this "DECODE(Employees.MANAGER_ID, NULL, 1, 2)" in the Order by, I get an internal parsing error.
    I replicated this error on my home machine as well as on my work machine. I'm using the same version of Jdeveloper on both.
    Has anyone else stumbled upon this problem and solved it?
    Any thoughts would be greatly appreciated :)
    Kristjan

    The second example works, but the first one doesn't, unfortunately :/
    Also, the example I gave is unfortunately just that, a proof-of-concept example that there is a problem with DECODE if it is written inside the Order by clause.
    My real DECODE use case is a bit different. Like this: "DECODE(attribute, 'N', 1, 2) ASC".
    Since posting my original question, I did some research-by-example work and I discovered that this is not just a problem of DECODE, but more like a problem of brackets and commas.
    No database function that uses more than one parameter can be used in Order by clause.
    The reason is, if a function with more than one parameter is used, commas inside brackets have to be used. Something along the lines of: "database_function(param1, param2, ...)".
    The parser seems to have a problem with this kind of expressions.
    Is there a work around?
    Kristjan
    p.s.: Thank you for your quick response.

  • Best practice using keyword in subject for encryption

    I have setup an encryption content filter on my appiance to encrypt messages that are outbound, and have a subject header that begin with the keyword Secure inside brackets. [Secure]. My intent was to eliminate some fals positives by including the brackets. What ended up happening was for some reason ALL outbound messages were being encrypted.
    After some more testing it seems like the content filter is ignoring the brackets as a requirement, but I can seem to find anything in the online help to back this up.
    Can someone assist with verification of the requirements around using a keywork in the subject to allow users to encrypt oubound messages voluntarily?
    Best practices around achieving this if anyone has them would also be greatly appreciated.
    Thanks,
    Chris

    Hi Chris,
    While I would have to see the syntax of the filter in question to be 100% sure , it sounds as if your conditional variable is being treated literally. The content filters will except regular expressions so what this means is something like [Secure] could be seen as look for anything that contains
    an S, or a
    e or a
    c or a
    u or a
    r or a
    e
    Since you said begins with we would be looking for anything in the subject that begins with of of these letters. This is due to the fact that the brackets [ ] are special characters in regular expressions, thus they need to be escaped. That being said [Secure] would become \\[Secure\\], we use the \\ to escape the brackets. In content filters however, you can get by with using just one escape as the filter is smart enough to go ahead an enter the additional escape for you. So in the filter it would be something like begins with \[Secure\]
    Once you enter this in the condition for you filter it will display like the following,
    subject == "^\\[Secure\\]"
    I hope that helps.
    Christopher C Smith
    CSE
    Cisco IronPort Customer Support  

  • Tips on Changing Find bar_buttons location & highlights

    Taking the archived topic a bit farther https://support.mozilla.org/en-US/questions/976166?page=1,
    I added code for the "phrase not found" <u>background & text color</u>.
    Thanks to cor-el & all others that contributed.
    I wanted the "Phrase not found" label to show up better. So I played around & added this to the already great code to bring back old Find bar characteristics, offered by others in the above topic. It all still works in Fx 30 - for me.
    Added to code in the link, this colors background of "Phrase not found" (yellow) & makes font red, bold.
    Colors or bolding are easily changed.
    <pre><nowiki>* Add background color to "Phrase not found;" set font color & make bold */
    .findbar-container>.findbar-find-status {
    background-color:#ff8 !important;
    color: red;
    font-weight: bold;
    }</nowiki></pre>
    Don't know why, but using "code block" formatting in this forum, inserts blank line after, "...<b>findbar-find-status {</b>"
    The following is for "coding-challenged" users - like me. Changes up background color & font weight for <u>active</u> "Highlight All" & "Match Case" labels. Can change text color as well, if desired.
    <pre><nowiki>/* add a background color to the checked Highlight and Case sensitive buttons.
    Make checked buttons' font bold; change font color if desired. */
    .findbar-highlight[checked]>label {
    background-color: lightgreen !important;
    color: black;
    font-weight: bold;
    .findbar-case-sensitive[checked]>label {
    background-color: lightgreen !important;
    font-weight: bold;
    .findbar-case-sensitive[checked]+label { display:none !important; } /* hide "(Case sensitive)" label</nowiki></pre>
    Those now using userChrome.css to add code for GUI changes might try Stylish addon https://addons.mozilla.org/en-US/firefox/addon/stylish/?src=search.
    It allows instantly previewing new code ("styles") effect on Fx or Tb, rather than having to restart.
    <b>Important!</b> - it also <u>alerts to errors</u> in the entered code; giving indication of error type & the line, space where the error exists. Easier to find mistakes - why code isn't working.
    Very simple - just click "Write new style," give it a name; copy / paste code like from this topic; then click Preview to see effect (or it may point out errors). Also, many custom styles for almost anything, available on Userstyles.org - can be instantly loaded.

    Unable to add an image.
    UPDATE 7/18/2014 - problems posting images:
    Using a 3rd party image host: Screen of Find Bar changes, using cor-el's code from other linked discussion and my additional code in this discussion.
    If you don't like the color choices or bold font, just change them or "comment out" specific lines. If you want the change back, just uncomment. Like:
    <b>background-color:#ff8 !important;
    color: fuchsia;
    <span style="color:#ff0000">/*</span>font-weight: bold;<span style="color:#ff0000">*/</span></b>
    [IMG]http://i59.tinypic.com/dyucfn.jpg[/IMG]
    Note: adding image link from hosting site (copying the host's usual full path "[IMG]... [/IMG]" , doesn't imbed the image - only inserts the link (if embedding by that method ever worked on this forum). Though I can follow the above link.
    Note: my entry in the edit screen for the closing "IMG" in brackets (just above) is entered <b>correctly</b> - inside brackets. Forum software appears to change the closing bracket statement into a forum help link.
    Below, using html code to insert an image (using a formatting toolbar) seems to work here, but most users wouldn't have that capability.
    <img src="http://i59.tinypic.com/dyucfn.jpg" alt="">

  • Enter (please Reply)

    i want to make find menuItem i make it and the word i find is high lighted when i press The FindNext button in the JOptionPane
    the problem is that when i write in the JTextPane if i press Enter
    and then try to find a Specific word in the first line the whole word is Highlighted but in the second line part of the word is highlighted and so on .
    here is the code:
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    //import java.awt.HeadlessException;
    import javax.swing.JOptionPane;
    import javax.swing.text.*;
    class Menu113 extends JFrame
    private JTextPane tp;
    private JMenuBar mb;
    private JMenu m1;
    private JMenu m2;
    private JMenu m3;
    private JMenu m4;
    private JMenuItem mi1;
    private JMenuItem mi2;
    private JMenuItem mi3;
    private JMenuItem mi4;
    private JMenuItem mi5;
    private JMenuItem mi6;
    private JMenuItem mi7;
    private JMenuItem mi31;
    private JMenuItem mi32;
    private JMenuItem mi33;
    private JMenuItem mi34;
    private JMenuItem mi21;
    private JMenuItem mi11;
    private JMenuItem mi12;
    private JMenuItem mi13;
    private JMenuItem mi14;
    private JMenuItem mi15;
    private JMenuItem mi16;
    private JMenuItem mi17;
    private JMenuItem mi41;
    private JMenuItem mi42;
    private JMenuItem mi43;
    private JOptionPane op;
    private JPanel jp1;
    private JPanel jp2;
    private JTextField ta;
    private JLabel l1;
    private JLabel l2;
    private JRadioButton rb1;
    private JRadioButton rb2;
    private JButton b1;
    private ButtonGroup bg;
    private String s1;
    private String s2;
    private String s3;
    private int i;
    private int j;
    private int u;
    private int y;
    private int h;
    private int flag;
    private int d;
    //JLayeredPane lp;
    //Boolean y;
    JFileChooser fc;
    Container c;
    public Menu113()
    i=0;
    flag=0;
    d=0;
    b1=new JButton("Find Next");
    jp1=new JPanel();
    jp2=new JPanel();
    ta=new JTextField();
    tp=new JTextPane();
    l1=new JLabel("Find What: ");
    l2=new JLabel("Direction");
    bg=new ButtonGroup();
    rb1=new JRadioButton("Up",true);
    rb2=new JRadioButton("Down");
    mb=new JMenuBar();
    m1=new JMenu("File");
    m2=new JMenu("Edit");
    m3=new JMenu("New");
    m4=new JMenu("Search");
    //File
    mi1=new JMenuItem("New \" PHP in HTML\" page");
    mi2=new JMenuItem("open");
    mi3=new JMenuItem("Close");
    mi4=new JMenuItem("Close All");
    mi5=new JMenuItem("Save");
    mi6=new JMenuItem("Save All");
    mi7=new JMenuItem("Save As");
    //New
    mi31=new JMenuItem("PHP in HTML");
    mi32=new JMenuItem("PHP");
    mi33=new JMenuItem("HTML");
    mi34=new JMenuItem("Plain text");
    //Edit
    mi11=new JMenuItem("Undo");
    mi12=new JMenuItem("Cut");
    mi16=new JMenuItem("Copy");
    mi13=new JMenuItem("Paste");
    mi14=new JMenuItem("Redo");
    mi15=new JMenuItem("SelectAll");
    mi17=new JMenuItem("Insert function");
    //Search
    mi41=new JMenuItem("Find");
    mi42=new JMenuItem("Replace");
    mi43=new JMenuItem("Go to Line Number");
    //open
    mi2.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent e)
    JFileChooser fc=new JFileChooser();
    try
    fc.showOpenDialog(null);
    catch(Exception et){ }
    //Save
    mi5.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent e)
    JFileChooser fc1=new JFileChooser();
    try
    fc1.showSaveDialog(null);
    catch(Exception et1){ }
    //SaveAll
    mi6.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent e)
    JFileChooser fc2=new JFileChooser();
    try
    fc2.showSaveDialog(null);
    catch(Exception et1){ }
    //SaveAs
    mi7.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent e)
    JFileChooser fc2=new JFileChooser();
    try
    fc2.showSaveDialog(null);
    catch(Exception et1){ }
    mi31.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent e)
    String s=new
    String("<HTML>\r\r<HEAD>\r<TITLE></TITLE>\r</HEAD>\r\r<BODY>\r
    \r<?php\r\r ?>\r\r</BODY>\r</HTML>");
    tp.setText(tp.getText()+s);
    mi32.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent e)
    String s=new String("<?php\n\n\n?>");
    tp.setText(tp.getText()+s);
    mi33.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent e)
    String s=new
    String("<HTML>\n\n<HEAD>\r<TITLE></TITLE>\r</HEAD>\r\r<BODY>\r
    \t\r</BODY>\r</HTML>");
    tp.setText(tp.getText()+s);
    mi34.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent e)
    tp.setText("");
    mi12.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent e)
    tp.cut();
    mi13.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent e)
    tp.paste();
    //Copy
    mi16.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent e)
    tp.copy();
    mi15.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent e)
    tp.selectAll();
    //Find
    mi41.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent e)
    jp1.setLayout(new BoxLayout(jp1,BoxLayout.X_AXIS));
    jp2.setLayout(new BoxLayout(jp2,BoxLayout.Y_AXIS));
    bg.add(rb1);
    bg.add(rb2);
    jp1.add(l1);
    jp1.add(ta);
    jp2.add(l2);
    jp2.add(rb1);
    jp2.add(rb2);
    Button bb=new Button(b1,ta);
    //bb.start();
    Object[] options = {jp2,b1,"Cancel"};
    int n = JOptionPane.showOptionDialog(null,
    jp1,
    "Find",
    JOptionPane.YES_NO_CANCEL_OPTION,
    JOptionPane.QUESTION_MESSAGE,
    null,
    options,
    options[2]);
    tp.addKeyListener(new KeyAdapter()
    public void keyPressed(KeyEvent e)
    s1=tp.getText();
    u=s1.length();
    int h=e.getKeyCode();
    //System.out.println(h);
    /*if(h==10)
    i--;
    System.out.println("hello");
    //Find Next
    b1.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent e)
    s2=ta.getText();
    if(rb1.isSelected())
    int m=s1.indexOf(s2,i);
    i=m+1;
    //System.out.println(i);
    int y=s1.indexOf("\n",i);
    //System.out.println(y);
    if(y<0)
    tp.setSelectionStart(i-1);
    tp.setSelectionEnd(i-1+s2.length());
    if(m==s1.lastIndexOf(s2))
    b1.setEnabled(false);
    else if(y>0)
    System.out.println("hello");
    tp.setSelectionStart(i-1-flag);
    tp.setSelectionEnd(i-1-flag+s2.length());
    i=y;
    System.out.println(i);
    flag=flag++;
    else if(rb2.isSelected())
    j=s1.lastIndexOf(s2,u);
    System.out.println(j);
    System.out.println(u);
    u=j-1;
    tp.setSelectionStart(u+1);
    tp.setSelectionEnd(u+1+s2.length());
    if(j==s1.indexOf(s2))
    b1.setEnabled(false);
    if(rb1.isSelected())
    b1.setEnabled(true);
    c=getContentPane();
    setJMenuBar(mb);
    m1.add(mi1);
    m1.add(m3);
    m1.addSeparator();
    m1.add(mi2);
    m1.addSeparator();
    m1.add(mi3);
    m1.add(mi4);
    m1.addSeparator();
    m1.add(mi5);
    m1.add(mi7);
    m1.add(mi6);
    m3.add(mi31);
    m3.add(mi32);
    m3.add(mi33);
    m3.add(mi34);
    m2.add(mi11);
    m2.add(mi14);
    m2.addSeparator();
    m2.add(mi12);
    m2.add(mi16);
    m2.add(mi13);
    m2.add(mi15);
    m2.addSeparator();
    m2.add(mi17);
    m4.add(mi41);
    m4.add(mi42);
    m4.add(mi43);
    mb.add(m1);
    mb.add(m2);
    mb.add(m4);
    c.add(tp);
    setSize(200,200);
    setVisible(true);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    public static void main (String args[])
    Menu113 mm=new Menu113();
    }

    I'm surprised that he understands his own code! Or maybe that's the problem. He's got it so messed up he doesn't know where to start. Hint to original poster. Name your variables after what they represent. Trust me, it will save you many many hours in the long run trying to wade through all of that to find one variable or method that is giving you problems. Rename your variables, then surround your code with code tags. Start with the word code inside [] brackets, then at the end, put /code in [] brackets. SQUARE brackets, not curly braces or angle brackets (I made the angle bracket mistake once. Felt like an idiot). Then come back and make it a little more specific and a little easier to read. For your own sake, fix that code!!!
    James

  • Uppercase in filenames generated by RoboHelp

    I developed (originally in RoboHelp HTML X5) and maintain
    (now in X7) a FlashHelp system. (FYI that the fact that it's
    FlashHelp is irrelevant to my problem.)
    When my client's developers attempt to check in my source
    files to their source code control system, they always complain
    that some of the folders and filenames have mixed case. They want
    everything in lowercase.
    Specifically, they are complaining about:
    -- a folder in which the images are stored. The folder is
    Images. Is it capped because that's how I originally named it and
    therefore I can change it (and the change will "stick")?
    -- RoboHHRE.lng. They want to know if I can force RoboHelp to
    write it as robohhre.lng?
    -- eHlpDhtm.js. They want to know same. But I also wonder if
    I even need this file anymore and can just nix it. I suspect it's
    legacy.
    -- eHelp.xml -- ditto above.
    For my output, I have the set the Use Lowercase File Names
    (Recommended for UNIX), but, obviously, that controls only output.
    It is these source files that my developers are complaining
    about.

    Hi, Nita.
    If you created the folder as Images, you can change it to
    images. However, a quirk of RH, inherited from MS apparently,
    prevents it from recognizing a change of case by itself. It might
    be fixed now, but if you have a problem making the change stick,
    change Images to Nita (or something), save the project, and change
    Nita to images.
    The RH furniture files are a different matter.
    RoboHHRE.lng carries the alternative language settings. Since
    you have the options of US or UK English, I don't know what would
    happen if you deleted the file.
    When RH puts a file in WebHelp output, there's a use for it
    under one circumstance or another. eHlpDhtm.js is extremely
    important if you have generated Applet and/or DHTML output.
    Also, consider that these files are referenced in htm topics,
    htm furniture, js and xml files whose origin is in the RH program
    application folders.
    It's easy enough to change the filenames after you generate
    WebHelp, but I believe Unix will be unhappy unless you also change
    all the references in the output as well.
    Not too hard with search and replace after generating
    WebHelp, but it shouldn't be too much trouble for your developers
    to force all file names to lower case whenever they appear inside
    < > brackets.
    Probably they deal with this frequently and have a utility
    they can use. Or they should be able to write a script of their
    own.
    Whether .jar and .cab files are involved here, I don't know.
    I'm reluctant to advise doing this in the RH program files,
    where there are DLL and other sorts of files, or in the project
    folder, where the .cpb database file and others refer to them.
    Good luck, and if you experiment in a backup copy of a
    project, please report back on results.
    Harvey

  • Data Access Object pattern (DAO)

    Sun's J2EE blueprints includes the DAO pattern:
    http://java.sun.com/blueprints/patterns/DAO.html
    I created some example DAO's:
    http://daoexamples.sourceforge.net
    http://daoexamples.sourceforge.net/xref/index.html
    Please send any feedback to sean /.at.\ seansullivan |.dot.| com

    Your example is beautiful, but what would be even more
    interesting to learn. How many lines of sql WOULD
    make StringBuffer the appropriate solution.It's not the number of lines, it's the number of Strings that will be appended at runtime. If all the Strings are literals, as in the OPs code, using StringBuffer will never be appropriate. It will always be slower than using +. That's a little misleading because + doesn't do anything at runtime when concatenating literals, the literals will be concatenated together at compile time. Usually SQL will contain a mixture of literals and non-literals. Generally, + will still be faster because it will be appending less Strings at runtime than StringBuffer, depending on the code.
    I suppose the question is how many Strings do you need to concatenate at runtime to make it worth while to use StringBuffer.
    Well, first of all, it's got to be more than two. The idea of using a StringBuffer is to avoid extra Object creation. If the + doesn't get compiled into StringBuffer appends, + between two Strings will create zero extras Objects; creating only the result String. The StringBuffer solution requires one extra Object; the StringBuffer. So in the case of concatenating only two Strings, the StringBuffer sotution is again inferior.
    When Concatenating three Strings you break even in the Object count. StringBuffer has an extra Object. 'Dumb' concatentation requires an extra Object.
    After three Strings. StringBuffer starts to come out ahead. But in reality, the difference is negligible. String concatenation is fast. I have to run tests 100s of thousands of times to get a clear difference in time. I find it unlikely that anyone will be concatenating enough Strings in a non-looping method to make it worth mucking up the code with StringBuffers. This is not a bottleneck.
    The time that it really counts is when you are concatenating inside loops. The compiler is not smart enough to optimize that type of code into an efficient StringBuffer solution. If you are concatenating to the same a String inside a loop, it is good practice to use a StringBuffer especially if the loop runs many times in a row or runs very often.
    The main point is for something like the OPs code, it doesn't really matter. Both versions will have essentially the same performance (very fast.) There is no reason to make the code less readable. I say, don't sacrifice readability just to make the code run more slowly. There are many ways to code less effecient without making it unreadable.

  • Sliding Panels options

    Hi, i'm building a sliding panels widget inside a
    spry:region, and i wish to set options for it like duration and
    defaultpanel but since the options must be inside brackets {} spry
    interprets it as a data reference.... how can it set options for
    this sliding panels widget, avoiding the spry interpretation of the
    constructor code?

    Adding spaces within the constructor brackets will solve it.
    { defaultPanel:3 }

Maybe you are looking for