Need help with connecting file inputs to arrays

In this assignment I have a program that will do the following: display a list of names inputed by the user in reverse order, display any names that begin with M or m, and display any names with 5 or more letters. This is all done with arrays.
That was the fun part. The next part requires me to take the names from a Notepad file, them through the arrays and then output them to a second Notepad file.
Here is the original program: (view in full screen so that the code doesn't get jumbled)
import java.io.*;       //Imports the Java library
class progB                    //Defines class
    public static void main (String[] arguments) throws IOException
        BufferedReader keyboard;                                  //<-
        InputStreamReader reader;                                 //  Allows the program to
        reader = new InputStreamReader (System.in);               //  read the the keyboard
        keyboard = new BufferedReader (reader);                  //<-
        String name;                 //Assigns the name variable which will be parsed into...
        int newnames;               //...the integer variable for the amount of names.
        int order = 0;              //The integer variable that will be used to set the array size
        String[] array;             //Dynamic array (empty)
        System.out.println (" How many names do you want to input?");   //This will get the number that will later define the array
        name = keyboard.readLine ();
        newnames = Integer.parseInt (name);                                         // Converts the String into the Integer variable
        array = new String [newnames];                                               //This defines the size of the array
        DataInput Imp = new DataInputStream (System.in);       //Allows data to be input into the array
        String temp;                                       
        int length;                                                                  //Defines the length of the array for a loop later on
            for (order = 0 ; order < newnames ; order++)                                //<-
            {                                                                           //  Takes the inputed names and
                System.out.println (" Please input name ");                            //  gives them a number according to
                temp = keyboard.readLine ();                                           //  the order they were inputed in
                array [order] = temp;                                                  //<-
            for (order = newnames - 1 ; order >= 0 ; order--)                                //<-
            {                                                                                //  Outputs the names in the reverse 
                System.out.print (" \n ");                                                   //  order that they were inputed
                System.out.println (" Name " + order + " is " + array [order]);             //<-
            for (order = 0 ; order < newnames ; order++)                                  //<-
                if (array [order].startsWith ("M") || array [order].startsWith ("m"))     //  Finds and outputs any and all
                {                                                                         //  names that begin with M or m
                    System.out.print (" \n ");                                            //
                    System.out.println (array [order] + (" starts with M or m"));         //
                }                                                                         //<-
            for (order = 0 ; order < newnames ; order++)                                            //<-
                length = array [order].length ();                                                   //
                if (length >= 5)                                                                    //  Finds and outputs names
                {                                                                                  //  with 5 or more letters
                    System.out.print (" \n ");                                                      //
                    System.out.println ("Name " + array [order] + " have 5 or more letters ");      //<-
}The notepad file contains the following names:
jim
laruie
tim
timothy
manny
joseph
matty
amanda
I have tried various methods but the one thing that really gets me is the fact that i can't find a way to connect the names to the arrays. Opening the file with FileInputStream is easy enough but using the names and then outputing them is quite hard. (unless i'm thinking too hard and there really is a simple method)

By "connect", do you just mean you want to put the names into an array?
array[0] = "jim"
array[1] = "laruie"
and so on?
That shouldn't be difficult at all, provided you know how to open a file for reading, and how to read a line of text from it. You can just read the line of text, put it in the array position you want, until the file is exhausted. Then open a file for writing, loop through the array, and write a line.
What part of all that do you need help with?

Similar Messages

  • Need Help with .nnlp File.............A.S.A.P.

    I'm having a problem also with my JNLP file. I have downloaded the program onto one computer and that computer is using j2re1.4.2_04
    The other computers I believe are all running j2re 1.4.2_05
    I'm not sure if that's make a difference, but on the computer with j2re 1.4.2_05 when going to the site where the .jnlp file is located, the application comes up and says Starting Application. After it gets to that screen it just stays there. I really need help with this as soon as possible.
    Here is my .jnlp file listed below:
    <?xml version="1.0" encoding="utf-8"?>
    <jnlp
      spec="1.0+"
      codebase="http://www.appliedsolutions.com/placewiz"
      href="Placewiz.jnlp">
      <information>
        <title>Placement Wizard 4.0</title>
        <vendor>Applied Solutions, Inc.</vendor>
        <homepage href="index.html"/>
        <description>Placement Wizard 4.0</description>
        <description kind="short">Short description goes here.</description>
        <offline-allowed/>
      </information>
      <resources>
        <j2se version="1.4+"/>
        <j2se version="1.3+"/>
         <j2se version="1.5+"/>
        <jar href="Placewiz.jar"/>
      </resources>
      <security>
          <all-permissions/>
      </security>
      <application-desc main-class="com/asisoftware/placewiz/loader/Exec">
    </jnlp>

    This was due to a change in 1.4.2_05
    the main class attribute
    main-class="com/asisoftware/placewiz/loader/Exec">is wrong - it should be:
    main-class="com.asisoftware.placewiz.loader.Exec">this didnt seem to mater before 1.4.2_05, but some change in java since then caused this bad class specification to stop loading.
    /Andy

  • Urgent Help With Connections File Needed Please

    Hello All!
    I am getting the following error when I attempt to test my
    live site. I am testing database connectivity within my site that
    is hosted by GoDaddy. All pages are ASP and the database is stored
    in the root directory in GoDaddy's folder called "access_db". The
    folder has read/write access.
    Here is the error:
    Microsoft JET Database Engine error '80040e4d'
    Cannot start your application. The workgroup information file
    is missing or opened exclusively by another user.
    /sitename/requestquote/index.asp, line 130
    Here is the code from the connections file:
    <%
    ' FileName="Connection_ado_conn_string.htm"
    ' Type="ADO"
    ' DesigntimeType="ADO"
    ' HTTP="false"
    ' Catalog=""
    ' Schema=""
    Dim MM_connNAME_STRING
    MM_connNAME_STRING =
    "Provider=Microsoft.Jet.OLEDB.4.0;DataSource=username\access_db\filename.mdb;UserId=usern ame;Password=password;"
    %>
    The error above refrences "/sitename/requestquote/index.asp,
    line 130", and here is the code:
    rs_quote.ActiveConnection = MM_connNAME_STRING
    Please help.
    Thanks - Matt

    Sorry Tim? This is Dave. Did you read what said? I'm not
    Matt.
    Dave
    "TC2112" <[email protected]> wrote in message
    news:[email protected]...
    > It could be, you'd have to check in the control panel to
    make sure
    > permissions are set to read and write.
    > Have you tried changing the path in your connection
    string to the GoDaddy
    > path and uploading the file?
    > The info I posted tells you how to find out what the
    path on GoDaddy is.
    >
    > Tim
    >
    >
    > "Baxter" <baxter(RemoveThe :-)@gtlakes.com> wrote
    in message
    > news:[email protected]...
    > > Tim,
    > > Very good reply! I have no experience with GD other
    than the complaints
    I
    > > have read here about connections to databases etc.
    I think that if his
    > > connection test is ok that it has to be a
    permissions issue? What do you
    > > think?
    > > Dave
    > > "TC2112" <[email protected]> wrote in message
    > > news:[email protected]...
    > >> Hello,
    > >>
    > >> Sorry if some of this is repetitive in respect
    to what others have
    > >> advised
    > >> in this thread.
    > >> It's an answer I gave someone with similar
    problems a while ago.
    > >> It does answer your question about the
    successful path on your local
    > > server
    > >> being different than the path on GDs server.
    > >> There are also instructions on how to find the
    path on GD's server if
    > > needed
    > >> for DNS-Less connection.
    > >>
    > >>
    > >> Option 1:
    > >> You can try using a map path function like this
    in your connection
    > >> string:
    > >> access_db is the folder the database is in and
    mydatabase.mdb is the
    > > access
    > >> file.
    > >> Substitute your names.
    > >>
    > >> STRING = "Provider=Microsoft.Jet.OLEDB.4.0;Data
    Source=" &
    > >> Server.MapPath("access_db") &
    "\mydatabase.mdb;User Id=admin;Password="
    > >>
    > >> -or-
    > >>
    > >> Option 2:
    > >> You could try an OLEDB DSN-Less connection
    instead of using a DSN. It's
    > > not
    > >> hard to do.
    > >>
    > >> Step 1 is to figure out the location of the
    root directory on the
    host's
    > >> server..That's very easy to do yourself.
    > >>
    > >> Just make an asp page (I named mine
    "findit.asp"), and put the
    following
    > >> code between the <body> tags, like so:
    > >> <body>
    > >> <%
    > >> Response.Write("The location of this page
    is:<br>")
    > >>
    Response.Write(Request.ServerVariables("PATH_TRANSLATED") &
    "<br>")
    > >> Response.Write("The location of my root
    directory is:<br>")
    > >> Response.Write(Server.MapPath("\"))
    > >> Response.Write Path
    > >> %>
    > >> </body>
    > >>
    > >>
    > >> Upload it to the same location as your site's
    home page.
    > >> Once your new asp page is uploaded, just
    navigate to that page in your
    > >> browser.
    > >>
    > >> For a site on GD the "findit.asp" page displays
    something like this:
    > >>
    > >> The location of this page is:
    > >> d:\hosting\mysite\findit.asp
    > >> The location of my root directory is:
    > >> d:\hosting\mysite
    > >>
    > >> Now that you know the root directory location
    on their server, you can
    > >> figure out the path to your database.
    > >> Let's say that the folder your database is in
    is named _private, and
    it
    > >> happens to be in the root
    > >> directory along with your home page.
    > >>
    > >> Next, just add the database folder name
    (_private) and the database
    > >> inside's name (mydatabase.mdb) to the root
    directory location:
    > >>
    > >> d:hosting\mysite\_private\mydatabase.mdb
    > >>
    > >> That's your Data Source path.
    > >>
    > >> The connection string would look something like
    this:
    > >>
    > >> = "Provider=Microsoft.Jet.OLEDB.4.0;Data
    > >>
    Source=d:hosting\mysite\_private\mydatabase.mdb;User
    ID=;Password=;"
    > >>
    > >> (the code above may appear wrapped (two lines)
    in the forum/ng but it's
    > > one
    > >> line with no return within)
    > >>
    > >> IMPORTANT: If you are using a local testing
    server, make a copy of your
    > >> connection asp page as a backup.
    > >> The reason? The connection information you are
    going to put in this
    file
    > >> will only work on the host's server.
    > >> Once you upload the new connection.asp page
    with the changes for the
    > >> host,
    > >> you'll need to change your local copy back to
    your local connection so
    it
    > >> will work on
    > >> your local testing server.
    > >>
    > >> Upload to server.
    > >>
    > >> Please note: From now on, when you upload (or
    "put" if you're using DW)
    > >> files that refer to your connection asp page
    you're going to get a
    > >> warning
    > >> that your connection asp on the host is
    different than your local copy.
    > >> Always say "No" to updating it, or you'll
    replace the GD DSN-Less
    > > connection
    > >> with your local one.
    > >>
    > >>
    > >> Did you set the appropriate read/write
    permissions on the
    > > directory(folder)
    > >> your database is in?
    > >> You can do that in GD's control panel.
    Hosting> Select your site >
    Manage
    > > to
    > >> open it.
    > >>
    > >> I hope this helps.
    > >>
    > >> For what it's worth, I only use GD for domain
    names now.
    > >> I had numerous problems with some sites hosted
    there, switched them to
    > >> HostMySite and haven't had any.
    > >>
    > >> Take care,
    > >> Tim
    > >>
    > >>
    > >>
    > >>
    > >>
    > >> "Baxter" <baxter(RemoveThe
    :-)@gtlakes.com> wrote in message
    > >> news:[email protected]...
    > >> > Baxter - I get "Connection was Made
    Successfully" if connection to
    the
    > >> > database was made Successfully not sure
    what's going on here? When
    you
    > >> > look
    > >> > at your site files in Dreamwerer on the
    server is there a folder
    named
    > >> > access_db? If so is your data base in that
    folder? The database needs
    > >> > permissions set to read and write to that
    file. Have you checked
    > >> > permissions
    > >> > on the site? does GD give you a control
    panel so that you can set the
    > >> > permissions your self? I have never used
    GD but have seen where
    people
    > >> > have
    > >> > had lots of problems with them when using
    a scripting language. I
    don't
    > >> > know
    > >> > what else it could be at this point.
    > >> > Dave
    > >> > "mtrueblood"
    <[email protected]> wrote in message
    > >> > news:[email protected]...
    > >> >> Baxter - I get "Connection was Made
    Successfully" with the
    credentials
    > >> >> you
    > >> > gave
    > >> >> me. My site works just fine on my
    local machine with
    > > access_trueblood.dsn
    > >> > (it
    > >> >> also worked with the dsn I initally
    created for the site). All pages
    > >> > display
    > >> >> and I get no errors. I think where the
    issue may be, now I am
    guessing
    > >> > here, is
    > >> >> that my connection refrences a
    database located in the folder
    > >> >>
    C:\Users\Administrator\Websites\Sitename\access_db, but once I
    upload
    > > my
    > >> > site,
    > >> >> the database still sits in access_db,
    but the root folder possibly
    has
    > >> > changed
    > >> >> (maybe causing the connection to
    fail).
    > >> >>
    > >> >> Dooza - I don't understand how I can
    use "c:myDsnFile.dsn", when
    once
    > > I
    > >> > upload
    > >> >> my site, "c:myDsnFile.dsn" would then
    not be the location of my dsn.
    > >> >> "c:myDsnFile.dsn" refrences a file on
    my computer. I am using an
    > >> >> online
    > >> > hosting
    > >> >> company. Am I not understanding you
    correctly? See note above. I did
    > > use
    > >> > your
    > >> >> information and got the following
    browser error:
    > >> >>
    > >> >> Microsoft OLE DB Provider for ODBC
    Drivers error '80004005'
    > >> >> General error: Invalid file dsn ''
    > >> >> /sitename/contactus/index.asp, line
    130
    > >> >>
    > >> >> line 130 -
    rs_contactus.ActiveConnection = MM_connTrueblood_STRING
    > >> >>
    > >> >> I am researching on how to do a
    dsn-less connection, unless I can
    get
    > >> > this
    > >> >> figured out.
    > >> >>
    > >> >> Thanks - Matt
    > >> >>
    > >> >
    > >> >
    > >>
    > >>
    > >
    > >
    >
    >

  • I need help with viewing files from the external hard drive on Mac

    I own a 2010 mac pro 13' and using OS X 10.9.2(current version). The issue that I am in need of help is with my external hard drive.
    I am a photographer so It's safe and convinent to store pictures in my external hard drive.
    I have 1TB external hard drive and I've been using for about a year and never dropped it or didn't do any thing to harm the hardware.
    Today as always I connected the ext-hard drive to my mac and click on the icon.
    All of my pictures and files are gone accept one folder that has program.
    So I pulled up the external hard drive's info it says the date is still there, but somehow i can not view them in the finder.
    I really need help how to fix this issue!

    you have a notebook, there is a different forum.
    redundancy for files AND backups, and even cloud services
    so a reboot with shift key and verify? Recovery mode
    but two or more drives.
    a backup, a new data drive, a drive for recovery using Data Rescue III
    A drive can fail and usually not if, only when
    and is it bus powered or not

  • MSI P67A-C45 (B3) Newb needs Help with connections..

    Hi all..
    First time posting here, but have been in the shadows for quite a while..   
    Anyway, i decided to finally take the plunge, and build my own PC, and now i'm beginning to hit a few bumps.
    I have a couple of questions that i would like some help with, if possible to reassure myself i may be in the right direction..
    I bought THIS PSU and was hoping someone could tell me where the Blue connectors (one labelled CP and one labelled U1) Connect to?
    Is it into JPWR2? And does it/do they only connect in the correct way? (Do i remove the plastic cap and attach both?
    and i bought THIS VIDEO/GRAPHICS CARD and i'm guessing the RED "PCI express" and "SLI ready" connect to that somehow (Haven't opened box yet for card)
    Again, wondering is there a certain way for them to connect.
    Also, from my chassis, the "AC '97" and "HDA" connectors go to JAUD (I guess), does it matter which one? (I currently have "HDA" connected)
    I have i5 2500k already on board. (If that makes a difference).

    Quote from: Ben_Cartwright on 26-May-11, 22:05:35
    Do the Audio plugs go into JAUD? and does it matter which one?
    Yep, connect the front panel audio to the JAUD. If you need the pin layout, it says in the manual. I would say the HDA connector is the one to connect.
    Quote from: Ben_Cartwright on 26-May-11, 22:05:35
    Any recommendations for testing it all, before i plug it in, and press the power?
    Should i (Can i) test individual parts first?
    Thanks again.
    Check all power connections, seating of the RAM and add-on cards, check the HSF is plugged into the fan header, and obvious things like that.
    As for testing, enter the BIOS and make sure the CPU isn't running too hot. Set up the RAM with the required timings and voltage, and test with >>Memtest86<< for several hours. No point starting the Windows installation if say your RAM has errors, since it will corrupt files during the install, if it installs at all.

  • Need help with backup files made by HP Recovery.

    So in 2011 I had made a post about a DV9 series HP laptop I had that I felt needed a harddrive. Well the laptop has been sold to a friend of mine and he has since fixed the issue it had. My curent deboggle is trying to deal with the 36GB of data it backed up onto an external USB powered harddrive. The information was saved from a system that ran Windows VISTA, on that same DV9 Pavilion. I have a new laptop and it's a Pavilion DV6 running windows 7. Is there some sort of 3rd party application or an uncommon HP utility that can open, run or modify. Specificaly I need to some files but not all, but if my only option is to extract all then that would be fine also. There is an executible in the backup folder but it doesn't extract anything it just locks up. 
    For the TLR portion, need to access backup files made on an older HP laptop with windows vista to a newer HP latop running windows 7.

    Terribly sorry for the post, I should have researched more before posting. I found the answer to my issue in another thread here on the HP forums! Thanks so much!!

  • Need help with fla.file

    Hi!
    I'm always having trouble with a fla.file in cs3 professional. Every time i try to reopen the file in flash i get this:
    failed to open document/users.desktop/jason/social.fla
    pls help reopen this file
    jay

    create a new directory and move your fla there and try and open.  if that fails, change the file's name and try and reopen.  if that fails and you created the fla, it's probably corrupt.

  • Need help with batch file for javac.exe and java.exe

    I have this in my batch file:
    c:\jdk1.3.1_05\bin\javac
    What symbol do I need to be able to run this from cprompt with any file following it

    Thanks could remember that for nothing

  • Need help with copying files onto external drive

    I need help! Trying to copy downloaded movie files from Vuze (which have downloaded successfully) and copy onto external hard drive to view them but it wont let me copy over to the external device. Any ideas how to fix this please???

    Can you explain the steps you used, and the error message (or symptom), that says the copy did not work? 

  • Need help with simple file sharing application

    I have an assignment to build a Java File Sharing application. Since I'm relatively new to programming, this is not gonna be an easy task for me.
    Therefore I was wondering if there are people willing to help me in the next few days. I will ask questions in this thread, there will be loads of them.
    I already have something done but I'm not nearly halfway finished.
    Is there a code example of a simple file sharing application somewhere? I didn't manage to find it.
    More-less, this is what it needs to contain:
    -client/server communication (almost over)
    -file sending (upload, download)
    -file search function (almost over)
    -GUI of an application.
    GUI is something I will do at the end, hopefully.
    I hope someone will help me. Cheers
    One more thing, I'm not asking for anyone to do my homework. I will only be needing some help in the various steps of building an application.
    As I said code examples are most welcome.
    This is what I have done so far
    Server:
    package ToJeTo;
    import java.io.*;
    import java.net.*;
    public class MultiServer {
        public static ServerSocket serverskiSoket;
        public static int PORT = 1233;
        public static void main(String[] args) throws IOException {
            try {
                serverskiSoket = new ServerSocket(PORT);
            }catch (IOException e) {
                System.out.println("Connection impossible");
                System.exit(1);
            do {
                Socket client = serverskiSoket.accept();
                System.out.println("accepted");
                ClientHandler handler = new ClientHandler(client);
                handler.start();
            } while(true);
    }Client:
    package ToJeTo;
    import java.io.IOException;
    import java.io.PrintWriter;
    import java.net.*;
    import java.util.Scanner;
    public class MultiClient {
        public static InetAddress host;
        public static int PORT = 1233;
        public static void main(String[] args) {
            try {
                host = InetAddress.getLocalHost();
            }catch (UnknownHostException uhe) {
                System.out.println("Error!");
                System.exit(1);
            sendMessages();
        private static void sendMessages() {
            Socket soket = null;
            try {
                soket = new Socket(host, PORT);
                Scanner networkInput = new Scanner(soket.getInputStream());
                PrintWriter networkOutput = new PrintWriter(soket.getOutputStream(), true);
                Scanner unos = new Scanner(System.in);
                String message, response;
                do {
                    System.out.println("Enter message");
                    message = unos.nextLine();
                    networkOutput.println(message);
                    response = networkInput.nextLine();
                    System.out.println("Server: " + response);
                }while (!message.equals("QUIT"));
            } catch (IOException e) {
                e.printStackTrace();
            finally {
                try{
                    System.out.println("Closing..");
                    soket.close();
                } catch (IOException e) {
                    System.out.println("Impossible to disconnect!");
                    System.exit(1);
    }ClientHandler:
    package ToJeTo;
    import java.io.*;
    import java.net.*;
    import java.util.*;
    public class ClientHandler extends Thread {
        private Socket client;
        private Scanner input;
        private PrintWriter output;
        public ClientHandler(Socket serverskiSoket) {
            client = serverskiSoket;
            try {
            input = new Scanner(client.getInputStream());
            output = new PrintWriter(client.getOutputStream(), true);
            } catch (IOException e) {
                e.printStackTrace();
            public void run() {
                String received;
                do {
                received = input.nextLine();
                output.println("Reply: " + received);
                } while (!received.equals("QUIT"));
                try {
                    if (client != null)
                        System.out.println("Closing the connection...");
                        client.close();
                }catch (IOException e) {
                    System.out.println("Error!");
    }Those three classes are simple client server multi-threaded connection.

    Now the other part that contains the search function looks like this:
    package ToJeTo;
    import java.io.*;
    import java.util.*;
    public class User {
        String nickname;
        String ipAddress;
        static ArrayList<String> listOfFiles = new ArrayList<String>();
        File sharedFolder;
        String fileLocation;
        public User(String nickname, String ipAddress, String fileLocation) {
            this.nickname = nickname.toLowerCase();
            this.ipAddress = ipAddress;
            sharedFolder = new File(fileLocation);
            File[] files = sharedFolder.listFiles();
            for (int i = 0; i < files.length; i++) {
                listOfFiles.add(i, files.toString().substring(fileLocation.length()+1));
    public static void showTheList() {
    for (int i = 0; i < listOfFiles.size(); i++) {
    System.out.println(listOfFiles.get(i).toString());
    @Override
    public String toString() {
    return nickname + " " + ipAddress;
    User Manager:
    package ToJeTo;
    import java.io.*;
    import java.util.*;
    class UserManager {
        static ArrayList<User> allTheUsers = new ArrayList<User>();;
        public static void addUser(User newUser) {
            allTheUsers.add(newUser);
        public static void showAndStoreTheListOfUsers() throws FileNotFoundException, IOException {
            BufferedWriter out = new BufferedWriter(new FileWriter("List Of Users.txt"));
            for (int i = 0; i < allTheUsers.size(); i++) {
                    System.out.println(allTheUsers.get(i));
                    out.write(allTheUsers.get(i).toString());
                    out.newLine();
            out.close();
    }Request For File
    package ToJeTo;
    import java.util.*;
    public class RequestForFile {
        static ArrayList<String> listOfUsersWithFile = new ArrayList<String>();
        Scanner input;
        String fileName;
        public RequestForFile() {
            System.out.println("Type the wanted filename here: ");
            input = new Scanner(System.in);
            fileName = input.nextLine();
            for (User u : UserManager.allTheUsers) {
                for (String str : User.listOfFiles) {
                    if (str.equalsIgnoreCase(fileName))
                        listOfUsersWithFile.add(u.nickname);
        public RequestForFile(String fileName) {
            for (User u : UserManager.allTheUsers) {
                for (String str : User.listOfFiles) {
                    if (str.equalsIgnoreCase(fileName))
                        listOfUsersWithFile.add(u.nickname);
        public static List<String> getAll() {
            for (int i = 0; i < listOfUsersWithFile.size(); i++) {
                //System.out.println("User that has the file: " + listOfUsersWithFile.get(i));
            return listOfUsersWithFile;
    }Now this is the general idea.
    The user logs in with his nickname and ip address. He defines his own shared folder and makes it available for other users that log on to server.
    Now each user has their own list of files from a shared folder. It's an ArrayList.
    User manager class is there to store another list, a list of users that are connected with server.
    When the user is searching for a particular file, he is searching through all the users and their respective files lists. Therefore for each loop inside a for each loop.
    Now the problem is how to connect all that with Client and Server class and put it into one piece.
    GUI should look somewhat like this:

  • Need help with connected / linked pop-up menus

    I want to select a preset.
    What I did is create 2 pop-up menus. The first with the preset folders and the second with the presets from that folder.
    Each pop-up group has a pop-up and a static field with the current choise.
    After selecting a different value from the first pop-up menu I want to have the second popup menu filled with the new, right presets of that folder.
    The first time everything works correct.
    However when selecting a different folder I see that the "preset table"  is filled with the correct new preset of that folder. Also the static field below the second pop-up menu shows the first value of the correct new presets. But the second pop-up menu itself still contains the presets of the first folder and not the new folder.
    Yet in the Observer I see that the preset table contains the right and new presets.
    My code is below.
    I based it on the sample in the SDK manual.
    Question: How can I update the second pop-up menu so that the pop-up menu shows the right presets.
    Code below
    local LrApplication = import 'LrApplication'
    local LrPathUtils = import 'LrPathUtils'
    local LrFileUtils = import 'LrFileUtils'
    local LrBinding = import "LrBinding"
    local LrDialogs = import "LrDialogs"local LrFunctionContext = import "LrFunctionContext"
    local LrView = import "LrView"
    local bind = LrView.bind -- shortcut for bind() method
    --     https://github.com/kikito/inspect.lua
    local inspect = require 'inspect'
    local logFilename = 'PresetList'
    local myLogger = import 'LrLogger'( logFilename )
    myLogger:enable( "logfile" )
    local logPath
    Name          emptyLogFile
    Purpose          Clears the existing log file.
    From cookbook: http://cookbooks.adobe.com/post_Clearing_your_logfile_automatically-19677.html
    function emptyLogFile()
    --local myLogger = import 'LrLogger'( 'Stash' )
    myLogger:disable()
    logPath = LrPathUtils.child(LrPathUtils.getStandardFilePath('documents'), logFilename .. ".log")
    if LrFileUtils.exists( logPath ) then
    local success, reason = LrFileUtils.delete( logPath )
    if not success then
    logger:error("Error deleting existing logfile!" .. reason)
    end
    end
    myLogger:enable( "logfile" )
    end
    Name          getLocationLogFile.
    Purpose          Returns the full path of the current log file.
    function getLocationLogFile()
    return logPath
    end
    local function getPresetFolders()
    -- Get all folders with presets
        local lrPresetFolders = LrApplication.developPresetFolders()
        local presetFolderCache = {}
    local record = {}
        for i, fo in ipairs( lrPresetFolders ) do
    record = {title = fo:getName(), value = fo }
    --record = {title = fo:getName(), value = fo:getName() }
    --myLogger:info( "folder name = " .. fo:getName() )
    table.insert ( presetFolderCache, record )
    end
    --     myLogger:info("Voor de listing")
    --     myLogger:info("preset Folders : " .. inspect (  presetFolderCache ) )
    return presetFolderCache
    end
    local function getPresets ( folderObject )
    local presets = folderObject:getDevelopPresets()
    local presetCache = {}
    local record = {}
    for j, p in ipairs( presets ) do
    record = {title = p:getName(), value = p:getName() }
    --record = {title = p:getName(), value = p:getName() }
    myLogger:info( "getPresets = " .. p:getName() )
    table.insert ( presetCache, record )
    end
    myLogger:info("presets : " .. inspect (  presetCache ) )
    return presetCache
    end
    local function ChoosePreset()
    emptyLogFile()
    local presetFolders = getPresetFolders()
    local currentPresetFolder = presetFolders[1]["value"]
    local presets = getPresets ( currentPresetFolder )
    myLogger:info(presets)
    --     myLogger:info("preset Folders : " .. inspect (  presetFolders ) )
    LrFunctionContext.callWithContext( 'Pop-up example', function( context )
    local f = LrView.osFactory() -- obtain view factory
    local properties = LrBinding.makePropertyTable( context ) -- make prop table
    -- create some keys with initial values
    properties.presetFolder = presetFolders[1]["value"] -- for radio buttons and pop-up menu
    properties.preset = presets[1]["value"]
    properties:addObserver( 'presetFolder', function( properties, key, newValue )
    myLogger:info("Observer - get preset list" )
    currentPresetFolder = properties.presetFolder
    presets = getPresets ( currentPresetFolder )
    myLogger:info(presets)
    myLogger:info("Observer - Preset table: " .. inspect ( presets ) )
    --     Set the new value
    properties.preset = presets[1]["value"]
    myLogger:info("Observer: " .. presets[1]["title"] )
    end )
    --     myLogger:info("presetFolder = " .. properties.presetFolder )
    --     myLogger:info("preset = " .. properties.preset )
    local contents = f:column { -- create view hierarchy
    fill_horizontal = 1,
    spacing = f:control_spacing(),
    bind_to_object = properties, -- default bound table is the one we made
    f:group_box {
    title = "Preset folders",
    fill_horizontal = 1,
    spacing = f:control_spacing(),
    f:popup_menu {
    value = bind 'presetFolder', -- current value bound to same key as static text
    items = presetFolders
    f:static_text {
    fill_horizontal = 1,
    title = bind 'presetFolder', -- bound to same key as current selection
    f:group_box {
    title = "Presets",
    fill_horizontal = 1,
    spacing = f:control_spacing(),
    f:popup_menu {
    value = bind 'preset', -- current value bound to same key as static text
    items = presets
    --     items = getPresets ( currentPresetFolder )
    f:static_text {
    fill_horizontal = 1,
    title = bind 'preset', -- bound to same key as current selection
    local result = LrDialogs.presentModalDialog( -- invoke the dialog
    title = "Select preset",
    contents = contents,
    end
    end
    -- Now display the dialogs
    ChoosePreset()

    That should work because you are likely to be creating a new table each time computeNewItems() executes..
    Sometime the bind function doesn't recognise whether the contents of a table bound to a property changes. So if you use something like this:
    local myItems = computeNewItems() -- compute array of tables with title and value members
    properties['myPresetItems'] = myItems --  assign to bound member of property table.
    it will work the first time. If you then do this:
    myItems = computeNewItems() -- compute array of tables with title and value members but using existing variable
    properties['myPresetItems'] = myItems --  assign to bound member of property table. Change might not be noticed by bind.
    In this instance you would need to reassign the same value again. i.e.
    properties['myPresetItems'] = myItems --  assign to bound member of property table again to force bind to check for table values.
    Setting a property with the same value twice seems to trick bind into checking to see whether you have bound a table. I'm not sure whether this trick is only required on some versions of LR (e.g. LR 2) or only on one of the platforms, but even if it isn't required in LR 5 it will help improve your backwards compatibility and it shouldn't cause any harm to continue using it in LR 5.
    Matt

  • Need help with java file scanner and objects

    Hi, i've got an assignment that asks me to do these, but i cant seem to get around in solving it. Any help will be much appreciated. TYVM!
    Create a class called TVProgram that can store some important details of a television program:
    - name of the show
    - the channel the show is on
    - the start time (in 24-hour format)
    - the end time (in 24-hour format)
    Write a program that uses this class.
    Your program will read a list of TV programs, making up a schedule for an evening's TV: for you convenience, you will be able to download a sample file listing. The listing will consist of one line for each of the above fields, in the above order, for each program, followed by a line containing only the "#" character. For example, here is the start of such a file.
    At the Movies
    ABC
    1800
    1830
    The Einstein Factor
    ABC
    1830
    1900
    Your program should start with a little menu to prompt whether to read from standard input or a file:
    Please choose a number for the way you will input the TV schedule:
    1. Read from standard input
    2. Input from a file
    Your program should first read the complete schedule, then loop through all the programs in the schedule and prompt the user as to whether they want to record the program or not. For example, the program should print:
    At the Movies is showing on ABC from 1800 to 18.30.
    Do you want to record it: type Y or N.
    If the user types Y then the program sets this T Vprogram to be recorded. If the user types N, the program goes to the next entry and prompts the user again. If the user types something other than a Y or N (or y or n), then the program should prompt for a proper answer:
    Do you want to record it: type Y or N.
    Once the complete schedule has been shown to the user, the program loops through those that the user has said they want to record and checks for any clashes---i.e. any times at which the user wants to record two programs at the same time. For any clashes, your program should show these to the user and insist that only one be selected for being recorded. For example:
    At 1830 you want to record both 1. The Einstein Factor on ABC and 2. The Biggest Loser on Ten.
    Please pick option 1 or 2 to record.
    Again, if the user selects an option other than 1 or 2 in the above, then the program should make the user to make another selection until they type a legal value.
    If the schedule is in time-start order (see "Assumptions" below), then a simple way to check for clashes is:
    - as you loop through the schedule of shows, keep track of the latest end-time the user wants to record;
    - if any program the user says they want to record has a start-time before this latest end-time, then this is a clash.
    There are different ways to keep track of clashes: you can keep an array (a list of clashes) of arrays (each of these is the list of clashing programs); you could create a Clash class.
    Finally, after going through all clashes, print out the list of programs that the user still wants recorded.
    Here is the list of programs that will be recorded for you:
    From 1830 to 1930, The Biggest Loser, on Ten.
    From 1930 to 2030, Who Do You Think You Are, on SBS
    -----

    * @(#)TVProgram.java
    * @author      Okky Satya
    * @version 1.00 2008/3/29
    import java.util.*;
    import java.io.*;
    public class TVProgram {
         private String name;
         private String chnl;
         private int strt;
         private int ends;
         public TVProgram(String showName, String channel, int start, int end ){
              this.name = showName;
              this.chnl = channel;
              this.strt = start;
              this.ends = end;
        public static void readFileInput() {
        List prog = new ArrayList();
        Scanner inputFile = null;
         try
        inputFile = new Scanner(new File("tv_schedule"));
         catch (FileNotFoundException fe)
        System.out.println("File not found!");
        System.exit(0);
        while(inputFile.hasNext()== true){
             while (inputFile.nextLine()!="##")
                  new TVProgram;
        public static void readInput(){
        public static void loopInput(){
        public static void showList(){
        public static void checkUserList(){
        public static void main(String[] args){
             int menuChoice = 0;
             System.out.println("Please choose a number for the way you will input the TV schedule:\n  1. Read from standard input\n  2. Input from a file");
             switch(menuChoice){
                  case 1:
                       readInput();
                       break;
                  case 2:
                       readFileInput();
                       break;
             loopInput();
             checkUserList();
             showList();
    }

  • CS5.5 need help with connecting to wsdl

    Hello,
    I'm new to Dreamweaver CS5.5 and i'm looking for a simple way to connect to a CFC wsdl web service.
    Basically need to pass 1 parameter to the webservice and have it return a string result from our database.
    Is this possible to do from dreamweaver, using javascript ?
    thanks.

    Those crosshairs are controllers for an effect. The first thing to do is to start turning off layers (eyeball) until you find the layer with the crosshairs. Once you've isolated the layer make sure that it's not a pre-comp, press F3 to reveal the ECW, and check the effects. If you can't turn the effects on and off then or access any of the settings the layer is locked. What would really help here is a screenshot. I can't tell much from the photo because I can't see what's under the hood.

  • Need help with moving files into Itunes and syncing

    Please help.
    I have an external hard drive with my music on it.  I created a new playlist in Itunes and did a drag and drop from my external hard drive into my newly created playlist. 
    Now that I go back and play the items I brought over, I get an error that says "original files not found" and it won't play and therefore does not seem to be syncing to the Ipod to be able to play.
    Can you please give me guidance as to what I can do without recreating all the work I had already done?
    Thanks,
    Michelle

    Is the external drive connected?
    Has the drive letter possibly changed due to being disconnected and reconnected?

  • Need Help With Appleworks Files on New Macbook

    Hey Everyone,
    I had an old iMac blueberry with OS 9.2 using appleworks. I just bought a MACBOOK and i got iWORK and MS OFFICE 2004 installed on it. How can i get my appleworks files to open up on my new MACBOOK.
    please help
    -

    will Appleworks transfer and run on an INTEL based
    MAC?
    AppleWorks 6 is a "package" that contains both a Classic (Mac OS 9) application and an OS X application. The rest of what's essential to AppleWorks 6's operation is included in the other items inside the AppleWorks 6 folder. AppleWorks will generate all needed items outside this folder when it is run.
    The OS X application will operate (and operate well) on the intel based Macs using Rosetta, which is included with these machines. AW 6.2.4 and AW 6.2.9 (IN Mac OS 9, the version numbers on the splash screen and in About AppleWorks for these two are 6.2.3 and 6.2.8) are the most stable and least error prone in OS X; update before or after the transfer if you have earlier versions.
    Remember also that your AppleWorks license allows for only one copy to be installed on a computer. If you want to continue to use AppleWorks on the G3 iMac, you'll need to purchase a retail copy to install on the MacBook.
    Regards,
    Barry

Maybe you are looking for

  • MDM Data Manager Assignments using Dates

    Hello. I am trying to create some assignments that default to a certain date and my expressions are getting the error message when I execute them. I am currently trying to create an Assignment for the Look-up table: Valid To (which belongs to the QT:

  • Help me please!!!! this is deseperating!!!!

    Hi, I'm really dissapointed of Mac annd HP, I have looked at their online support but for some unknown reason they can't help me, I have followed all the informations the have in their websites but nothing works. I have posted this before but none se

  • Miro line item quantity and amount after miro

    Dear Forum, I have got the help about this subject and quite clear. Thanks for all have helped. Now I need to confirm 1 more part. Assuming in PO there are 2 scenarios where gr based iv is ticked and also not ticked, after both GR and miro done (comp

  • When to support autocad 2012 in acrobat x?

    It was long time that Autodesk release autocad 2012 products, but it is still missing pdf converting toolbox in ACad 2012. So is there any update or time talbe about this? Thank you all~ Regards from Asia

  • IPhone won't reboot past Apple logo.

    iPhone 4 won't reboot past Apple logo. It will not show up in iTunes to perform a restore. I can't even get it to turn off. Help?