Why aint this working???

have pasted object thru a constructor like this:
        Write screen   = new Write(ring);
//and rezive it here in the constructor
     public Write(Object ring)
          buffer = ring;
// and use it like this:
          System.out.println(buffer.remove()); // This line gets an errorSo why is this error comming?
cannot resolve symbol method remove()

public class RingBuffer
    public static void main(String[] args)
         Ringen ring = new Ringen();
         Write screen   = new Write(ring);  // Henter tekst fra ringbuffer og skriver den ut p? skjermen.
         Generate genr  = new Generate();   // Lager tekst "automatisk" og legger den inn i ringbufferen.
         Input_txt intxt= new Input_txt(ring);  // Lar brukeren taste inn noen ord som lagres i ringbufferen.
         screen.start(); //
         genr.start();   //  Starter tr?dene.
         intxt.start();  //
public class Write extends Thread
     private Object buffer;
     public Write(Object ring)
          buffer = ring;
     synchronized public void run()
          //Ringen buffer = new Ringen();
          while(true){
               try{
                    System.out.println(buffer.remove()); // Pr?ver ? skrive ut hvert sekund
                    Thread.sleep(1000);
               }//end try
               catch(InterruptedException e){
                    System.out.println(e);
          }//end while
import java.io.*;
public class Input_txt extends Thread
     Object buffer;
     public Input_txt(Object ring)
          buffer = ring;
     synchronized public void run()
          try{
                    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
                    System.out.println("Skriv inn noe tull");
                    String inTxT = in.readLine();
                    buffer.insert(inTxT);
          catch(Exception e) { System.out.println(e);}
public class Ringen implements Buffer
     private static final int BUFFER_SIZE = 10;
     int in, out;  // peker p? f?rste ledige og siste okuperte.
     int count;    // Teller hvor mange objekter som er i bufferen.
     private Object[] buffer;
     public Ringen()
          count = 0;
          in = 0;
          out = 0;
          buffer = new Object[BUFFER_SIZE];
     public void insert(Object item)
          while (count == BUFFER_SIZE)
               ;// do nothing..
          // Legger til et object i bufferen
          ++count;
          buffer[in] = item;
          in = (in + 1)% BUFFER_SIZE;
     public Object remove()
          Object item;
          while (count == 0){
               try{
                    System.out.println(buffer[0]);
                    Thread.sleep(4000);
               }//end try
               catch(InterruptedException e){
                    System.out.println(e);
          }//end while
          --count;
          item = buffer[out];
          out = (out + 1) % BUFFER_SIZE;
          return item;
public interface Buffer
     // producers call this method
     public abstract void insert(Object item);
     // consumers call this method
     public abstract Object remove();
}

Similar Messages

  • Why aint this working!!!couldnt find answer in forums

    Hi,
    I come accross a problem with comparing 2 strings. Well i got a program that reads a file and displays its contents on the screen. Well, as the contents of the file changes i wont the program to add new text but not txt that had been already inputted.
    My solution was to read the file and then compare it to the text already inputted. Below is what i have written but it doesnt work, its either displays the text or not.
    FileInputStream file = new
    FileInputStream ("send.txt");
    BufferedReader reader = new BufferedReader(new InputStreamReader(file));
    String text = new String ("" + reader.readLine());
    if (text == oldtext) {
    System.out.println(text);
    oldtext = text;
    file.close();
    My Regards,

    And reader.readLine returns a string as it is - you're creating THREE Here:
    reader.readLine returns 1 string.
    ""+<reader.readLine result> creates another.
    new String() creates a third.

  • Why isnt this working urgent please help

    why isnt this working im trying to connect a panel to a scrollpane the panel will contain several dozen text fields
    the scrollpane shouls be about 350, 450 , but the pane is 350
    by 1200 the problem now is that the scorllbar isnt created and even when I explictly create it it contains no knob, and it will
    not scroll up or down please someone help this is urgent
    import java.awt.*;
    import com.sun.java.swing.*;
    public class ScrollDemo extends JPanel {
         private Rule columnView;
         private Rule rowView;
         private ScrollablePicture picture;
         class UnitsListener implements ItemListener {
              public void itemStateChanged(ItemEvent e) {
                   if (e.getStateChange() == ItemEvent.SELECTED) {
                        // Turn it to metric.
                        rowView.setIsMetric(true);
                        columnView.setIsMetric(true);
                   } else {
                        // Turn it to inches.
                        rowView.setIsMetric(false);
                        columnView.setIsMetric(false);
                   picture.setMaxUnitIncrement(rowView.getIncrement());
    public ScrollDemo() {
         Two t = new Two(columnView.getIncrement());
              JScrollPane pictureScrollPane = new JScrollPane(t);
              pictureScrollPane.setPreferredSize(new Dimension(300, 250));
              pictureScrollPane.setColumnHeaderView(columnView);
              pictureScrollPane.setRowHeaderView(rowView);
         public static void main(String s[]) {
              JFrame frame = new JFrame("ScrollDemo");
              frame.setContentPane(new ScrollDemo());
              frame.setVisible(true);
    import java.awt.*;
    import com.sun.java.swing.*;
    public class Two extends JPanel implements Scrollable{
    private JPanel ivjJPanel3 = null;
         private JScrollPane ivjJScrollPane1 = null;
         private int maxUnitIncrement = 1;
    public Two(int m)
         getJPanel1();
         maxUnitIncrement = m;
         setSize(300,1200);
    private void getJPanel1() {
                   setLayout(null);
                   setSize(250,1200);
                   add(getJLabel1(), getJLabel1().getName());
    public Dimension getPreferredScrollableViewportSize() {
              return getPreferredSize();
         public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation,
         int direction) {
              if (orientation == SwingConstants.HORIZONTAL)
                   return visibleRect.width - maxUnitIncrement;
              else
                   return visibleRect.height - maxUnitIncrement;
         public boolean getScrollableTracksViewportHeight() {
              return false;
         public boolean getScrollableTracksViewportWidth() {
              return false;
         public int getScrollableUnitIncrement(Rectangle visibleRect,
                                                      int orientation,
                                                      int direction) {
              //Get the current position.
              int currentPosition = 0;
              if (orientation == SwingConstants.HORIZONTAL)
                   currentPosition = visibleRect.x;
              else
                   currentPosition = visibleRect.y;
              //Return the number of pixels between currentPosition
              //and the nearest tick mark in the indicated direction.
              if (direction < 0) {
                   int newPosition = currentPosition -
                                       (currentPosition / maxUnitIncrement) *
                                       maxUnitIncrement;
                   return (newPosition == 0) ? maxUnitIncrement : newPosition;
              } else {
                   return ((currentPosition / maxUnitIncrement) + 1) *
                        maxUnitIncrement - currentPosition;
         public void setMaxUnitIncrement(int pixels) {
              maxUnitIncrement = pixels;

    I personally didn't play with swing components when they were in the com.sun.java.swing state, but I have a strong feeling it is very buggy and could be causing your problem.
    Before posting gui issues, please use a newer API, even jdk1.1 would be fine, anything would be better than what your using.
    you wrote: I dont care if its javax.swing or
    com.sun.java.swing
    I would also gather from this statement that your attitude could be one of your other issues.

  • Why does this work?

    I've been practicing some IPSec VPN scenarios, starting with the typical site-to-site VPN:
    Router A
    crypto map mymap 10 ipsec-isakmp
    set peer 1.1.1.2
    set transform-set myset
    match address 101
    access-list 101 permit ip 10.1.1.0 0.0.0.255 10.1.2.0 0.0.0.255
    Router B
    crypto map mymap 10 ipsec-isakmp
    set peer 1.1.1.1
    set transform-set myset
    match address 101
    access-list 101 permit ip 10.1.2.0 0.0.0.255 10.1.1.0 0.0.0.255
    This works as expected. Traffic from 10.1.1.x on Router A gets picked up by the crypto map and sent to RouterB and vice versa. What is confusing me is a more advanced scenario where I'm tunnelling GRE over IPSec with OSPF (why? Because I can).
    http://www.cisco.com/en/US/tech/tk583/tk372/technologies_configuration_example09186a008009438e.shtml
    Everything works just fine, but I'm bothered by the ACLs being used in the example. I don't see how everthing should be working- OSPF is fat and happy, and if I ping one spoke from another spoke from a loopback interface, it works as well. In this case, is the network traffic being picked up by the Tunnel interface first, and all the crypto map sees is GRE traffic by the time the packets make it that far?

    Ian
    You ask a question about the access lists and I believe that it will be easier to answer the question if we have the access lists to refer to. So here they are:
    7206:access-list 130 permit gre host 14.36.88.6 host 14.38.88.40access-list 140 permit gre host 14.36.88.6 host 14.38.88.20access-list 150 permit gre host 14.36.88.6 host 14.38.88.102610:access-list 120 permit gre host 14.38.88.10 host 14.36.88.63620:access-list 110 permit gre host 14.38.88.20 host 14.36.88.6
    3640:
    access-list 100 permit gre host 14.38.88.40 host 14.36.88.6
    one of the first things to understand here (and you briefly mention it in your post) is that they are running OSPF dynamic routing protocol over the tunnels. So each router sees the path to get to the other router as being through the tunnel. So when the 2610 wants to get to the 7206 it will send that traffic to the tunnel interface. The tunnel interface will encapsulate the original packet in a GRE header. So yes the only thing that the access list will see is GRE traffic.
    Anything that goes through the tunnel (whether it be a data packet or an OSPF routing update) is encapsulated in a GRE header and the access list does not see the original data but sees only GRE.
    HTH
    Rick

  • Questions, Extreme begginer - Why wont this work.

    /* My Java Program
    Failing To Compile 2009 - CurrentDate()
    /* Importing */
    import java.util.Scanner;
    import acm.graphics.*;
    import acm.program.*;
    class run {
         public static void main(String args[]){
         //Variables
         Scanner ninjatext = new Scanner(System.in);
         Scanner Clarinet_Request = new Scanner(System.in);
         System.out.println(ninjatext.nextLine());
         double pye, var1, ans;
         String yodawg;
         var1 = 2;
         pye = 3.14;
         yodawg ="I heard you like saxaphones  ";
         ans = var1/pye;
              System.out.println("Hello Cruel World?");
              System.out.print(yodawg);
              System.out.print("So i bought you ");
              System.out.print(ans);
              System.out.println(" Saxxes");
              System.out.println("So How many Clarinets Would you like????");
              System.out.println("Enter Number::");
              System.out.println("So " + Clarinet_Request.nextLine() + " Is how many clarinets You would like? Cool");
         /*Please end up working*/
         // Declaring Variables Semi-Randomly Works, Right?
         String test1 = "Ok i hope this works";
         int test2 = 10;
         double test3 = 4.9;
         int test4 = test2/test3; //Random Weird Awnser right???
         System.out.println(test2 + "Divided by" + test3 + "Is Equal To" + test4);
         /* This all should work, at least in theory.... But it wont right? */
         /** What have i gotten myself into? Oh well it sounds like it should work */
         Console console = System.console();
         String username = console.readLine("Lets Do This?: ");
         if (/* String? */username == "yes" || "Yes" || "YES"){
              testingthiscrap LeroyJenkins = new testingthiscrap
              LeroyJenkins.LetsDoThis()
         /* Guaranteed to not work */
    public class testingthiscrap extends GraphicsProgram {
         /** Runs the program */
         public void LetsDoThis() {
              GRect rect = new GRect(100, 50, 100, 100 / PHI);
              rect.setFilled(true);
              rect.setColor(Color.RED);
              add(rect);
              GOval oval = new GOval(150, 50 + 50 / PHI, 100, 100 / PHI);
              oval.setFilled(true);
              oval.setColor(Color.GREEN);
              add(oval);
    /** Constant representing the golden ratio */
         public static final double PHI = 1.618;
    /* Standard Java entry point */
    /* This method can be eliminated in most Java environments */
         public static void main(String[] args) {
              new FeltBoard().start(args);
         }//If anything i just typed i now feel heroic.
         // public static void
         Ok, sorry if the titles not good enough but i am a php programmer between begginer and intermediate but who wants to know java so i can say write a applet or something that can run from the desktop directly, also i wanted to lean OO and it in php confuses me infinately so i decided in the context of knowing nothing i might pick it up better thus java.
    So most of what im doing is confusing to me so i just tried to type some code (Well the first 20 maybe lines i compiled and tested but after that i couldnt test so i just ran with it. Today i tried to compile and poof, nothing.
    Any clues what im doing wrong and what i should do instead?
    BTW this stuff feels weird, i feel like to take imput it should have a html form or something. I dunno.
    also i dont even seem to have these acm packages im trying to import, any clue why?

    jman888 wrote:
    Ok, sorry if the titles not good enough but i am a php programmer between begginer and intermediate but who wants to know java so i can say write a applet or something that can run from the desktop directly, also i wanted to lean OO and it in php confuses me infinately so i decided in the context of knowing nothing i might pick it up better thus java. Ok?
    So most of what im doing is confusing to me so i just tried to type some code (Well the first 20 maybe lines i compiled and tested but after that i couldnt test so i just ran with it. Today i tried to compile and poof, nothing.I assume you got a compile time error, if so next time you post a question incorporate this piece of information.
    Any clues what im doing wrong and what i should do instead?I can take a stab at your code.
    BTW this stuff feels weird, i feel like to take imput it should have a html form or something. I dunno.One step at a time
    String yodawg;
    yodawg ="I heard you like saxaphones  ";This is not an error but plain weird IMHO, if you are declaring a variable then initializing it, you might as well do it all on one line.
    if (/* String? */username == "yes" || "Yes" || "YES"){
      testingthiscrap LeroyJenkins = new testingthiscrap
      LeroyJenkins.LetsDoThis()
    }This code will not compile and should produce one of possible many compiler errors. The condition inside the if statement requires each condition to be independent of one another. e.g. (username == "yes" || username = "Yes" || username == "YES").
    This also represents one of the most common errors presented to new comers. Equivalence of Objects such as Strings are compared using a method .equals() and not the term "==". The latter actually compares two Strings by the address stored in memory.
    class runBy convention all Class names begin with a capital letter
    Also it appears that the class run contains main method and an inner class in which itself contains a main method. I will conclude right here that you are biting off far more then you can chew. Start with the basics, e.g. Google for Java tutorials and start from "hello world" then make your way from there. Tackle one problem at a time and learn the concepts of the tutorial which will hopefully stay with you, as these fundamental concepts will be your foundation to development using the Java language.
    Mel
    Edited by: Melanie_Green, apparently CODE tags don't like me tonight

  • Work-around The Whine: why does this work? And is it BAD?

    Hello everybody, sorry to bring up The Whine again, but I was wondering if anyone can figure out why the following trick works to eliminate the noise.
    Also, could doing this regularly (all the time, basically) potentially be bad for the system in any way?
    This is the work-around I've been using:
    1. Open Photobooth, then Force Quit that application (you must Force Quit rather than simply quit)
    2. Put the Macbook to sleep, waiting a few seconds until the indicator light starts pulsing.
    3. Wake up the computer.
    Voila. That always does the trick, eliminating the whine until either the next time I boot up or the next time I open and quit Photobooth in the normal way.
    I suppose force quitting may keep the processor slightly busy somehow?
    Don't know...

    John P.,
    You say that all the notebooks that you know of make
    some kind of noise. How many notebooks is that? Not
    trying to be a jerk or anything but it better be like
    dozens and dozens to make this claim. I have heard
    the exact opposite of this claim from users that have
    owned a few notebooks as well.
    Hi Jerome,
    No problem... I'll clarify..
    5 notebooks personally, so when I say "all notebooks that I know of", it's a true claim because that is exactly what I'm saying.
    If this noise is caused by capacitor that is at some
    miniature threshold then why does the noise go away
    when said remedies are employed? Does the capacitor
    get bigger? Doesn't make sense but I appreiate that
    you want to reassure original poster.
    Actually I may have misspoken--it may be called a "voltage regulator" and it sits directly West of the CPU and controller chip. They do make noise and from what I have been told and remember, they can dampen it w/ a capacitor but that's about it. It's just the nature of the beast for that type of component, I'm told.
    What "I" think it may be is the power fluctuations, or lack thereof, in the Intel chip causing it--when you put a load on it, there's a power fluctuation because your CPU usage is going up/down a little bit, but when you're not doing anything it's very little it causes it to make a little noise. No big deal, but just as long as it's not blaring in your ear when you're trying to use your computer. My ZV6000 does the same thing, but it doesn't matter when you've got a load or not--seems to do it more when I have Cool 'n' Quiet enabled.
    This is not right. I am sorry.
    If this noise is normal then I'll take no MacBook.
    You know it is being fixed apparently on the MacBook
    Pros by motherboard replacement.
    I never said anything about pro. I don't own one, nor have I used one. I can't say how profound in comparison to the Macbook (non pro) it is.
    I'm sure if Apple thought it was a big enough problem, they would act either more quickly about it, but it's not stopping me from checking my e-mail or going on the Web.

  • Filter as autoload trigger; why does this work?

    In my efforts to use PS consoles more and CMD consoles less, I've been "porting" my environment over. One of the things I can't live without is my 'cd aliases'. I have several aliases like: "src=cd /d c:\src" (loaded in doskey). Separate
    functions for each alias seemed kludgy, so after a bit of playing around, I came up the little module below to mimic the functionality. The function takes a look at the alias that invoked it and sets the location based on values in a hashtable.
    Since the aliases are dynamically created and thus aren't available to trigger the autoload, I decided to add a filter to do the triggering (I could just import the module in my profile, but I try to keep my profile lean).
    My thought was that I could type 'src' and if the module wasn't loaded, it would cause the autoload to happen which would override the filter 'src' with the alias 'src'. Typing 'src' a second time would actually set my location to my source directory.
    When I tested the 'filter autoload' however, I was pleasantly surprised that not only did it autoload the module, but it did the set-location on the
    first invocation.
    My guess is that PS sees the command 'src' and when it's passed looks at the modules that can satisfy the command. Finding a filter named 'src' in CdAlias.psm1, it autoloads. Then PS, knowing that the needed module is now loaded, resolves 'src' against the
    now-current environment, finds the alias, resolves that to Set-XLocation and we are off to the races. That said, I'm only guessing here, and since this seems like something that could be useful in other places, it would be cool if someone could confirm my
    guess or explain what's really happening.
    thanks,
    K.
    Note: This is the prototype, I will actually store the hashtable in the registry along with functions to edit the entries.
    <#
    .Synopsis
    Sets location based on the alias name used to call the function
    .DESCRIPTION
    Uses the name of the alias used to call the function to look up
    a path in the script-scoped dictionary 'xlocation' then sets
    the location to that value.
    .PARAMETER ChildPath
    Optional child path, if passed it will be joined with the base.
    .NOTES
    Not sure why the filter trick works, but it does. Since src is my
    most commonly used alias location, I can use it to auto-load. What
    really confuses me is that it still sets the location to src the
    first time I type it.
    #>
    function Set-XLocation
    Param
    [string]$ChildPath
    $k = $MyInvocation.InvocationName
    if ($Script:xlocation.ContainsKey($k))
    Set-Location -Path (Join-Path -Path $Script:xlocation[$k] -ChildPath $ChildPath)
    else
    Write-Warning "`$xlocation does not contain the key '$k'."
    $Script:xlocation = @{
    src = 'C:\src';
    one = 'C:\src\one';
    zero = 'C:\src\zero';
    mod = "$mod";
    foreach ($k in $Script:xlocation.Keys) { Set-Alias -Name $k -Value Set-XLocation }
    filter src
    Export-ModuleMember -Function Set-XLocation -Alias *

    I do not understand what the issue is.  If you have to create a filter for every alias you are not really gaining anything over defining a function or alias.
    I do not believe the filter does anything except create a reference:
    PS C:\src> get-alias src
    CommandType     Name                                              
    ModuleName
    Alias           src -> Set-XLocation                              
    CDAlias
    ¯\_(ツ)_/¯

  • Problem with WindowAdapter, why doesnt this work ?

    Hi
    I have created a source file with the following code:
    import java.awt.* ;
    import java.awt.event.* ;
    import javax.swing.* ;
    public class EventDemo3 extends JFrame
         EventDemo3()
              // Setter tittel, st�rrelse og gj�r det synlig
              setTitle("EventDemo3 - lukking av vindu") ;
              this.addWindowListener(new WindowAdapter() {
                   public void windowClosed(WindowEvent e)
                        System.exit(0) ;
              setSize(300, 300) ;
              setVisible(true) ;
         public static void main(String[] args)
              new EventDemo3() ;
    }It compiles and runs, but when i close the window the JVM is still running and i cant figure out why, does someone know why this doesnt work ?
    Message was edited by:
    icebyte

    Perhaps you want this instead:
    import java.awt.* ;
    import java.awt.event.* ;
    import javax.swing.* ;
    public class EventDemo3 extends JFrame
         EventDemo3()
              // Setter tittel, st�rrelse og gj�r det synlig
              setTitle("EventDemo3 - lukking av vindu") ;
              this.addWindowListener(new WindowAdapter() {
                            @Override
                   public void windowClosing(WindowEvent e)
                        System.exit(0) ;
              setSize(300, 300) ;
              setVisible(true) ;
         public static void main(String[] args)
              new EventDemo3() ;
    }

  • Why doesnt this work, its so simple

    The following piece of code I guess should print "THEY ARE EQUAL" but it doesnt. I dont know why???????????? anybody help.
    String check = new String("new���".getBytes("iso-8859-1"), "iso-8859-1");
    for(int i =0 ; i< check.length(); i++)
    if(check.charAt(i)=='���') System.out.println("THEY ARE EQUAL");
    }

    You aren't comparing whether the two strings contain
    the same data, you are comparing whether the two
    references point to the same objects. Try it again
    using the .equals() method to compare the contents of
    the two strings instead of using ==.For the first time in my life have I seen DrClap err. So he is human too. amit234 is comparing characters and not Strings
    I found the solution to your problem your the corresponding line in your code with this one and it would work
    if(check.charAt(i)=='\u20AC') System.out.println("THEY ARE EQUAL");
    happy coding

  • Why wouldnt this work?

    HI,
      i created a jsp dynpage using the wizard in NWDS and in the jsp file that is created using the wizard, i have written something like this.
    <html>
    <head>
    header
    </head>
    <body>
    body
    <% String str = "jsp dynpage" %>
    </body>
    </html>
    as you can see it is a plain jsp file without any hbj tags.
    when viewed in browser, it throws a compilation error in j2ee engine.
    but when i remove the line "<% String str = "jsp dynpage" %>".. it works fine.. why arent the jsp tags working here.. any idea?
    thanks

    This is ususally how I call a method from with in a jsppage.  Notice that there is an '=' sign at the beginning.  Maybe this is important in your case.
    <%<b>=</b>salesNumbers.getCurDatInOrd()%>
    You java code sort of doesn't make sence to me.  You are just filling a string. 
    Regards,
    Rich Heilman

  • Why does this work in MS SQL and not in Oracle

    ALTER TABLE Stk
    DROP COLUMN ComCode;
    This BASIC statement works perfectly
    in MS SQL, but after 2 hours now, it
    simply refuses to work in Oracle,
    although the syntax seems correct, I
    get :
    ALTER TABLE Stk
    DROP COLUMN ComCode
    ORA-00905: missing keyword
    null

    Stop trying! Oracle simply does not support the DROP COLUMN syntax. A work around is:
    CREATE another table based on the original table, minus the column you want to drop.
    (CREATE TABLE new_table AS SELECT col1, col2 , ... FROM old_table)
    DROP the original table.
    (DROP TABLE old_table)
    RENAME the new table the old table.
    (RENAME new_table TO old_table)
    Your have to manually add the constraints, if the old table has any.
    Eric Ma

  • Map map = new HashMap(); -why doesnt this work in jdk 1.8.1

    Hi there,
    I'm trying to use a hashmap like this below:
    Map map = new HashMap();
    map.put("Carrots", new Integer(12));
    map.put("Potatoes", new Integer(30));
    map.put("Onions", new Integer(15));
    map.put("Apples", new Integer(40));
    map.put("Cherries", new Integer(300));
    the HashMap() does not exist in my API for some reason.
    Can anyone tell me why this may be?
    i'm using the hashmap with a stringtokenizer to search a text file line by line and increment how many times each keyword occurs.Sound efficient way of doing it?
    cheers,

    do you mean jdk 1.1.8?
    Map and the other Collections API were added in JDK 1.2. for JDK < 1.2, use Hashtable instead.

  • Why does this work? (dmenu_run shell script...)

    I'm very confused at what this is doing. dwm knowledge would help to understand my question. I don't understand how this script can take a font name with a space in it, the way dwm's default config does, and understand it as one argument.
    #!/bin/sh
    exe=`dmenu_path | dmenu ${1+"$@"}` && exec $exe
    Before updating to a newer version of dmenu (where this is included), I had written my own dmenu_run script. Although I wrote it, I actually don't understand how this one worked either. It was a trial and error thing, and when I try to think it through I always conclude that it shouldn't work.
    #!/bin/bash
    IFS="\t" # (was actually a literal tab character in my script)
    `dmenu_path | dmenu $*`
    This does not work without redefining $IFS, so I figured that dwm is not somehow making sure that spaces are interpretted correctly. But by stopping spaces from separating arguments, shouldn't this cause huge problems for everything except the font name?
    An example of how this would be called by dwm:
    dmenu_run -fn -*-dejavu sans-medium-r-normal-*-12-*-*-*-*-*-*-*
    (Note the space in the font name)
    So what is going on here? I realize that my question is somewhat confusing. I'm happy to clarify anything that is confusing - I found it very hard to clearly ask this question.
    Last edited by fflarex (2008-11-07 05:06:24)

    First off, sorry for all the shell-speak. This is a bit of an edge case, so it's sort of unavoidable. That said, I'll summarize what you need to know at the end.
    The dwm version of the script uses $@ in double quotes. @ contains all the parameters passed to the shell, just like * does. The main useful difference is a special case: when double-quoted, $@ expands to the list of arguments, each as a single shell word. Double-quoted $* expands to the list of arguments as a single word delimited by $IFS. (Both variables expand to the list of arguments [with word splitting applied according to $IFS, hence your spaces problem] when unquoted.) Here's the logic flow:
    1. dwm calls dmenu_run with the list of arguments specified in your config.h. It calls it directly, not running a command through a shell, so word splitting is never performed and spaces in values don't matter.
    2. dmenu_run calls dmenu with the list of arguments it was given. It uses two shell tricks: first, quoted-@ to pass the list of arguments without word splitting. Second, the ${foo+bar} expansion syntax, which expands to bar if foo is defined, otherwise the null string (""). So it expands to the full list of arguments, each as a single word, only if arguments were passed (if $1 is defined).
    What you need to know: You almost always want to use '"$@"'. Unless you want all your arguments as a single string, in which case you want '"$*"'. Other forms are practically useless.
    Last edited by skymt (2008-11-07 14:26:58)

  • Why isnt this  working

    After a big loss of out-pulled hair here is the code:
    setInterval() calls getNewMess function but it happens
    nothing with onNewMess function.
    Instead, if i click refresh-button, it gives me result
    correctly.

    evt.target._parent
    is just using the event argument that is dispatched to and
    therefore received by your listener function. It is dispatched/sent
    by your button component instance. The event object from components
    - in as2 - normally contains at least two properties. A type
    property... in this case that's "click" , because its a click event
    and a target property. The target property is a reference to the
    component instance from which the event originated. It can be
    particularly useful if you have one listener handling events from
    many sources. So.....
    evt.target._parent is referring to the container clip of the
    instance that sent the event. i.e. The _parent of the button in
    this case.
    That's why I replaced it with t (=this) which is a reference
    to the timeline that the button is running in. Now it doesn't need
    to get that reference from checking the _parent of the evt.target
    property from the evt argument. Which means the argument that the
    newMess function receives can be ignored and its no longer reliant
    on it. Sounds confusing but once you "get" it, it all makes sense.
    Eventually, lol.
    And of couse you don't need to have a button if you don't
    want one.

  • Why aint wifi working?

    I have had my Iphone 4s replaced. The first time the wifi went out. The option to turn it on was grey out. Apple Chat tried to help me trouble shoot it with no success and I was sent to apple store to get another replacement (which I did). I was given a new Iphone 4s and the wifi work for one day and same problem again. So is there going to be a solution that is actually going to fix this? Because the troubleshooting steps does not work nor should we have these problems.

    How long has it been since you got this replacement? I'm not saying it should happen, but if it has been less than 90 days, that device is still under warranty. Is it possible there is something wrong with your backup that is causing this? Did you restore this device from a backup, or as a new device. I wouldn't know what it might be, but that is the only thing the same about this device from your last one that was not working.

Maybe you are looking for

  • Add http link to document attributes

    Hi. I'm looking for a way where we can store a http link somewhere in the document attributes so that we can link to an external service management application. Is this possible? I've read that it should be possible to define additional attributes bu

  • Hooking up ipod

    everytime i try to connect my new ipod it says i have to restore and then i get a error message 1418. it now says i am stuck in a reprogram or something. if anyone can help me i sure would appreciate it.

  • Invoices for 1 line item

    Hi, We have standard PO with one line item, we do GR and many invoices for the PO which has one line item. There are variances in invoices beacuse PO has only one line item. Can we have different type of PO created for this so that the variance dont

  • Adobe Air Error - Initial Content Could Not Be Found

    Hi, I'm using BBC iplayer desktop and trying to download programmes.  I keep getting an Adobe Air Error saying 'initial content could not be found for this application'.  I've uninstalled and reinstalled Adobe Air but keep getting this message.  Any

  • Scrap in PP

    Hi Gurus, I have a scenario in which my RM is an steel tube of say 1000 mm length which is procured in Nos. Now this tube is been cut into 4 pieces of 240 mm each leaving behind scrap of 20 mm scrap at both ends so in total a scrap of 40 mm in total.