Need some help with this code.

var myDoc = app.documents[0]
var mySel = app.selection[0]
var myStory = mySel.parentStory; // Now we are pointing to the entire story
var myHolidayStyle1 = "Holiday-Header" // Header 'day of the week'
var myHolidayStyle2 = "Holiday-Sub-Heading-Date" // Header 'month and day'
var myHolidayStyle3 = "Holiday-Header-Body" // Lead Paragraph 'default paragraph style'
if (mystory = "Monday" ) {
    paragraphs(0).appliedparagraphstyles = myHolidayStyle1;
else if (mystory = "Tuesday") {
    mystory.paragraphs(0). appliedparagraphstyles = myHoldiayStyle1;
else if (mystory = "Wednesday") {
    mystory.papragraph(0).appliedparagraphstyles = myHolidayStyle1;
else if (mystory = "Thursday") {
    mystory.paragraphs(0).appliedparagraphstyles = myHolidayStyle1;
else if (mystory = "Friday")  {
    mystory.paragraphs(0).appliedparagraphstyle = myHolidayStyle1;
else if (mystory = "Saturday") {
    mystory.paragraphs(0).appliedparagrahstyles = myHolidayStyle1;
else if (mystory = "Sunday") {
    mystory.paragraphs(0).appliedparagraphstyles = myHolidayStyle1;
// it finds if in the selection of the month and day if they equal for example Decmeber 15 then applies the HolidaySub-Heading-Date
if   (mystory = "December 15") {
    mystory. paragraphs(1).appliedparagraphstyles = myHolidayStyle2;
else if (mystory = "December 15") {
    mystory. paragraphs(1).appliedparagraphstyles = myHolidayStyle2;
else if (mystory = "December 16") {
    mystory. paragraphs(1).appliedparagraphstyles = myHolidayStyle2;
else if (mystory = "December 17") {
    mystory. paragraphs(1).appliedparagraphstyles = myHolidayStyle2;
else if (mystory = "December 18") {
    mystory. paragraphs(1).appliedparagraphstyles = myHolidayStyle2;
else if (mystory = "December 19") {
    mystory. paragraphs(1).appliedparagraphstyles = myHolidayStyle2;
else if (mystory = "December 20") {
    mystory. paragraphs(1).appliedparagraphstyles = myHolidayStyle2;
else if (mystory = "December 21") {
    mystory. paragraphs(1).appliedparagraphstyles = myHolidayStyle2;
else if (mystory = "December 22") {
    mystory. paragraphs(1).appliedparagraphstyles = myHolidayStyle2;
else if (mystory = "December 23") {
    mystory. paragraphs(1).appliedparagraphstyles = myHolidayStyle2;
else if (mystory = "December 24") {
    mystory. paragraphs(1).appliedparagraphstyles = myHolidayStyle2;
else if (mystory = "December 25") {
    mystory. paragraphs(1).appliedparagraphstyles = myHolidayStyle2;
// If text doesn't  equal Day of the week like Monday and doesn't equal month and date like Decmber 14
// then the document loops into doing the the rest of the document in Holiday-Header-Body
// not sure if this loop will stop once it reaches another day of the week and then repeat the above tasks again.
if (mystory =!  [myHolidayStyle0], [myHolidayStyle1]) { // not sure if I did this IF selection not equal Holidaystyle 0 and style 1 then perform loop, correctly???
    for (loop=0; loop<myStory.paragraphs.length; loop++)
  myStory.paragraphs[loop].appliedParagraphStyle = myHolidayStyle3;
=============================
==========================
I'm getting a error saying Paragraph is not a function, but nor is mystory.paragraph(0) , so i'm just trying to figure out what synax goes before that.
=============================
The text that is bold is the prolbem i'm having. I just got  a Javascript bible on how to program in javascript. How would i make that function work. I'm sure its simple. I'm just hoping I have If some Then ({) command follow by what I want it to do is correct. And I'm understanding this. there is so many different syntax's to choose from, any help would be appreciated. I work for a Newspaper company, and Indesign CS3 Javascript coding is a bit diffrent from normal javascript.

Okie, I'm making progress now. Because well it didnt crash, but then again, LOL the script didnt apply the paragraph styles when I selected the text!
any suggestions?
I'm also getting a weird error now with the loop, but I also dont think its working because maybe the myStyle and myStle1 aren't applying themselves correctly, in the first part of the script.
this is the Error Message:
Error Number : 30477
Error String: Invalid value of set propert 'appliedParagraphStyle'. Expected ParagraphStyle or String, but Recieved nothing.
Line: 110
Source: myStory.paragraphs[loop].appliedParagraphStyle = myStyle3;
//var myDoc = app.documents[0]
var mySel = app.selection[0];
var myStory = mySel.parentStory; // Now we are pointing to the entire story
var myStyle = app.activeDocument.paragraphStyles.item ( "Holiday-Header" ) ;
var myStyle1 = app.activeDocument.paragraphStyles.item ( "Holiday-Sub-Heading-Date" ) ;
var myStyle3 = app.activeDocument.paragraphStyles.item ( "Holiday-Header-Body" ) ;
if (myStory.contents == "Monday" ) {
    myStory.paragraphs.appliedParagraphStyle = myStyle;
else if  (myStory.contents == "Tuesday") {
    myStory.paragraphs[0]. appliedParagraphStyle = myStyle;
if  (myStory.contents == "Wednesday") {
    myStory.papragraph[0].appliedparagraphstyle = myStyle;
else if (myStory.contents == "Thursday") {
    myStory.paragraphs[0].appliedparagraphstyle = myStyle;
if  (myStory.contents == "Friday")  {
    myStory.paragraphs[0].appliedparagraphstyle = myStyle;
else if (myStory.contents == "Saturday") {
    myStory.paragraphs[0].appliedparagrahstyle = myStyle;
if  (myStory.contents == "Sunday") {
    myStory.paragraphs[0].appliedparagraphstyle = myStyle;
// it finds if in the selection of the month and day if they equal for example Decmeber 15 then applies the HolidaySub-Heading-Date
if   (myStory.contents == "December 2") {
    myStory. paragraphs[1].appliedparagraphstyle = myStyle1;
else if (myStory.contents == "December 3") {
    myStory. paragraphs[1].appliedparagraphstyle = myStyle1;
if   (myStory.contents == "December 4") {
    myStory. paragraphs[1].appliedparagraphstyle = myStyle1;
else if (myStory.contents == "December 5") {
    myStory. paragraphs[1].appliedparagraphstyle = myStyle1;
if   (myStory.contents == "December 6") {
    myStory. paragraphs[1].appliedparagraphstyle = myStyle1;
else if (myStory.contents == "December 7") {
    myStory. paragraphs[1].appliedparagraphstyle = myStyle1;
if   (myStory.contents == "December 8") {
    myStory. paragraphs[1].appliedparagraphstyle = myStyle1;
else if (myStory.contents == "December 9") {
    myStory. paragraphs[1].appliedparagraphstyle = myStyle1;
if   (myStory.contents == "December 10") {
    myStory. paragraphs[1].appliedparagraphstyle = myStyle1;
else if (myStory.contents == "December 11") {
    myStory. paragraphs[1].appliedparagraphstyle = myStyle1;
if   (myStory.contents == "December 12") {
    myStory. paragraphs[1].appliedparagraphstyle = myStyle1;
else if (myStory.contents == "December 13") {
    myStory. paragraphs[1].appliedparagraphstyle = myStyle1;
if   (myStory.contents == "December 14") {
    myStory. paragraphs[1].appliedparagraphstyle = myStyle1;
else if (myStory.contents == "December 15") {
    myStory. paragraphs[1].appliedparagraphstyle = myStyle1;
if  (myStory.contents == "December 16") {
    myStory. paragraphs[1].appliedparagraphstyle = myStyle1;
else if (myStory.contents == "December 17") {
    myStory. paragraphs[1].appliedparagraphstyle = myStyle1;
if  (myStory.contents == "December 18") {
    myStory. paragraphs[1].appliedparagraphstyle = myStyle1;
else  if (myStory.contents == "December 19") {
    myStory. paragraphs[1].appliedparagraphstyle = myStyle1;
if  (myStory.contents == "December 20") {
    myStory. paragraphs[1].appliedparagraphstyle = myStyle1;
else if (myStory.contents == "December 21") {
    myStory. paragraphs[1].appliedparagraphstyle = myStyle1;
if  (myStory.contents == "December 22") {
    myStory. paragraphs[1].appliedparagraphstyle = myStyle1;
else if (myStory.contents == "December 23") {
    myStory. paragraphs[1].appliedparagraphstyle = myStyle1;
if  (myStory.contents == "December 24") {
    myStory. paragraphs[1].appliedparagraphstyle = myStyle1;
else if (myStory.contents == "December 25") {
    myStory. paragraphs[1].appliedparagraphstyle = myStyle1;
// If text doesn't  equal Day of the week like Monday and doesn't equal month and date like Decmber 14
// then the document loops into doing the the rest of the document in Holiday-Header-Body
// not sure if this loop will stop once it reaches another day of the week and then repeat the above tasks again.
// not sure if I did this IF selection not equal mystyle and mystyle1 then perform loop, is done correctly???
if (myStory.contents !=  (myStyle && myStyle1)) {
   for (loop=0; loop<myStory.paragraphs.length; loop++)
  myStory.paragraphs[loop].appliedParagraphStyle = myStyle3;
    I'm truly grateful for the Support and Assistance everyone has been providing me, I'm learning, and I thank you all for your help.

Similar Messages

  • Error 1603: Need some help with this one

    When installing iTunes I first get an error box saying
    "Error 1406: Could not write value to key \Software\classes\.cdda\OpenWithList\iTunes.exe. Verify that you have sufficient access to that key, or contact your support personnel."
    The second one (after I click on Ignore on the last box) I get it this one:
    "Error: -1603 Fatal error during installation.
    Consult Windows Installer Help (Msi.chm) or MSDN for more information"
    Strange thing is that I do have full access to my computer (or atleast in all other cases I have had since I am the only one with an account on it).
    I have done my best in trying to solve it myself but I'm running out of ideas. I have downloaded latest versions from the website and tried installing Quicktime separately. I have also tried removing Quicktime using add/or remove programs though I just I didn't dare to take full removal because it said something about system files.
    Anyway I really need some help with this, anyone got any ideas?
    Greets,
    Sixten
      Windows XP Pro  

    Do you know how to count backwards? Do you know how to construct a loop? Do you know what an autodecrementor is? Do you know how to use String length? Do you know Java arrays start with index 0 and run to length-1? Do you know you use length on arrays too? Do you know what System.out.println does?
    Show us what you have, there isn't anything here that isn't easily done the same as it would be on paper.

  • Need some help for this code.

    Hi Everyone,
    I've test codes for east region and west region.
    I've a requirement to replace the west test id with east test id.
    That mapping has been done by the onshore team, I've got the mapping doc.
    But updating these details is a tricky part. It's nothing like direct update and replace those test codes.
    As per the mapping if it's
    In case of one to one (East - West) mapping which going to affect only a single row, I’ll have to update there,directly.
    In case of one – many (East - West) mapping and which is going to affect multiple rows, I’ll have to update the latest one and rest will be deleted only in that group. To identify the latest we have to check the latest order detail for that test.
    Suppose I've a west code named W123 and it has to be replaced with E123, in this case direct update.
    But now I've a transaction table where a patient has ordered multiple tests, In this case suppose the
    patiend id is P123 and ordered tests are W123, W234, W345; I'll have to update W123 as E123 and rest
    should not be deleted.
    But if I'll get multiple west code mapped towards single east code, the latest record as per the order detail needs
    to be updated and rest needs to be deleted if mapped with multiple west test codes, for single record and group record as well. Some thing like this.
    E123 - W123, W234 so I'll have to find out the latest and update there accordingly for single record and now
    patient has orderd multiple tests and the group record is like P123(patient) -----has orederd for W123, W234, W345.
    Now only the lastest test code suppose W234 has to be replaced with E123 and W123 has be deleted and W345
    should be there with E123.
    Now please see the code.
    CREATE OR REPLACE
    PROCEDURE P_UPDATE_TEST_ID AS
    V_EAST_TEST_ID            TEST_CODE_CONVERSION.EAST_TEST_ID%TYPE;
    V_ARRAY                   VARCHAR2(4000);
    V_COUNT                   NUMBER := 0;
    BEGIN
      FOR I IN (SELECT EAST_TEST_ID
                      ,STRAGG(WEST_TEST_ID) AS V_STRING
                FROM TEST_CODE_CONVERSION
                GROUP BY EAST_TEST_ID)
      LOOP
        V_EAST_TEST_ID            := I.EAST_TEST_ID;
        V_ARRAY                   := I.V_STRING;
        V_COUNT                   := V_COUNT+1;
        DBMS_OUTPUT.PUT_LINE('EAST_TEST_ID = ' ||V_EAST_TEST_ID|| ' || '||
                             'WEST_TEST_ID = ' ||v_array);
        Now after this I need to segregate the string values and check individual record
        and group record as well, for update. Now If I'll add the regexp_substr, then how
        to map those extracted values for checking.
      END LOOP;
      DBMS_OUTPUT.PUT_LINE('v_count = ' ||V_COUNT);
    END P_UPDATE_TEST_ID;Please suggest something.
    Regards,
    BS2012.
    Edited by: BS2012 on May 23, 2013 4:40 PM

    Hi Bawer,
    Thanks for your interest, but I've done that yesterday.
    Bawer wrote:
    Sorry, but
    >
    Here I'll have to check which one is the latest and update that with relative east test id ...
    >how do you describe the *'latest'* and *'relative east'* ?We have one more template table where we'll have to take the max of template_test_id to figure out "which one is the latest?" To identify the relative east we have a parent table named "test" from there we can find the relative test ids by the column name called East_west_ind (indicator); as per the mapping.
    and depending to this,
    >
    ... rest one has to be deleted and other should be untouched.
    >which one is here, in your sample to be deleted and which should be untouched?
    (maybe a sample after-update output?)If you see the patient id 93, we have number of tests has been ordered. But 3257, 3515 test ids are same as per the mapping. So we need to check the max of template_test_id to figure out "which one is the latest?" as we have one entry in template table always for a new order. In terms of that I'll have to update 3257 as it's the latest entry and 3515 has to be deleted and rest of the test ids should be untouched. I did it yesterday, but i couldn't respond you. Thanks once again for your interest.

  • I have a iphone 4  and when i call people then cant hear me  and the mute is off ..  need some help with this problem

    i have a iphone 4 and when i call people about 70 percent of the time then cant hear me and the mute is not on ,  need some help

    Please see the  More Like This  section on the right.

  • Need some help with this project (methods)

    Ok. in this project it states the following:
    Write an application that rolls a die and displays the reuslt. Let the user pick the number of sides on the die. Use the Die Class to represent the die in your program.
    This is what i have so far, but im confused on how to utilize the Die class because it keeps giving me errors:
    P4_3.java:
    Code:
    import cs1.Keyboard;
    import java.util.Random;
    // extends the Die class...
    public class P4_3 extends Die
    public static void main (String[] args)
    { // asks the user how many sides of the die there is.
    int userSides;
    System.out.println("How many sides of the die do you want?");
    userSides = Keyboard.readInt();
    System.out.println ("You rolled "+Die.die);
    }Die.java:
    Code:
    // the die class
    import cs1.Keyboard;
    import java.util.Random;
    public class Die extends P4_3
    public static void Die()
    // rolls the dice
    Random generator = new Random();
    int die;
    die = generator.nextInt(P4_3.userSides) +1;
    }It keeps giving me:
    cannot resolve symbol
    symbol : variable die
    location: class Die
    System.out.println ("You rolled "+Die.die);
    ^
    cannot resolve symbol
    symbol : variable userSides
    location: class P4_3
    die = generator.nextInt(P4_3.userSides) +1;Can somebody point me in the right direction?
    Thanks, ps2cho
    (PS: Please keep it as simple as possible, dont give me some crazy wacky tough code because i wont understand a word of it, no matter how hard you try to explain it. Simple simple simple!)
    Thanksss

    import java.io.*;
    import java.util.Random;
    public class DieTest
        public static void main(String[] args)
            boolean more = true;
            BufferedReader br = null;
            try
                br = new BufferedReader(
                     new InputStreamReader(System.in));
                while(more)
                    System.out.println("enter number for die sides, \"q\" to quit");
                    String line = br.readLine();
                    if(line.equalsIgnoreCase("q"))
                        break;
                    int sides = Integer.parseInt(line);
                    Die die = new Die(sides);
                    for(int j = 0; j < 5; j++)
                        System.out.println("die roll " + (j+1) + " = " + die.roll());
                br.close();
            catch(IOException ioe)
                System.err.println("read error " + ioe.getMessage());
                more = false;
    class Die
        int sides;
        Random seed;
        public Die(int n)
            this.sides = n;
            seed = new Random();
        public int roll()
            // 0 <= seed.nextInt(sides) <= sides-1
            // 1 <= return value <= sides
            return 1 + seed.nextInt(sides);
    }

  • Need some help with this Design.  Not sure if it can be done.

    I am a full time RVer. I have a complex system installed in my RV. I am trying to share a wireless or use my AE to feed internet to the devices in my rack and allow my Apple TV to connect to my MBP over gigabit for streaming reasons.
    Is there a way to share my internet to the AE so that it will feed the 3 ports? Can I somehow connect to a hotspot and share that internet connection to the other devices on my network wired and wireless?? I am mainly concerned with getting internet to the ATV while connected to it via ethernet for the gigabit connection.
    It seems that I can connect the AE to a hotspot or WAP, but then I loose the ability to turn bridged mode off so that it will hand out DHCP ip addresses to the ethernet devices. I cannot extend any network unless the hotspot is using an apple device for its WAP. This is what apple told me when I was trying to extend my Linksys WAP4400N.
    Any ideas or advice here would be great. I am just stuck for a solution to what I want to accomplish.
    Thanks

    One possible solution....(if I understand correctly what you're trying to accomplish with what you have to work with) I'm assuming that the Linksys has no internet connection in the RV and isn't really needed in my idea below.....or do you have a satellite connection (or some other internet source besides a public wireless network?
    You could have your MBP join the wireless network, set up internet sharing (see OS X help) and share from airport to ethernet, connect an ethernet cable from MBP to WAN port on the Extreme, set the Extreme's connection sharing to "share a public IP", ignore the double NAT error (or you may be able to bridge it, I can't remember if the MBP will hand out several IPs but I think it will), and plug your Apple TV into a LAN port on the Extreme. Come to think about it, you really don't even need the Extreme unless you need other clients to connect, just plug the Apple TV into the MBP.
    hope it helps

  • Need some help troubleshooting this code

    I have the following code in a JSP (HTML stuff edited out). If I run it as it is I get a blank page. But if I comment out the line that says "ruleName = rs.getInt("rule_name");" I am able to see the output of the prepared statement call. I need to see the results of both queries. Any ideas how I can fix this? Thanks.
    <%@ page language="java" import="java.sql.*" %>
    <%@ page import="oracle.jdbc.driver.*" %>
    <%@ page import="oracle.sql.*" %>
    <%@ page import="beans.*" %>
    <%
    Connection conn = null;
    CallableStatement cstmt= null;
    Statement stmt = null;
    int ruleName = 0;
    try {
    //Build the database connection string
    String SYSTEM_DB_DRIVER =
    "oracle.jdbc.driver.OracleDriver";
    String SYSTEM_DB_URL =
    "jdbc:oracle:thin:@<db connection string>";
    String SYSTEM_DB_FILE = "<db>";
    String SYSTEM_DB_USER = "<user>";
    String SYSTEM_DB_PASSWORD = "(passwd>";
    Class.forName(SYSTEM_DB_DRIVER);
    conn = DriverManager.getConnection(SYSTEM_DB_URL +
    SYSTEM_DB_FILE, SYSTEM_DB_USER, SYSTEM_DB_PASSWORD);
    System.out.println("creating stmt for rule name");                    
    stmt = conn.createStatement();
    ResultSet rs = stmt.executeQuery("SELECT DISTINCT MAX(TO_NUMBER(rule_name)) FROM rules WHERE product_id = CHR(" + prodId + ")");                    
    ruleName = rs.getInt("rule_name");
    System.out.println(ruleName);
    // Prepare a PL/SQL call.
    OracleCallableStatement call =
    (OracleCallableStatement)conn.prepareCall("{ call wacc_eaicl_p_requirement.open_rules_dtl (:1,:2) }");
    // Return the rules.
    call.registerOutParameter(1, OracleTypes.CURSOR);
    call.setInt(2, Integer.parseInt(prodId) );
    call.execute();
    ResultSet rset = ((OracleCallableStatement)call).getCursor(1);
    System.out.println(prodId);
    rs.close();
    stmt.close();
    conn.close();                                    
    rset.close();
    call.close();
    conn.close();
    catch(Exception e)
    %>

    Never mind. I fixed it. Silly me. Lesson learned: Use exceptions!

  • Need Some Help with my code

    Hey guys;
    Here is my problem:
    I have a detailed query, but for argurments sake and to keep it simple let's just say it is this:
    select a.acct_number, s.service_id, s.service
    from account a, service s
    where s.acct_number = s.acct_number
    and s.service = 'ELECTRIC';
    So this part of my problem i have working ok.
    BUT, what i now need is to take these results above and search through only the returned data.
    So i need all the accounts above that are active between say an effective_date of Jan 1, 2007 and April 30, 2007
    What is the best way to do this:
    Should i do it right in my SQL code, or would it be better to setup a cursor and do it through PL/SQL Developer?

    So this part of my problem i have working ok. I doubt it, you have a Cartesian product here (your 2 tables are not joined, I'm assuming that it's a typo
    So i need all the accounts above that are active between say an effective_date of Jan 1, 2007 and April 30, 2007Unfortunately you have over simplified your issue. It is impossible to answer without making guesses. Do you even have columns which indicate whether a record is active or not, or a date column for your rows?
    Should i do it right in my SQL code, or would it be better to setup a cursor and do it through PL/SQL Developer?
    If possible, use SQL.

  • Need some help with this new setup I have

    This is what I got for my new setup
    A64 3000 939
    K8N Neo4 Platinum MSI
    1 gig of Mushkin duel chan. ddr 400
    Gigabyte GeForce 6600 GT PCI-E
    The ram I have is duel chan. I have no idea what this means  Or what the ram needs to be set to is it faster than non duel ddr? 

    Quote from: igmox
    it is like water flowing through two parallel pipes instead of one.
    Quote from: mrbell84
    Another example you could think of duel channel memory could be like a 2 lane motorway.  You close one lane and cars can only go down 1 lane, but when you open another lane up thats another path for the cars to travel
    Quote from: omnikron
    One more thing is my psu going to be ok with that setup
    Quote from: mrbell84
    Yes your Power supply has 24 pin atx connector and also its a ATx2.0, which means its SLI/PCI-E Complient

  • Really need some help with this low earpiece volume issue.

    I'm taking my iPhone to an Apple Store Genius tomorrow to check out the low volume in the earpiece. Has anyone else taken their phone in to an Apple Store and had the issue addressed? Are Geniuses just saying it is within spec? Has Apple published an article on this?
    I realize that people are also frustrated over the low speakerphone volume, but the low volume in the earpiece is particularly concerning.
    While traveling down the road it is very difficult to hear the person on the other end of the phone when using just the earpiece (no earbuds, no BT headset). The volume while using the earbuds is plenty loud.
    Can anyone please shed some new light on this? I have had my iPhone for one week and I've got a bad feeling in my gut that this is a hardware issue and the earpiece speaker can't go any louder. Bummer.
    (Obviously, all of my volume settings are maxed out).
    -Joe

    When the iPhones were first released, some people reported on their posts that they were able to take them to the Genius Bar, have a tech test it out, the tech would agree that the volume sounded low, and get their phone swapped right away. Unfortunately, there is no cut and dry answer because people have reported all sorts of different things- that the various software updates have fixed their volume, messing with the volume setting within iTunes, etc.
    Personally, I think it is a software glitch. Why? I did this: I was playing the iPod without the earbuds and the volume was only set midrange. I covered the speaker on the bottom, cranked up the volume, and the sound coming out of the receiver was MUCH louder than it ever is when I am using the iPhone on a call. That to me indicates that the low volume it just a glitch that can be fixed, because it CAN obviously sound louder, just within a different function. Hope that makes sense.
    Good luck tomorrow.

  • Need some help with threads...

    Hello all,
    I am working on a project at work, and I am not the best programmer in the world. I have been trying to get my head around this for a couple of days and just cannot get it to work.
    I am writing an instrumentation control program that will have three threads. One is the GUI, one will receive control information and set up the hardware, and one will check the hardware status and report it to the GUI periodically. I plan on using the invokeLater() method to communicate the status to the GUI and change the status display in the GUI. Communication from the GUI to the controller thread and from the status thread to the controller thread I had planned on being piped input/output stream as appropriate. I have a control class and a status class that need to be communicated over these piped streams. In some trial code I have been unable to wrap the piped input/output streams with object input/output streams. I really need some help with this. Here is the main thread code:
    package playingwiththreads1;
    import java.io.*;*
    *public class PlayingWithThreads1 {*
    public static void main(String[] args) {*
    * PipedOutputStream outputPipe = new PipedOutputStream();*
    * ObjectOutputStream oos = null;*
    * ReceiverThread rt = new ReceiverThread(outputPipe);*
    // Start the thread -- First try*
    * Thread t = new Thread(rt);*
    t.start();*
    // Wrap the output pipe with an ObjectOutputStream*
    try*
    oos = new ObjectOutputStream(outputPipe);*
    catch (IOException e)*
    System.out.println(e);*
    // Start the thread -- Second try*
    //Thread t = new Thread(rt);*
    //t.start();*
    /** Send an object over the pipe. In reality this object will be a
    class that contains control or status information */
    try
    if (!oos.equals(null))
    oos.writeObject(new String ("Test"));
    catch (IOException e)
    try
    Thread.sleep(5000);
    catch (InterruptedException e)
    I read somewhere that it matters where you start the thread relative to where you wrap piped streams with the object streams. So, I tried the two places I felt were obvious to start the thread. These are noted in the comments. Here is the code for the thread.
    package playingwiththreads1;
    import java.io.*;
    public class ReceiverThread implements Runnable {
    private PipedInputStream inputPipe = new PipedInputStream();
    private ObjectInputStream inputObject;
    ReceiverThread (PipedOutputStream outputPipe)
    System.out.println("Thread initialization - start");
    try
    inputPipe.connect(outputPipe);
    inputObject = new ObjectInputStream(inputPipe);
    catch (IOException e)
    System.out.println(e);
    System.out.println("Thread initialization - complete");
    public void run()
    System.out.println("Thread started");
    try
    if (inputObject.available() > 0)
    System.out.println(inputObject.read());
    catch (IOException e)
    System.out.println(e);
    Through testing I have determined that no matter where I start the thread, the thread never gets past the "inputObject = new ObjectInputStream(inputPipe);" assignment.
    Could someone please help me with this? There are other ways for me to write this program, but this is the one that I would like to make work.
    Many thanks in advance,
    Rob Hix
    Edited by: RobertHix on Oct 6, 2009 3:54 AM

    Thanks for the help, but that did not work. I tried flushing the ObjectOutputStream and it is still hanging when initializing the thread.
    Here is a better look at the code since I was helped to figure out how to insert it:
    The main method:
    package playingwiththreads1;
    import java.io.*;
    public class PlayingWithThreads1 {
        public static void main(String[] args) {
            PipedOutputStream outputPipe = new PipedOutputStream();
            ObjectOutputStream oos = null;
            ReceiverThread rt = new ReceiverThread(outputPipe);
            // Start the thread -- First try
            //Thread t = new Thread(rt);
            //t.start();
            // Wrap the output pipe with an ObjectOutputStream
            try
                oos = new ObjectOutputStream(outputPipe);
                oos.flush();
            catch (IOException e)
                System.out.println(e);
            // Start the thread -- Second try
            Thread t = new Thread(rt);
            t.start();
            /* Send an object over the pipe.  In reality this object will be a
             * class that contains control or status information */
            try
                if (!oos.equals(null))
                    oos.writeObject(new String ("Test"));
                    oos.flush();
            catch (IOException e)
                System.out.pringln(e);
            try
                Thread.sleep(5000);
            catch (InterruptedException e)
    }The thread code:
    package playingwiththreads1;
    import java.io.*;
    public class ReceiverThread implements Runnable {
        private PipedInputStream inputPipe = new PipedInputStream();
        private ObjectInputStream inputObject;
        ReceiverThread (PipedOutputStream outputPipe)
            System.out.println("Thread initialization - start");
            try
                inputPipe.connect(outputPipe);
                inputObject = new ObjectInputStream(inputPipe);
            catch (IOException e)
                System.out.println(e);
            System.out.println("Thread initialization - complete");
        public void run()
            System.out.println("Thread started");
            try
                if (inputObject.available() > 0)
                    System.out.println(inputObject.read());
            catch (IOException e)
                System.out.println(e);
    }Does anyone else have and ideas?

  • Need some help with ".png" image.

    Good day everyone. Here's the run down. I need to add an
    image (image "A") ontop of another image (image"B"). Image "B" is a
    paterned background. And Image "A" a logo with a transparent
    background.
    As it stands I have image "A" as a "png" and as you know....
    they are fri**ing huge! Haveing it as a "gif" only presents me with
    the IE6 problem of it adding a colored background to the image.
    So I'm stuck! Can any one tell me or point me in the
    difection of a tutorial to tell me the best way to add an image
    with a transparent background in Dreamweaver.
    Really need some help with this!
    Thanks all!

    >Right you can see the work in progress here>
    http://www.stclairecreative.com/DoughBoys_Site_Folder/home.html
    Before going much further I'd recommend reconsidering the use
    of a textured background. They are usually included for the benefit
    of the site owner only, and likely to annoy visitors. Studies on
    the subject suggest they often lead to usability problems. I do
    like to header graphic, but at 200K it's kinda heavy and can
    probably be optimized.

  • I need help with this code error "unreachable statement"

    the error_
    F:\Java\Projects\Tools.java:51: unreachable statement <-----------------------------------------------------------------------------------------------------------------THIS
    int index;
    ^
    F:\Java\Projects\Tools.java:71: missing return statement
    }//end delete method
    ^
    F:\Java\Projects\Tools.java:86: missing return statement
    }//end getrecod
    ^
    3 errors
    import java.util.*;
    import javax.swing.*;
    import java.awt.*;
    public class Tools//tool class
    private int numberOfToolItems;
    private ToolItems[] toolArray = new ToolItems[10];
    public Tools()//array of tool
    numberOfToolItems = 0;
    for(int i = 0; i < toolArray.length; i++)//for loop to create the array tools
    toolArray[i] = new ToolItems();
    }//end for loop
    }//end of array of tools
    public int search(int id)//search mehtod
    int index = 0;
    while (index < numberOfToolItems)//while and if loop search
    if(toolArray[index].getID() == id)
    return index;
    else
    index ++;
    }//en while and if loop
    return -1;
    }//end search method
    public int insert(int id, int numberInStock, int quality, double basePrice, String nm)//insert method
    if(numberOfToolItems >= toolArray.length)
    return 0;
    int index;
    index = search(id); <-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------HERE
    if (index == -1)
    toolArray[index].assign(id,numberInStock, quality, basePrice,nm);
    numberInStock ++;
    return 1;
    }//end if index
    }//end if toolitem array
    return -1;
    }//end insert method
    public int delete(/*int id*/)//delete method
    }//end delete method
    public void display()//display method
    for(int i = 0; i < numberOfToolItems; i++)
    //toolArray.display(g,y,x);
    }//end display method
    public String getRecord(int i)//get record method
    // return toolArray[i].getName()+ "ID: "+toolArray[i].getID()
    }//end getrecod
    }//end class
    Edited by: ladsoftware on Oct 9, 2009 6:08 AM
    Edited by: ladsoftware on Oct 9, 2009 6:09 AM
    Edited by: ladsoftware on Oct 9, 2009 6:10 AM
    Edited by: ladsoftware on Oct 9, 2009 6:11 AM

    ladsoftware wrote:
    Subject: Re: I need help with this code error "unreachable statement"
    F:\Java\Projects\Tools.java:51: unreachable statement <-----------------------------------------------------------------------------------------------------------------THIS
    int index;
    ^
    F:\Java\Projects\Tools.java:71: missing return statement
    }//end delete method
    ^
    F:\Java\Projects\Tools.java:86: missing return statement
    }//end getrecod
    ^
    3 errorsThe compiler is telling you exactly what the problems are:
    public int insert(int id, int numberInStock, int quality, double basePrice, String nm)//insert method
    if(numberOfToolItems >= toolArray.length)
    return 0; // <<== HERE you return, so everyting in the if block after this is unreachable
    int index;
    index = search(id);  //< -----------------------------------------------------------------------------------------------------------------HERE
    if (index == -1)
    toolArray[index].assign(id,numberInStock, quality, basePrice,nm);
    numberInStock ++;
    return 1;
    }//end if index
    }//end if toolitem array
    return -1;
    }//end insert method
    public int delete(/*int id*/)//delete method
    // <<== HERE where is the return statement?
    }//end delete method
    public String getRecord(int i)//get record method
    // return toolArray.getName()+ "ID: "+toolArray[i].getID() <<== HERE you commented out the return statement
    }//end getrecod
    }//end class

  • Please I need some help with a table

    Hi All
    I need some help with a table.
    My table needs to hold prices that the user can update.
    Also has a total of the column.
    my question is if the user adds in a new price how can i pick up the value they have just entered and then add it to the total which will be the last row in the table?
    I have a loop that gets all the values of the column, so I can get the total but it is when the user adds in a new value that I need some help with.
    I have tried using but as I need to set the toal with something like total
        totalTable.setValueAt(total, totalTable.getRowCount()-1,1); I end up with an infinite loop.
    Can any one please advise on some way I can get this to work ?
    Thanks for reading
    Craig

    Hi there camickr
    thanks for the help the other day
    this is my full code....
    package printing;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.print.*;
    import javax.swing.*;
    import javax.swing.table.*;
    import java.text.DecimalFormat;
    public class tablePanel
        extends JDialog  implements Printable {
      BorderLayout borderLayout1 = new BorderLayout();
      private boolean printing = false;
      private Dialog1 dialog;
      JPanel jPanel = new JPanel();
      JTable table;
      JScrollPane scrollPane1 = new JScrollPane();
      DefaultTableModel model;
      private String[] columnNames = {
      private Object[][] data;
      private String selectTotal;
      private double total;
      public tablePanel(Dialog1 dp) {
        dp = dialog;
        try {
          jbInit();
        catch (Exception exception) {
          exception.printStackTrace();
      public tablePanel() {
        try {
          jbInit();
        catch (Exception exception) {
          exception.printStackTrace();
      private void jbInit() throws Exception {
        jPanel.setLayout(borderLayout1);
        scrollPane1.setBounds(new Rectangle(260, 168, 0, 0));
        this.add(jPanel);
        jPanel.add(scrollPane1, java.awt.BorderLayout.CENTER);
        scrollPane1.getViewport().add(table);
        jPanel.setOpaque(true);
        newTable();
        addToModel();
        addRows();
        setTotal();
    public static void main(String[] args) {
      tablePanel tablePanel = new  tablePanel();
      tablePanel.pack();
      tablePanel.setVisible(true);
    public void setTotal() {
      total = 0;
      int i = table.getRowCount();
      for (i = 0; i < table.getRowCount(); i++) {
        String name = (String) table.getValueAt(i, 1);
        if (!"".equals(name)) {
          if (i != table.getRowCount() - 1) {
            double dt = Double.parseDouble(name);
            total = total + dt;
      String str = Double.toString(total);
      table.setValueAt(str, table.getRowCount() - 1, 1);
      super.repaint();
      public void newTable() {
        model = new DefaultTableModel(data, columnNames) {
        table = new JTable() {
          public Component prepareRenderer(TableCellRenderer renderer,
                                           int row, int col) {
            Component c = super.prepareRenderer(renderer, row, col);
            if (printing) {
              c.setBackground(getBackground());
            else {
              if (row % 2 == 1 && !isCellSelected(row, col)) {
                c.setBackground(getBackground());
              else {
                c.setBackground(new Color(227, 239, 250));
              if (isCellSelected(row, col)) {
                c.setBackground(new Color(190, 220, 250));
            return c;
        table.addMouseListener(new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
            if (e.getClickCount() == 1) {
              if (table.getSelectedColumn() == 1) {
       table.setTableHeader(null);
        table.setModel(model);
        scrollPane1.getViewport().add(table);
        table.getColumnModel().getColumn(1).setCellRenderer(new TableRenderDollar());
      public void addToModel() {
        Object[] data = {
            "Price", "5800"};
        model.addRow(data);
      public void addRows() {
        int rows = 20;
        for (int i = 0; i < rows; i++) {
          Object[] data = {
          model.addRow(data);
      public void printOut() {
        PrinterJob pj = PrinterJob.getPrinterJob();
        pj.setPrintable(tablePanel.this);
        pj.printDialog();
        try {
          pj.print();
        catch (Exception PrintException) {}
      public int print(Graphics g, PageFormat pageFormat, int pageIndex) throws PrinterException {
        Graphics2D g2 = (Graphics2D) g;
        g2.setColor(Color.black);
        int fontHeight = g2.getFontMetrics().getHeight();
        int fontDesent = g2.getFontMetrics().getDescent();
        //leave room for page number
        double pageHeight = pageFormat.getImageableHeight() - fontHeight;
        double pageWidth =  pageFormat.getImageableWidth();
        double tableWidth = (double) table.getColumnModel().getTotalColumnWidth();
        double scale = 1;
        if (tableWidth >= pageWidth) {
          scale = pageWidth / tableWidth;
        double headerHeightOnPage = 16.0;
        //double headerHeightOnPage = table.getTableHeader().getHeight() * scale;
        //System.out.println("this is the hedder heigth   " + headerHeightOnPage);
        double tableWidthOnPage = tableWidth * scale;
        double oneRowHeight = (table.getRowHeight() +  table.getRowMargin()) * scale;
        int numRowsOnAPage = (int) ( (pageHeight - headerHeightOnPage) / oneRowHeight);
        double pageHeightForTable = oneRowHeight *numRowsOnAPage;
        int totalNumPages = (int) Math.ceil( ( (double) table.getRowCount()) / numRowsOnAPage);
        if (pageIndex >= totalNumPages) {
          return NO_SUCH_PAGE;
        g2.translate(pageFormat.getImageableX(), pageFormat.getImageableY());
    //bottom center
        g2.drawString("Page: " + (pageIndex + 1 + " of " + totalNumPages),  (int) pageWidth / 2 - 35, (int) (pageHeight + fontHeight - fontDesent));
        g2.translate(0f, headerHeightOnPage);
        g2.translate(0f, -pageIndex * pageHeightForTable);
        //If this piece of the table is smaller
        //than the size available,
        //clip to the appropriate bounds.
        if (pageIndex + 1 == totalNumPages) {
          int lastRowPrinted =
              numRowsOnAPage * pageIndex;
          int numRowsLeft =
              table.getRowCount()
              - lastRowPrinted;
          g2.setClip(0,
                     (int) (pageHeightForTable * pageIndex),
                     (int) Math.ceil(tableWidthOnPage),
                     (int) Math.ceil(oneRowHeight *
                                     numRowsLeft));
        //else clip to the entire area available.
        else {
          g2.setClip(0,
                     (int) (pageHeightForTable * pageIndex),
                     (int) Math.ceil(tableWidthOnPage),
                     (int) Math.ceil(pageHeightForTable));
        g2.scale(scale, scale);
        printing = true;
        try {
        table.paint(g2);
        finally {
          printing = false;
        //tableView.paint(g2);
        g2.scale(1 / scale, 1 / scale);
        g2.translate(0f, pageIndex * pageHeightForTable);
        g2.translate(0f, -headerHeightOnPage);
        g2.setClip(0, 0,
                   (int) Math.ceil(tableWidthOnPage),
                   (int) Math.ceil(headerHeightOnPage));
        g2.scale(scale, scale);
        //table.getTableHeader().paint(g2);
        //paint header at top
        return Printable.PAGE_EXISTS;
    class TableRenderDollar extends DefaultTableCellRenderer{
        public Component getTableCellRendererComponent(
          JTable table,
          Object value,
          boolean isSelected,
          boolean isFocused,
          int row, int column) {
            setHorizontalAlignment(SwingConstants.RIGHT);
          Component component = super.getTableCellRendererComponent(
            table,
            value,
            isSelected,
            isFocused,
            row,
            column);
            if( value == null || value .equals("")){
              ( (JLabel) component).setText("");
            }else{
              double number = 0.0;
              number = new Double(value.toString()).doubleValue();
              DecimalFormat df = new DecimalFormat(",##0.00");
              ( (JLabel) component).setText(df.format(number));
          return component;
    }

  • I Need Some Help With My Dreamweaver

    Hello, there i need some help with my dreamweaver i already made a forum about this but that one i maded didnt make sense soo i will make it more details in it soo i will tell you what i did i tell you what i downloed and all that just now but i tell you the things what it does i downloaded Adobe Design and Web Premium CS6 its a 30 day trial then and now i will tell you the details look below please
    Details
    Soo i opened my start menu then went on all programs then clicked on Adobe Design and Web Premium CS6 then i clicked on the dreamweaver CS6 then when i clicked on it i heard my computer shut down then it shuted down when i opened it straight away then it turns it self back on
    What did i do about this when it happened?
    I made a question so please can telll me what to do or what ever
    Why did i download it?
    i downloaded it because i am making a website and i want to use dreamweaver CS6 because i use notepad++ i do not like the notepad++ its harder and dreamweaver helps a bit i think because i watched a video of it
    What if you dont have an answer?
    Well, i will be very angry because i am making a good website its gonna be my frist publish website ever i made 20 websites but i never published them i deleted them because i wiped my computer
    What kind of Computer Do You have?
    System:
    Micfosoft windows xp
    Media Center Edition
    Version 2002
    Service Pack 2
    Computer
    ei-system
            intel(R)
    pentium(R) 4 CPU 3.20ghz
    3.20 ghz, 960 MB of RAM
    Btw i am using dreamweaver CS6 if you fogot and dont say add more details because there is alot off details there and if you help me i will show u the whloe code when i am done but leave ur emaill address below
    (C) Connor McIntosh

    No.
    Service Pack 3 just updates your OS. All of your files, folders and programs will still be there.
    You will start running into more problems like this the longer you stick with XP though. That particular OS is over 11 years old, service pack 3 hs been out for over 4 years.
    It may be time for a system upgrade. I personally went from XP to Windows 7 and I haven't looked back one bit.

Maybe you are looking for

  • How can I set the font size of a form field in the fdf file?

    I need to dynamically set the font size of a field to accommodate text of varying length, automatic font size won't work in this case. It seems like this can be done in the FDF but I have tried several variants without success. Could someone help out

  • Creation of Secondary Infotypes

    Hello gurus, I have to create secondary infotypes for IT0021 for the country Sweden. I am trying the transaction code PM01....but I don't get to see the IT View option in the menu so as to initiate secondary infotype creation. Request your urgent hel

  • Photo Places not showing up in the Photos App???

    i have a 3gs and i updated it yesterday. i saw that my friend had albums and places on the bottom of the photo app, however i didnt. can someone tell my why this is?

  • SAP Table for Custom variable and values?

    Hi folks. I am looking for a SAP standard table which I recall existing. This table was designed by SAP to store a variable name and value(s), so that no programmer would ever hard-code values into their reports. Instead, the programmer would create

  • New episodes not showing up in iTunes

    I have added a new episode (item) to my feed and pinged iTunes and the new episode will not show up. The feed was validated and is in the proper format. When people subscribe, the episode is available and workign fine. Any way idea on how to get the