Need help in transcation code ime0
I need help in transaction code ime0. I mean to say what is this TCode doing? What different Drill-down program means? Where I can use this report?
Regards,
Subhasish
Hi
Please check the link for help
<a href="http://help.sap.com/saphelp_47x200/helpdata/EN/5c/8db33f555411d189660000e829fbbd/frameset.htm">CA - Drilldown Reporting</a>
Hope it helps
Anirban
Similar Messages
-
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 AMladsoftware 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 -
I need help with my code..
hi guys. as the subject says I need help with my code
the Q for my code is :
write a program that reads a positive integer x and calculates and prints a floating point number y if :
y = 1 ? 1/2 + 1/3 - ? + 1/x
and this is my code
This program that reads a positive integer x and calculates
and prints a floating point number y if :
y = 1 - 1/2 + 1/3 - ? + 1/x
import java.util.Scanner; // program uses class Scanner
class Sh7q2
// main method begins execution of Java application
public static void main( String args[] )
// create Scanner to obtain input from command window
Scanner input = new Scanner( System.in );
int i = 1; // i is to control the loop
int n = 2; // n is suppose to control the number sign
int x; // a positive integer entered by the user
int m;
System.out.println("Enter a positive integer");
x = input.nextInt();
do
m = (int) Math.pow( -1, n)/i;
System.out.println(m);
n++;
i++;
while ( m >= 1/x );
} // end method main
} // end class Sh7q2 when I compile it there is no error
but in the run it tells me to enter a positive integer
suppose i entered 5
then the result is 1...
can anyone tell me what's wrong with my codeThis program that reads a positive integer x and calculates
and prints a floating point number y if :
y = 1 - 1/2 + 1/3 - ? + 1/x
import java.util.Scanner; // program uses class Scanner
class Sh7q2
// main method begins execution of Java application
public static void main( String args[] )
// create Scanner to obtain input from command window
Scanner input = new Scanner( System.in );
int i = 1; // i is to control the loop
int n = 1; // n is suppose to control the number sign
int x; // a positive integer entered by the user
double m;
int a = 1;
double sum = 0;
System.out.println("Enter a positive integer");
x = input.nextInt();
for ( i = 1; a <= x; i++)
m = Math.pow( -1, n+1)/i;
sum = sum + m;
n++;
a++;
System.out.print("y = " + sum);
} // end method main
} // end class Sh7q2is it right :S -
Need Help on this Code Immediately
Hi Friends,
Iam very new to java.
I have a Java Code that iam trying to Run. The Code Compiles fine but it fails on its 3rd Loop where it is trying to Run a report.
I have the Code part that is errorring out. Can someone please look into the code and tell me if i need to make any changes to the Code.
The Code when Executed gives an Error "The Client Did Something Wrong".
Please Help Me!!!
* Execute a report.
*@param path This is the search path to the report.
*@param format The array that contains the format options (PDF,HTML,etc...)
public void executeReport(String path,String[] format)
ParameterValue pv[] = new ParameterValue[]{};
Option ro[] = new Option[3];
RunOptionBoolean saveOutput = new RunOptionBoolean();
RunOptionStringArray rosa = new RunOptionStringArray();
RunOptionBoolean burstable = new RunOptionBoolean();
// Define that the report to save the output.
saveOutput.setName(RunOptionEnum.saveOutput);
saveOutput.setValue(true);
// What format do we want the report in: PDF? HTML? XML?
rosa.setName(RunOptionEnum.outputFormat);
rosa.setValue(format);
// Define that the report can be burst.
burstable.setName(RunOptionEnum.burst);
burstable.setValue(true);
// Fill the array with the run options.
ro[0] = rosa;
ro[1] = saveOutput;
ro[2] = burstable;
try
SearchPathSingleObject spSingle = new SearchPathSingleObject();
spSingle.setValue(path);
// Get the initial response.
AsynchReply res = reportService.run(spSingle,pv,ro);
// If it has not yet completed, keep waiting until it is done.
// In this case, we wait forever.
while (res.getStatus() != AsynchReplyStatusEnum.complete && res.getStatus() != AsynchReplyStatusEnum.conversationComplete)
res = reportService.wait(res.getPrimaryRequest(), new ParameterValue[]{}, new Option[]{});
reportService.release(res.getPrimaryRequest());
// Return the final response.
catch (Exception e)
System.out.println(e);
}Guess I was too late. Sorry
Inestead of posting you need help on code immediately how about intest posting the particular topic that you are working on. It's quite doubtful that you would be here if you didn't have a question. -
wazap guys ? long time not 2 see U :)
i need help , this application that will follow is supposed to count the words lengths
i.e if typed "I am poprage" the program will output :
the word length the occurence
1 1
2 1
3
4
5
6
7 1
compile it & u will understand it.
the problem is that it makes a table for each damen word
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
public class Application2 extends JFrame{
private JLabel label;
private JTextField field;
private JTextArea area;
private JScrollPane scroll;
private int count;
public Application2(){
super("Application 2 / Word Length");
Container c = getContentPane();
c.setLayout(new FlowLayout());
label = new JLabel("Enter The Text Here");
c.add(label);
field = new JTextField(30);
field.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
StringTokenizer s = new StringTokenizer(e.getActionCommand());
count = s.countTokens();
while(s.hasMoreTokens()){
count--;
pop(s.nextToken());
c.add(field);
area = new JTextArea(10,30);
area.setEditable(false);
c.add(area);
scroll = new JScrollPane(area);
c.add(scroll);
setSize(500,500);
show();
public void pop (String s){
String poprage = "";
int count1 = 0;
int count2 = 0;
int count3 = 0;
int count4 = 0;
int count5 = 0;
int count6 = 0;
int count7 = 0;
int count8 = 0;
int count9 = 0;
int count10 = 0;
int count11 = 0;
int count12 = 0;
int count13 = 0;
int count14 = 0;
int count15 = 0;
int count16 = 0;
int count17 = 0;
int count18 = 0;
int count19 = 0;
int count20 = 0;
int count21 = 0;
int count22 = 0;
int count23 = 0;
int count24 = 0;
int count25 = 0;
for(int i = 0; i < s.length(); i++){
if(s.length() == 1) count1 += 1;
else if(s.length() == 2) count2 += 1;
else if(s.length() == 3) count3 += 1;
else if(s.length() == 4) count4 += 1;
else if(s.length() == 5) count5 += 1;
else if(s.length() == 6) count6 += 1;
else if(s.length() == 7) count7 += 1;
else if(s.length() == 8) count8 += 1;
else if(s.length() == 9) count9 += 1;
else if(s.length() == 10) count10 += 1;
else if(s.length() == 11) count11 += 1;
else if(s.length() == 12) count12 += 1;
else if(s.length() == 13) count13 += 1;
else if(s.length() == 14) count14 += 1;
else if(s.length() == 15) count15 += 1;
else if(s.length() == 16) count16 += 1;
else if(s.length() == 17) count17 += 1;
else if(s.length() == 18) count18 += 1;
else if(s.length() == 19) count19 += 1;
else if(s.length() == 20) count20 += 1;
else if(s.length() == 21) count21 += 1;
else if(s.length() == 22) count22 += 1;
else if(s.length() == 23) count23 += 1;
else if(s.length() == 24) count24 += 1;
else if(s.length() == 25) count25 += 1;
poprage += "The Length\t"+"The Occurence\n"+
"1\t"+count1+"\n"+
"2\t"+count2+"\n"+
"3\t"+count3+"\n"+
"4\t"+count4+"\n"+
"5\t"+count5+"\n"+
"6\t"+count6+"\n"+
"7\t"+count7+"\n"+
"8\t"+count8+"\n"+
"9\t"+count9+"\n"+
"10\t"+count10+"\n"+
"11\t"+count11+"\n"+
"12\t"+count12+"\n"+
"13\t"+count13+"\n"+
"14\t"+count14+"\n"+
"15\t"+count15+"\n"+
"16\t"+count16+"\n"+
"17\t"+count17+"\n"+
"18\t"+count18+"\n"+
"19\t"+count19+"\n"+
"20\t"+count20+"\n"+
"21\t"+count21+"\n"+
"22\t"+count22+"\n"+
"23\t"+count23+"\n"+
"24\t"+count24+"\n"+
"25\t"+count25+"\n";
area.append(poprage);
public static void main (String ar[]){
Application2 a = new Application2();
a.addWindowListener(
new WindowAdapter(){
public void windowClosing( WindowEvent e ){
System.exit(0);
can any one fix it ???????
REGARDS.Okay, so I took a look at it, where you are having the problem is that your pop() method not only updated the count variable, but then displays the result each time you call it. and since you call it in the loop, guess what it will give you a "table" for each "damen word"...
Any way, I was bored enough to "fix" the program and included comments as to what I did and the relative "why"...
So here goes...
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
public class Application2 extends JFrame{
private JLabel label;
private JTextField field;
private JTextArea area;
private JScrollPane scroll;
private int count;
// moved these up here so that all methods in this class
// can see and modify them, and more importantly so that they would not go
// out of scope and end up zero'd out before we display the values
// in the "table", once that done, then we can zero them out.
// although an array would be better and easier to use... -MaxxDmg...
private int count1 = 0;private int count2 = 0;
private int count3 = 0;private int count4 = 0;
private int count5 = 0;private int count6 = 0;
private int count7 = 0;private int count8 = 0;
private int count9 = 0;private int count10 = 0;
private int count11 = 0;private int count12 = 0;
private int count13 = 0;private int count14 = 0;
private int count15 = 0;private int count16 = 0;
private int count17 = 0;private int count18 = 0;
private int count19 = 0;private int count20 = 0;
private int count21 = 0;private int count22 = 0;
private int count23 = 0;private int count24 = 0;
private int count25 = 0;
// end move int count variable declarations - MaxxDmg...
public Application2(){
super("Application 2 / Word Length");
Container c = getContentPane();
c.setLayout(new FlowLayout());
label = new JLabel("Enter The Text Here");
c.add(label);
field = new JTextField(30);
field.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
String poprage = ""; // move this here, once pop() loop is done, then this string
// will be constructed and displayed - MaxxDmg...
StringTokenizer s = new StringTokenizer(e.getActionCommand());
count = s.countTokens();
while(s.hasMoreTokens()){ // this is the "pop() loop" since it calls pop() to count the words - MaxxDmg...
count--;
pop(s.nextToken()); // runs pop which only increments the count variable as needed - MaxxDmg...
}// end "pop() loop" - MaxxDmg...
// string poprage constructed one pop() loop is done to display the proper results - MaxxDmg...
poprage += "The Length\t"+"The Occurence\n"+"1\t"+count1+"\n"+
"2\t"+count2+"\n" + "3\t"+count3+"\n" + "4\t"+count4+"\n" +
"5\t"+count5+"\n" + "6\t"+count6+"\n" + "7\t"+count7+"\n" +
"8\t"+count8+"\n" + "9\t"+count9+"\n" + "10\t"+count10+"\n" +
"11\t"+count11+"\n" + "12\t"+count12+"\n" + "13\t"+count13+"\n" +
"14\t"+count14+"\n" + "15\t"+count15+"\n" + "16\t"+count16+"\n" +
"17\t"+count17+"\n" + "18\t"+count18+"\n" + "19\t"+count19+"\n" +
"20\t"+count20+"\n" + "21\t"+count21+"\n" + "22\t"+count22+"\n"+
"23\t"+count23+"\n" + "24\t"+count24+"\n" + "25\t"+count25+"\n";
area.append(poprage);
// end string construction and area update... - MaxxDmg...
// all int count variable set to 0 for next usage - MaxxDmg...
count = 0;
count1 = 0;count2 = 0;count3 = 0;count4 = 0;count5 = 0;
count6 = 0;count7 = 0;count8 = 0;count9 = 0;count10 = 0;
count11 = 0;count12 = 0;count13 = 0;count14 = 0;count15 = 0;
count16 = 0;count17 = 0;count18 = 0;count19 = 0;count20 = 0;
count21 = 0;count22 = 0;count23 = 0;count24 = 0;count25 = 0;
// end count variable reset... - MaxxDmg...
c.add(field);
area = new JTextArea(10,30);
area.setEditable(false);
c.add(area);
scroll = new JScrollPane(area);
c.add(scroll);
setSize(500,500);
show();
public void pop (String s){
// now all this method does is increment the count variables - MaxxDmg...
// which will eliminate the "making a table" for each "damen word" - MaxxDmg...
if(s.length() == 1) count1 += 1;
else if(s.length() == 2) count2 += 1;
else if(s.length() == 3) count3 += 1;
else if(s.length() == 4) count4 += 1;
else if(s.length() == 5) count5 += 1;
else if(s.length() == 6) count6 += 1;
else if(s.length() == 7) count7 += 1;
else if(s.length() == 8) count8 += 1;
else if(s.length() == 9) count9 += 1;
else if(s.length() == 10) count10 += 1;
else if(s.length() == 11) count11 += 1;
else if(s.length() == 12) count12 += 1;
else if(s.length() == 13) count13 += 1;
else if(s.length() == 14) count14 += 1;
else if(s.length() == 15) count15 += 1;
else if(s.length() == 16) count16 += 1;
else if(s.length() == 17) count17 += 1;
else if(s.length() == 18) count18 += 1;
else if(s.length() == 19) count19 += 1;
else if(s.length() == 20) count20 += 1;
else if(s.length() == 21) count21 += 1;
else if(s.length() == 22) count22 += 1;
else if(s.length() == 23) count23 += 1;
else if(s.length() == 24) count24 += 1;
else if(s.length() == 25) count25 += 1;
}// end modified pop() method - MaxxDmg...
public static void main (String ar[]){
Application2 a = new Application2();
a.addWindowListener(
new WindowAdapter(){
public void windowClosing( WindowEvent e ){
System.exit(0);
}So read the comments, look at the code and compare it to the original. You will see why the original did not give you the results you wanted, while the fixed version will...
- MaxxDmg...
- ' He who never sleeps... ' -
Need help fixing my code...
I'm currently working on a problem for school where you have to make a game called Pig.
I worked on it but need help on fixing it because it won't work the way I want it to, and I'm not sure what the problem is.
public class Pig
public static void main (String[] args)
int num1, num2, num3 = 0, num4, num5, num6 =0;
String answer="y";
PairOfDice die1 = new PairOfDice(); // die # 1
PairOfDice die2 = new PairOfDice(); // die # 2
while (num3 <= 100 || num6 <= 100)
// rolls dice
while (answer.equalsIgnoreCase("y"))
num1 = die1.roll();
num2 = die2.roll();
if (num1 == 1 || num2 == 1) // when either face is 1
{num3 = num3;
answer = "n";}
else
if (num1 == 1 && num2 == 1) // when both faces are 1
{num3 = 0;
answer = "n";}
else
num3 += num1 + num2; // sum of two faces
System.out.println (num1 +" "+ num2); // shows both faces
System.out.println (num3); // shows the sum of faces
System.out.println ("Do you want to roll again? (y/n)");
answer = Keyboard.readString();
if (answer.equalsIgnoreCase("n"))
answer = "1";
while (answer.equalsIgnoreCase("1"))
while (num6 <= 20)
num4 = die1.roll();
num5 = die2.roll();
if (num4 == 1 || num5 == 1) // when either face is 1
{num6 = num6;
answer = "2";}
else
if (num4 == 1 && num5 == 1) // when both faces are 1
{num6 = 0;
answer = "2";}
else
num6 += num4 + num5; // sum of two faces
System.out.println (num4 +" "+ num5); // shows both faces
System.out.println (num6); // shows the sum of faces
answer = "y";
Here is my code. It runs okay, but when the dice rolls a 1, it doesn't jump to the next while loop. I need the program to go to the "while loop answer = 1" when the dice rolls a 1 from the "while loop answer = y". If you see my code, I did it by making the answer = "n" to make it jump to the next while loop. I'm sorry if my explanation is confusing. It's my first time asking for help here...
You don't have to fix the code for me, as long as you tell me what I'm doing wrong.
Please help me...Thank you for your help.
Edited by: nakatsu on Nov 12, 2007 7:03 PMHint: all your code does NOT have to be in one method. You have numerous loops some nested inside others. This is starting to get mighty messy and can be tidied up if you think about how you can break some of the code down into smaller chunks and place these into their own methods.
while (answer.equalsIgnoreCase("1"))What other case is there? -
Need help with WMI code that will send output to db
'm new to WMI code writing, so I need some help with writing code that we can store on our server. I want this code to run when a user logs into their computer
and talks to our server. I also want the code to:
* check the users computer and find all installed patches
* the date the patches were installed
* the serial number of the users computer
* the computer name, os version, last boot up time, and mac address
and then have all this output to a database file. At the command prompt I've tried:
wmic qfe get description, hotfixid
This does return the patch information I'm looking for, but how do I combine that line of code with:
wmic os get version, csname, serialnumber, lastbootuptime
and
wmic nicconfig get macaddress
and then get all this to output to a database file?Thank you for the links. I checked out http://technet.microsoft.com/en-us/scriptcenter/dd793612.aspx and
found lots of good information. I also found a good command that will print information to a text file.
Basically what I'm trying to do is retrieve a list of all installed updates (Windows updates and 3rd party updates). I do like that the below code because it gives me the KB numbers for the Windows updates. I need this information so my IT co-workers &
I can keep track of which of our user computers need a patch/update installed and preferably which patch/update. The minimum we want to know is which patches / updates have been installed on which computer. If you wondering why we don't have Windows automatic
updates enable, that's because we are not allowed to.
This is my code so far.
#if you want the computer name, use this command
get-content env:computername
$computer = get-content env:computername
#list of installed patches
Get-Hotfix -ComputerName $computer#create a text file listing this information
Get-Hotfix > 'C:\users\little e\Documents\WMI help\PowerShell\printOutPatchList.txt'
I know you don't want to tell me the code that will print this out to a database (regardless if it's Access or SQL), and that's find. But maybe you can tell me this. Is it possible to have the results of this sent to a database file or do I need to go into
SQL and write code for SQL to go out and grab the data from an Excel file or txt file? If I'm understanding this stuff so far, then I suspect that it can be done both ways, but the code needs to be written correctly for this to happen. If it's true, then which
way is best (code in PowerShell to send information to SQL or SQL go get the information from the text file or Excel file)? -
Need help with error code 150:30
need help with finding out what error code 150:30 is and how to fix it
See the following:
Error 150:30 - Error "Licensing has stopped working" | Mac OS :
http://helpx.adobe.com/x-productkb/global/error-licensing-stopped-mac-os.html -
Need help trying to upgrade itunes for windows, i get to a certain point and the following error comes up "ERROR 1714: THE OLD VERSION OF ITUNES CANNOT BE REMOVED CONTACT YOUR TECHNICAL SUPPORT GROUP" i click ok and then another error comes up "ERROR 1603 FATAL ERROR" can anybody help Please!!!!!!!!!!!!!!!!!!!!
hi wags!
hmmmm. okay, let's try using the complete uninstallation instructions from the following document to remove your existing itunes and QT:
Trouble installing iPod, iTunes, or QuickTime software in Windows
if you do that first, will the new itunes install go through properly?
if you get an error message on the uninstalls, let us know what it says. include error message numbers if you're getting any.
love, b -
I have this file but I need to improve the code on some method. The methods are addNode, deleteNode, saveNode, findLader and are they anyway for me to iliminate the findsmallest method?
here is the code
import java.io.*;
import java.util.LinkedList;
import java.util.Stack;
import javax.swing.*;
public class Graph {
private LinkedList graph;
private BufferedReader inputFile;
public Graph() {
graph = new LinkedList();
// read the words from the given file
// create a GraphNode
// Add the node to the graph
public void createGraph(String fileName) throws IOException {
inputFile = new BufferedReader(
new InputStreamReader(new FileInputStream("word.txt")));
// Convert the linkedlist to an array 'a'
// sort the array 'a'
// create a string from all elements in 'a'
// return the string
public String printGraph() {
String output = new String();
// will contain String objects
// ... do some work with the list, adding, removing String objects
String[] a = new String[graph.size()];
graph.toArray(a);
// now stringArray contains all the element from linkedList
quickSort(a, 0, a.size() - 1);
for(int i=0;i<a.length;++i)
output = output + new String(a.toString())+"\n";
return output;
private static void quickSort(Comparable[] theArray,
int first, int last) {
// Sorts the items in an array into ascending order.
// Precondition: theArray[first..last] is an array.
// Postcondition: theArray[first..last] is sorted.
// Calls: partition.
int pivotIndex;
if (first < last) {
// create the partition: S1, Pivot, S2
pivotIndex = partition(theArray, first, last);
// sort regions S1 and S2
quickSort(theArray, first, pivotIndex-1);
quickSort(theArray, pivotIndex+1, last);
} // end if
} // end quickSort
private static int partition(Comparable[] theArray,
int first, int last) {
// Partitions an array for quicksort.
// Precondition: theArray[first..last] is an array;
// first <= last.
// Postcondition: Returns the index of the pivot element of
// theArray[first..last]. Upon completion of the method,
// this will be the index value lastS1 such that
// S1 = theArray[first..lastS1-1] < pivot
// theArray[lastS1] == pivot
// S2 = theArray[lastS1+1..last] >= pivot
// Calls: choosePivot.
// tempItem is used to swap elements in the array
Comparable tempItem;
// place pivot in theArray[first]
//choosePivot(theArray, first, last);
Comparable pivot = theArray[first]; // reference pivot
// initially, everything but pivot is in unknown
int lastS1 = first; // index of last item in S1
// move one item at a time until unknown region is empty
for (int firstUnknown = first + 1; firstUnknown <= last;
++firstUnknown) {
// Invariant: theArray[first+1..lastS1] < pivot
// theArray[lastS1+1..firstUnknown-1] >= pivot
// move item from unknown to proper region
if (theArray[firstUnknown].compareTo(pivot) < 0) {
// item from unknown belongs in S1
++lastS1;
tempItem = theArray[firstUnknown];
theArray[firstUnknown] = theArray[lastS1];
theArray[lastS1] = tempItem;
} // end if
// else item from unknown belongs in S2
} // end for
// place pivot in proper position and mark its location
tempItem = theArray[first];
theArray[first] = theArray[lastS1];
theArray[lastS1] = tempItem;
return lastS1;
} // end partition
// Given a new word, add it to the graph
public void addNode(String word) {
GraphNode node = new GraphNode(word);
if(graph.contains(node)){
JOptionPane.showMessageDialog(null,"Duplicate Word, operation terminated");
for(int i=0; i<graph.size(); ++i) {
if(isAnEdge((String)(((GraphNode)graph.get(i)).getVertex()),(String)(node.getVertex()))) {
EdgeNode e1 = new EdgeNode((String)node.getVertex(),1);
EdgeNode e2 = new EdgeNode((String)((GraphNode)graph.get(i)).getVertex(),1);
node.addEdge(e2);
((GraphNode)graph.get(i)).addEdge(e1);
graph.add(node);
public boolean deleteNode(String word) {
GraphNode node = new GraphNode(word);
EdgeNode n = new EdgeNode(word,1);
if(!graph.contains(node)) {
return false;
else {
for(int i=0; i<graph.size();++i) {
((GraphNode)graph.get(i)).getEdgeList().remove(n);
graph.remove(node);
return true;
public void save(String fileName) {
try {
PrintWriter output = new PrintWriter(new FileWriter("word.txt"));
for(int i=0; i< graph.size();++i) {
output.println(((GraphNode)graph.get(i)).getVertex());
output.close();
catch (IOException e) {
// given two word, find the ladder (using dijkstra's algorithm
// create a string for the ladder and return it
public String findLadder(String start,String end) {
String ladder = new String();
GraphNode sv = new GraphNode(start);
GraphNode ev = new GraphNode(end);
if(!graph.contains(sv)) {
JOptionPane.showMessageDialog(null,start + " not in graph");
return null;
if(!graph.contains(ev)) {
JOptionPane.showMessageDialog(null,end + " not in graph");
return null;
LinkedList distance = new LinkedList(((GraphNode)graph.get(graph.indexOf(sv))).getEdgeList());
LinkedList visited = new LinkedList();
visited.add(start);
LinkedList path = new LinkedList();
path.add(new PathNode(start,"****"));
for(int i=0; i<distance.size();++i) {
PathNode p = new PathNode((String)((EdgeNode)distance.get(i)).getKey(),start);
path.add(p);
while(!visited.contains(end)) {
EdgeNode min = findSmallest(distance,visited);
String v = (String)min.getVertex();
if(v.equals("****"))
return null;
visited.add(v);
// for(int i=0;i<graph.size();++i) {
// String u = (String)(((GraphNode)(graph.get(i))).getVertex());
GraphNode temp1 = new GraphNode(v);
int index = graph.indexOf(temp1);
LinkedList l = new LinkedList(((GraphNode)graph.get(index)).getEdgeList());
for(int i=0;i<l.size();++i)
String u = (String)(((EdgeNode)(l.get(i))).getVertex());
if(!visited.contains(u)) {
int du=999, dv=999, avu=999;
dv = min.getCost();
EdgeNode edge = new EdgeNode(u,1);
if(distance.contains(edge)) {
du = ((EdgeNode)(distance.get(distance.indexOf(edge)))).getCost();
GraphNode temp = new GraphNode(v);
GraphNode node = ((GraphNode)(graph.get(graph.indexOf(temp))));
LinkedList edges = node.getEdgeList();
if(edges.contains(edge)) {
avu = ((EdgeNode)(edges.get(edges.indexOf(new EdgeNode(u,1))))).getCost();
if( du > dv+avu) {
if(du == 999) {
distance.add(new EdgeNode(u,dv+avu));
path.add(new PathNode(u,v));
else {
((EdgeNode)(distance.get(distance.indexOf(u)))).setCost(dv+avu);
((PathNode)(path.get(path.indexOf(u)))).setEnd(v);
if(!path.contains(new PathNode(end,"")))
return null;
LinkedList pathList = new LinkedList();
for(int i=0;i<path.size();++i) {
PathNode n = (PathNode)path.get(path.indexOf(new PathNode(end,"****")));
if(n.getEnd().compareTo("****") != 0) {
pathList.addFirst(end);
n = (PathNode)path.get(path.indexOf(new PathNode(n.getEnd(),"****")));
end = n.getStart();
pathList.addFirst(start);
for(int i=0;i<pathList.size()-1;++i) {
ladder = ladder + ((String)(pathList.get(i))) + " --> ";
ladder = ladder + ((String)(pathList.get(pathList.size()-1)));
return ladder;
private EdgeNode findSmallest(LinkedList distance, LinkedList visited) {
EdgeNode min = new EdgeNode("****",999);
for(int i=0;i<distance.size();++i) {
String node = (String)(((EdgeNode)distance.get(i)).getVertex());
if(!visited.contains(node)) {
if(((EdgeNode)distance.get(i)).getCost()<min.getCost()) {
min = (EdgeNode)distance.get(i);
return min;
// class that represents nodes inserted into path set
private class PathNode {
protected String sv;
protected String ev;
public PathNode(String s,String e) {
sv = s;
ev = e;
public String getEnd() {
return ev;
public String getStart() {
return sv;
public void setEnd(String n) {
ev = n;
public boolean equals(Object o) {
return this.sv.equals(((PathNode)o).sv);
public String toString() {
return "("+sv+":"+ev+")";
thank youlet me fix my misstake which was point out by some one in here and thank you ofr do so because I'm new at this.
I have this file but I need to improve the code on some method. The methods are addNode, deleteNode, saveNode, findLader and are they anyway for me to iliminate the findsmallest method?
here is the code
import java.io.*;
import java.util.LinkedList;
import java.util.Stack;
import javax.swing.*;
public class Graph {
private LinkedList graph;
private BufferedReader inputFile;
public Graph() {
graph = new LinkedList();
// read the words from the given file
// create a GraphNode
// Add the node to the graph
public void createGraph(String fileName) throws IOException {
inputFile = new BufferedReader(
new InputStreamReader(new FileInputStream("word.txt")));
// Convert the linkedlist to an array 'a'
// sort the array 'a'
// create a string from all elements in 'a'
// return the string
public String printGraph() {
String output = new String();
// will contain String objects
// ... do some work with the list, adding, removing String objects
String[] a = new String[graph.size()];
graph.toArray(a);
// now stringArray contains all the element from linkedList
quickSort(a, 0, a.size() - 1);
for(int i=0;i<a.length;++i)
output = output + new String(a.toString())+"\n";
return output;
private static void quickSort(Comparable[] theArray,
int first, int last) {
// Sorts the items in an array into ascending order.
// Precondition: theArray[first..last] is an array.
// Postcondition: theArray[first..last] is sorted.
// Calls: partition.
int pivotIndex;
if (first < last) {
// create the partition: S1, Pivot, S2
pivotIndex = partition(theArray, first, last);
// sort regions S1 and S2
quickSort(theArray, first, pivotIndex-1);
quickSort(theArray, pivotIndex+1, last);
} // end if
} // end quickSort
private static int partition(Comparable[] theArray,
int first, int last) {
// Partitions an array for quicksort.
// Precondition: theArray[first..last] is an array;
// first <= last.
// Postcondition: Returns the index of the pivot element of
// theArray[first..last]. Upon completion of the method,
// this will be the index value lastS1 such that
// S1 = theArray[first..lastS1-1] < pivot
// theArray[lastS1] == pivot
// S2 = theArray[lastS1+1..last] >= pivot
// Calls: choosePivot.
// tempItem is used to swap elements in the array
Comparable tempItem;
// place pivot in theArray[first]
//choosePivot(theArray, first, last);
Comparable pivot = theArray[first]; // reference pivot
// initially, everything but pivot is in unknown
int lastS1 = first; // index of last item in S1
// move one item at a time until unknown region is empty
for (int firstUnknown = first + 1; firstUnknown <= last;
++firstUnknown) {
// Invariant: theArray[first+1..lastS1] < pivot
// theArray[lastS1+1..firstUnknown-1] >= pivot
// move item from unknown to proper region
if (theArray[firstUnknown].compareTo(pivot) < 0) {
// item from unknown belongs in S1
++lastS1;
tempItem = theArray[firstUnknown];
theArray[firstUnknown] = theArray[lastS1];
theArray[lastS1] = tempItem;
} // end if
// else item from unknown belongs in S2
} // end for
// place pivot in proper position and mark its location
tempItem = theArray[first];
theArray[first] = theArray[lastS1];
theArray[lastS1] = tempItem;
return lastS1;
} // end partition
// Given a new word, add it to the graph
public void addNode(String word) {
GraphNode node = new GraphNode(word);
if(graph.contains(node)){
JOptionPane.showMessageDialog(null,"Duplicate Word, operation terminated");
for(int i=0; i<graph.size(); ++i) {
if(isAnEdge((String)(((GraphNode)graph.get(i)).getVertex()),(String)(node.getVertex()))) {
EdgeNode e1 = new EdgeNode((String)node.getVertex(),1);
EdgeNode e2 = new EdgeNode((String)((GraphNode)graph.get(i)).getVertex(),1);
node.addEdge(e2);
((GraphNode)graph.get(i)).addEdge(e1);
graph.add(node);
public boolean deleteNode(String word) {
GraphNode node = new GraphNode(word);
EdgeNode n = new EdgeNode(word,1);
if(!graph.contains(node)) {
return false;
else {
for(int i=0; i<graph.size();++i) {
((GraphNode)graph.get(i)).getEdgeList().remove(n);
graph.remove(node);
return true;
public void save(String fileName) {
try {
PrintWriter output = new PrintWriter(new FileWriter("word.txt"));
for(int i=0; i< graph.size();++i) {
output.println(((GraphNode)graph.get(i)).getVertex());
output.close();
catch (IOException e) {
// given two word, find the ladder (using dijkstra's algorithm
// create a string for the ladder and return it
public String findLadder(String start,String end) {
String ladder = new String();
GraphNode sv = new GraphNode(start);
GraphNode ev = new GraphNode(end);
if(!graph.contains(sv)) {
JOptionPane.showMessageDialog(null,start + " not in graph");
return null;
if(!graph.contains(ev)) {
JOptionPane.showMessageDialog(null,end + " not in graph");
return null;
LinkedList distance = new LinkedList(((GraphNode)graph.get(graph.indexOf(sv))).getEdgeList());
LinkedList visited = new LinkedList();
visited.add(start);
LinkedList path = new LinkedList();
path.add(new PathNode(start,"****"));
for(int i=0; i<distance.size();++i) {
PathNode p = new PathNode((String)((EdgeNode)distance.get(i)).getKey(),start);
path.add(p);
while(!visited.contains(end)) {
EdgeNode min = findSmallest(distance,visited);
String v = (String)min.getVertex();
if(v.equals("****"))
return null;
visited.add(v);
// for(int i=0;i<graph.size();++i) {
// String u = (String)(((GraphNode)(graph.get(i))).getVertex());
GraphNode temp1 = new GraphNode(v);
int index = graph.indexOf(temp1);
LinkedList l = new LinkedList(((GraphNode)graph.get(index)).getEdgeList());
for(int i=0;i<l.size();++i)
String u = (String)(((EdgeNode)(l.get(i))).getVertex());
if(!visited.contains(u)) {
int du=999, dv=999, avu=999;
dv = min.getCost();
EdgeNode edge = new EdgeNode(u,1);
if(distance.contains(edge)) {
du = ((EdgeNode)(distance.get(distance.indexOf(edge)))).getCost();
GraphNode temp = new GraphNode(v);
GraphNode node = ((GraphNode)(graph.get(graph.indexOf(temp))));
LinkedList edges = node.getEdgeList();
if(edges.contains(edge)) {
avu = ((EdgeNode)(edges.get(edges.indexOf(new EdgeNode(u,1))))).getCost();
if( du > dv+avu) {
if(du == 999) {
distance.add(new EdgeNode(u,dv+avu));
path.add(new PathNode(u,v));
else {
((EdgeNode)(distance.get(distance.indexOf(u)))).setCost(dv+avu);
((PathNode)(path.get(path.indexOf(u)))).setEnd(v);
if(!path.contains(new PathNode(end,"")))
return null;
LinkedList pathList = new LinkedList();
for(int i=0;i<path.size();++i) {
PathNode n = (PathNode)path.get(path.indexOf(new PathNode(end,"****")));
if(n.getEnd().compareTo("****") != 0) {
pathList.addFirst(end);
n = (PathNode)path.get(path.indexOf(new PathNode(n.getEnd(),"****")));
end = n.getStart();
pathList.addFirst(start);
for(int i=0;i<pathList.size()-1;++i) {
ladder = ladder + ((String)(pathList.get(i))) + " --> ";
ladder = ladder + ((String)(pathList.get(pathList.size()-1)));
return ladder;
private EdgeNode findSmallest(LinkedList distance, LinkedList visited) {
EdgeNode min = new EdgeNode("****",999);
for(int i=0;i<distance.size();++i) {
String node = (String)(((EdgeNode)distance.get(i)).getVertex());
if(!visited.contains(node)) {
if(((EdgeNode)distance.get(i)).getCost()<min.getCost()) {
min = (EdgeNode)distance.get(i);
return min;
// class that represents nodes inserted into path set
private class PathNode {
protected String sv;
protected String ev;
public PathNode(String s,String e) {
sv = s;
ev = e;
public String getEnd() {
return ev;
public String getStart() {
return sv;
public void setEnd(String n) {
ev = n;
public boolean equals(Object o) {
return this.sv.equals(((PathNode)o).sv);
public String toString() {
return "("+sv+":"+ev+")";
}thank you -
Noob needs help with this code...
Hi,
I found this code in a nice tutorial and I wanna make slight
adjustments to the code.
Unfortunately my Action Script skills are very limited... ;)
This is the code for a 'sliding menue', depending on which
button u pressed it will 'slide' to the appropriate picture.
Here's the code:
var currentPosition:Number = large_pics.pic1._x;
var startFlag:Boolean = false;
menuSlide = function (input:MovieClip) {
if (startFlag == false) {
startFlag = true;
var finalDestination:Number = input._x;
var distanceMoved:Number = 0;
var distanceToMove:Number =
Math.abs(finalDestination-currentPosition);
var finalSpeed:Number = .2;
var currentSpeed:Number = 0;
var dir:Number = 1;
if (currentPosition<=finalDestination) {
dir = -1;
} else if (currentPosition>finalDestination) {
dir = 1;
this.onEnterFrame = function() {
currentSpeed =
Math.round((distanceToMove-distanceMoved+1)*finalSpeed);
distanceMoved += currentSpeed;
large_pics._x += dir*currentSpeed;
if (Math.abs(distanceMoved-distanceToMove)<=1) {
large_pics._x =
mask_pics._x-currentPosition+dir*distanceToMove;
currentPosition = input._x;
startFlag = false;
delete this.onEnterFrame;
b1.onRelease = function() {
menuSlide(large_pics.pic1);
b2.onRelease = function() {
menuSlide(large_pics.pic2);
b3.onRelease = function() {
menuSlide(large_pics.pic3);
b4.onRelease = function() {
menuSlide(large_pics.pic4);
I need to adjust five things in this code...
(1) I want this menue to slide vertically not horizontally.
I changed the 'x' values in the code to 'y' which I thought
would make it move vertically, but it doesn't work...
(2) Is it possible that, whatever the distance is, the
"sliding" time is always 2.2 sec ?
(3) I need to implement code that after the final position is
reached, the timeline jumps to a certain movieclip to a certain
label - depending on what button was pressed of course...
I tried to implement this code for button number two...
b2.onRelease = function() {
menuSlide(large_pics.pic2);
if (currentPosition = finalDestination) {
this.large_pics.pic2.gotoAndPlay("s1");
--> sliding still works but it doesn't jump to the
appropriate label...
(4) I wanna add 'Next' & 'Previous' buttons to the slide
show - what would be the code in this case scenario ?
My first thought was something like that Flash checks which
'pic' movieclip it is showing right now (pic1, pic2, pic3 etc.) and
depending on what button u pressed u go to the y value of movieclip
'picX + 1' (Next button) or 'picX - 1' (Previous button)...
Is that possible ?
(5) After implementing the Next & Previous buttons I need
to make sure that when it reached the last pic movieclip it will
not go further on the y value - because there is no more pic
movieclip.
Options are to either slide back to movieclip 'pic1' or
simply do nothing any more on the next button...
I know this is probably Kindergarten for you, but I have only
slight ideas how to do this and no code knowledge to back it up...
haha
Thanx a lot for your help in advance !
Always a pleasure to learn from u guys... ;)
MikeHi,
I made some progress with the code thanx to the help of
Simon, but there are still 2 things that need to be addressed...
(1) I want the sliding time always to be 2.2 sec...
here's my approach to it - just a theory but it might work:
we need a speed that changes dynamically depending on the
distance we have to travel...
I don't know if that applies for Action Scrip but I recall
from 6th grade, that...
speed = distance / time
--> we got the time (which is always 2.2 sec)
--> we got the disctance
(currentposition-finaldestination)
--> this should automatically change the speed to the
appropriate value
Unfortunately I have no clue how the action script would look
like (like I said my action script skills are very limited)...
(2) Also, one other thing I need that is not implemented yet,
is that when the final destination is reached it jumps to a certain
label inside a certain movieclip - every time different for each
button pressed - something like:
if (currentPosition = finalDestination) {
this.large_pics.pic2.gotoAndPlay("s1");
that statement just doesn't work when I put it right under
the function for each button...
Thanx again for taking the time !!!
Mike -
Sql injection attack - need help changing ASP code
Our web server was attacked yesterday by SQL injection. So I
quickly learned about the holes in the code that was generated by
Dreamweaver MX 2004.
I found the help article on the Adobe website to fix the ASP
code; however I need more information for my particular case. I
don't know how to get my cursor type and location settings into the
new code.
MY ORIGINAL CODE
<%
Dim Recordset1
Dim Recordset1_numRows
Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_Oncology_STRING
Recordset1.Source = "SELECT * FROM dbo.Oncology_Dir WHERE
Oncology_ID = " + Replace(Recordset1__MMColParam, "'", "''") + ""
Recordset1.CursorType = 0
Recordset1.CursorLocation = 3
Recordset1.LockType = 1
Recordset1.Open()
Recordset1_numRows = 0
%>
THE NEW CODE, WHICH NEEDS TO BE FIXED TO REFLECT CURSOR TYPE
AND LOCATION ABOVE.
<%
Dim Recordset1
Dim Recordset1_cmd
Dim Recordset1_numRows
Set Recordset1_cmd = Server.CreateObject ("ADODB.Command")
Recordset1_cmd.ActiveConnection = MM_Oncology_STRING
Recordset1_cmd.CommandText = "SELECT * FROM dbo.Oncology_Dir
WHERE Oncology_ID = ?"
Recordset1_cmd.Prepared = true
Recordset1_cmd.Parameters.Append
Recordset1_cmd.CreateParameter("param1", 5, 1, -1,
Recordset1__MMColParam) ' adDouble
Set Recordset1 = Recordset1_cmd.Execute
Recordset1_numRows = 0
%>
What exactly is the 5,1,-1 in the code above?
Any help would be very much appreciated as my ASP page
(although secured from SQL injection) is not working properly.
Thanks,
--Jen
--JenThe new snippet is not vulnerable to SQL injection. It uses a
command
object and actual defined parameters, so you're safe. You
cannot change the
cursor type or location on that object.
"jennday" <[email protected]> wrote in
message
news:f85omh$ngg$[email protected]..
> Our web server was attacked yesterday by SQL injection.
So I quickly
> learned
> about the holes in the code that was generated by
Dreamweaver MX 2004.
> I found the help article on the Adobe website to fix the
ASP code; however
> I
> need more information for my particular case. I don't
know how to get my
> cursor type and location settings into the new code. -
Need help in this code snippet for split container
Hi,
I am using the following code to display two tables in report output.
using cl_salv_table.
=============================================================================================
START-OF-SELECTION.
DATA: lo_report TYPE REF TO lcl_test_class.
* create report object
CREATE OBJECT lo_report.
* call methods
lo_report->get_data( ).
lo_report->process_data( ).
lo_report->generate_output( ).
METHOD generate_output.
data: g_custom_container TYPE REF TO cl_gui_custom_container, "custom container
g_splitter_container TYPE REF TO cl_gui_splitter_container, "splitter container
g_top_container TYPE REF TO cl_gui_container, "top container
g_bottom_container TYPE REF TO cl_gui_container, "bottom one
g_display TYPE REF TO cl_salv_display_settings, " set display pattern
g_slav_table TYPE REF TO cl_salv_table,
g_table TYPE REF TO cl_salv_table.
"create custom container placed in CUSTOM AREA defined on screen
CREATE OBJECT g_custom_container
EXPORTING
container_name = 'CUSTOM_AREA'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
OTHERS = 6.
IF sy-subrc 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
"now split the container into two independent containers
CREATE OBJECT g_splitter_container
EXPORTING
parent = g_custom_container
rows = 2
columns = 1
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
IF sy-subrc 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
"get top container
CALL METHOD g_splitter_container->get_container
EXPORTING
row = 1
column = 1
RECEIVING
container = g_top_container.
TRY.
CALL METHOD cl_salv_table=>factory
EXPORTING
r_container = g_top_container
IMPORTING
r_salv_table = lr_table
CHANGING
t_table = gt_itab_header. "gt_itab_header is populated with required output columns in process_data( ) method
CATCH cx_salv_msg.
ENDTRY.
g_display = g_table->get_display_settings( ).
g_display->set_striped_pattern( cl_salv_display_settings=>true ).
g_display->set_striped_pattern( cl_salv_display_settings=>true ).
*... Display table
g_table->display( ).
ENDMETHOD.
=============================================================================================
<Added code tags>
when I Execute the code, it still stay on selection screen does not display output table. If I comment out the lines
EXPORTING
r_container = g_top_container
from the Method "cl_salv_table=>factory" the output is displayed with table in required format.
Could someone help me out identifying what am I doing wrong.
Thanks,
Abhiram.
Edited by: Suhas Saha on Jan 31, 2012 9:14 PMwhen I Execute the code, it still stay on selection screen does not display output table.
You need to call the screen in which you have defined the custom container 'CUSTOM_AREA'. And you need to call the method generate_output( ) in the PBO of the screen.
If I comment out the lines
EXPORTING
r_container = g_top_container
from the Method "cl_salv_table=>factory" the output is displayed with table in required format.
If you're removing the R_CONTAINER parameter, SALV framework displays the data in full-screen grid. Actually it uses REUSE_ALV_GRID_DISPLAY to display the data. Hence you are getting the data.
To be honest i'll be surprised if you are getting the splitter container, can you confirm if you are getting it?
BR,
Suhas -
Need help getting this code to work
I am trying to get this code to work using "if else statment" but it will only do the first part and not do the second part in the else statement. Can anyone help me out? Here is the code:
var R1 = this.getField("Registration Fees1");
var R2 = this.getField("Registration Fees2");
var R3 = this.getField("Registration Fees3");
var R4 = this.getField("Registration Fees4");
var R0 = 0
if (R0 == 0)
event.value = Math.floor(R1.value);
else
event.value = Math.floor(R2.value + R3.value + R4.value);
I did notice that if I fiddled around this this part:
if (R0 == 0)
sometimes I can get the second part to work but not the first. I need it to do either or and this is getting frustrating.
I might also not even need "var R0 = 0". I put that there for the condition part. If that is what is causing the problem, I can take it out. But then what would the condition be? For this form, the default is 0 and then the calculation follows by user clicking on different prices. The first part is if they want to pay for the full conference and the second part is if they want to pay for either Monday, Tuesday or Wednesday or 2 of the 3 days. Is it possible to get this to work with both parts together? I am still stuck on getting just one or the other working. Any help would be greatly appreciated. Thanks in advance.I have posted this on another message board and a user by the name of gkaiseril offered this solution but it hasn't worked either.
// all four days
var R1 = this.getField("Registration Fees1").value;
// Monday
var R2 = this.getField("Registration Fees2").value;
// Tuesday
var R3 = this.getField("Registration Fees3").value;
// Wednesday
var R4 = this.getField("Registration Fees4").value;
var Fee = 0
event.value = ''; // default value
if (R1 != 'Off') {
Fee = Number(R1) + Fee;
} else {
if(R2 != 'Off') {
Fee = Number(Fee) + R2;
if(R3 != 'Off') {
Fee += Number(R3);
if(R4 != 'Off') {
Fee = Number(R4) + Fee;
event.value = Fee; -
Need help with LabVIEW code for motor control.
Hi,
My name is Sasi. I am a BME grad student working on my thesis topic of evaluating spine implants for low back pain. For this I am building a test machine that would apply pure moments to a spine specimen. I am using LabVIEW 8.5 to implement control of a brushless AC servo motor. My requirement is,
Step 1: Initialize the motor.
Step 2: Start moving it at a uniform RPM to the right (This RPM value too user can enter).
Step
3: While doin Step 2; simultaneously read torque cell data (Using DAQ
asst.). DAQ o/p is from 0 V to 10 V; 0 V being -10 Nm n
10 V being +10 Nm
Step 4: When Torque value reaches +10 Nm, i.e 10 V, the motor stops.
Step
5: From the position where motor stopped (i.e no need to reset to
initial position) Start moving in the opposite direction at the same
uniform RPM as in Step 2 while reading torque cell data.
Step 6: Once again when torque reaches -10 Nm, i.e. 0 V, the motor should stop.
Step 7: Repeat 'Step 2' to 'Step 6' 3 times.
Step 8: Reset motor postion.
Till now I have managed to get the motor to move forward n backward @ a desired vel, accl, n deceleration for 3 cycles. I am attaching my code. I am having problem inserting the code for reading DAQmx amidst all this. Can anyone help me out.
Thnks,
Sasi.
Solved!
Go to Solution.
Attachments:
Test_012609.vi 35 KBHi Sasidhar,
I took a look at your problem and I think I have a workable solution for you. I definitely agree with Lynn's suggestion of using parallel loops. This will allow the DAQmx portion to run uninhibited by the motion portion, and vice versa. Plus, you only need to iterate the motion loop whenever the voltage level crosses a threshold. So, by iterating on the motion code in the same loop that you are iterating on DAQmx code, you are essentially wasting processor.
I created a VI that should do what you are wanting. I tested it out myself and it works great. You might have a tweak a few things to apply to your system (like motion board ID and DAQmx physical channel, etc.). I used two parallel loops and event-based programming. Basically the motion loop starts the motor spinning at the specified velocity. Once the motor is spinning, it waits for the DAQmx loop to tell it that the voltage value has crossed the threshold. When the voltage value exceeds the maximum threshold (which I set to a value slightly less than 10 to allow for jitter and saturation), the DAQmx loop signals the motion loop that it can finish its iteration. The motion loop stops the motion, reverses the direction, and starts the motion again. Once motion has started, it again waits for the DAQmx loop to tell it that a threshold has occurred, but this time, it is looking for a minimum threshold. I used "Occurrences" to implement the event-based programming in LabVIEW.
I have commented the code rather thouroughly, so hopefully the comments will answer any remaining questions. The benefit of using event-based programming for this is that you save processor time, and your motion is more closely synchonized with the DAQmx. Instead of iterating the motion loop as fast as you can, checking for updates each time, you just pause it, and wait for the other loop to tell you when to start up again. In the mean time, the processor doesn't have to worry about iterating that loop over and over again. Also, when the occurrence does occur, you catch it immediately, instead of having to wait until the next iteration. Thus, you are more closely synchronized with the DAQmx portion of the code.
I hope this will help you. Please post back if you have any questions about the code or its implementation. Good Luck!
Message Edited by Wes P on 02-03-2009 05:18 PM
Wes P
Certified LabVIEW Developer
Attachments:
Motion and DAQ.vi 59 KB
DAQmx Loop.png 24 KB
Motion Loop.png 17 KB
Maybe you are looking for
-
Reading email in outlook with c# and parsing the body
Hello, I don't know where to start. The organization I work for uses different user web forms to collect user/client feedback. Instead of having those forms populate a table, they have them emailed to me as text in the body of an email for me to deci
-
Two Internal Tables for ALV Grid
Hi Gurus, I have a little problem here. I have a report to display cost of production. The rows is about 50 displaying amount in dollars (currency fields). I have this in ALV Grid. But my problem is that the last 4 lines of the report are not currenc
-
Spanish speech analysis not appearing in the language list
I downloaded and installled the spanish speech analysis module for CS 6 and CC. I have both CS 6 and CC installed on my machine. I installed the spanish module. Then in prelude, the spanish option doesn't appear in the language list. I only have engl
-
"This photo was downloaded from a photo subscription" but from my camera
When looking in my Unnamed Faces smart folder, (Face is unnamed), I am getting the message "*This photo was downloaded from a photo subscription*" in the Info frame for several photos that were taken with my camera. I never saw this before I moved to
-
PROJECT DUE TODAY __ NEED HELP!!!
i posted earlier about how DVDStudio is quitting itself while rendering the menu. i think exactly what it says is rendering menu1, language menu. i sat here and watched it for 4 hours and it gets to 60%, shuts down. no file to be found, nothing. i ha