How can i modify this code in BI?
hi friends,
suppose i have data in infosource with deffirent customers.
like from usa,germany,uk.
i created 3 cubes and uploaded records corresponding countries.
i have written code like this in 3.5
loop at data_package.
if data_package-/bic/zcustomer <> 'usa'.
delete data_package.
endif.
endloop.
same logic i need to write in BI 7.0 now where can i write this logic, what modifications i need to change for BI 7.0
regards
suneel.
Hi,
Check this link:
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/6090a621-c170-2910-c1ab-d9203321ee19
I guess, you just need to change the DATA_PACKAGE to the new naming convention.
Hope this helps.
PB
Similar Messages
-
How can I modify this code to display an image in an applet?
Sorry, I'm almost positive this is absolutely incorrect, but here is what I have so far:
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.io.*;
import javax.imageio.*;
import javax.swing.*;
public class Blackberry extends JApplet implements ActionListener
Image image;
public void init()
//image = getImage(getDocumentBase(), "bluespace.png");
try { image = ImageIO.read(new File("bluespace.png")); }
catch (IOException e) { }
public void paint(Graphics g)
g.drawImage(image, 0, 0, this);
}There are no errors given when run as an applet in Eclipse, it just displays a blank window.Here's a small example of a JPanel that draws an image:
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import javax.swing.JPanel;
public class ShowImageJPanel extends JPanel
private Image image;
public ShowImageJPanel(Image image)
this.image = image;
Dimension size = new Dimension(
image.getWidth(this),
image.getHeight(this));
setPreferredSize(size);
@Override
protected void paintComponent(Graphics g)
super.paintComponent(g);
if (image != null)
g.drawImage(image, 0, 0, this);
}and a JApplet that adds this JPanel into its contentPane:
import java.awt.Image;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JApplet;
public class ShowImageApplet extends JApplet
private static final String IMAGE_PATH = "images/SunSteinSmall.png";
public void init()
try
javax.swing.SwingUtilities.invokeAndWait(new Runnable()
public void run()
createGUI();
catch (Exception e)
System.err.println("createGUI didn't successfully complete");
private void createGUI()
try
Image image = ImageIO.read(getClass().getResourceAsStream(IMAGE_PATH));
getContentPane().add(new ShowImageJPanel(image));
catch (IOException e)
e.printStackTrace();
}Here I have a subpackage off of the applet's package called image, and it's filled with Duke images which you can download from here:
[https://duke.dev.java.net/images/index.html] -
How can i run this code correctly?
hello, everybody:
when i run the code, i found that it dons't work,so ,i hope somebody can help me!
the Ball class is this :
package {
import flash.display.Sprite;
[SWF(width = "550", height = "400")]
public class Ball extends Sprite {
private var radius:Number;
private var color:uint;
private var vx:Number;
private var vy:Number;
public function Ball(radius:Number=40, color:uint=0xff9900,
vx:Number =0, vy:Number =0) {
this.radius= radius;
this.color = color;
this.vx = vx;
this.vy = vy;
init();
private function init():void {
graphics.beginFill(color);
graphics.drawCircle(0,0,radius);
graphics.endFill();
and the Chain class code is :
package {
import flash.display.Sprite;
import flash.events.Event;
[SWF(width = "550", height = "400")]
public class Chain extends Sprite {
private var ball0:Ball;
private var ball1:Ball;
private var ball2:Ball;
private var spring:Number = 0.1;
private var friction:Number = 0.8;
private var gravity:Number = 5;
//private var vx:Number =0;
//private var vy:Number = 0;
public function Chain() {
init();
public function init():void {
ball0 = new Ball(20);
addChild(ball0);
ball1 = new Ball(20);
addChild(ball1);
ball2 = new Ball(20);
addChild(ball2);
addEventListener(Event.ENTER_FRAME, onEnterFrame);
private function onEnterFrame(event:Event):void {
moveBall(ball0, mouseX, mouseY);
moveBall(ball1, ball0.x, ball0.y);
moveBall(ball2, ball1.x, ball1.y);
graphics.clear();
graphics.lineStyle(1);
graphics.moveTo(mouseX, mouseY);
graphics.lineTo(ball0.x, ball0.y);
graphics.lineTo(ball1.x, ball1.y);
graphics.lineTo(ball2.x, ball2.y);
private function moveBall(ball:Ball,
targetX:Number,
targetY:Number):void {
ball.vx += (targetX - ball.x) * spring;
ball.vy += (targetY - ball.y) * spring;
ball.vy += gravity;
ball.vx *= friction;
ball.vy *= friction;
ball.x += vx;
ball.y += vy;
thanks every body's help!ok, thanks for your reply ! I run this code in the Flex builder 3!and the Ball class and the Chain class are all in the same AS project!
and i changed the ball.pv property as public in the Ball class, and the Chain class has no wrong syntactic analysis,but the AS code don't run.so this is the problem.
2010-04-21
Fang
发件人: Ned Murphy <[email protected]>
发送时间: 2010-04-20 23:01
主 题: how can i run this code correctly?
收件人: fang alvin <[email protected]>
I don't see that the Ball class has a pv property, or that you even try to access a pv property in the Chain class. All of the properties in your Ball class are declared as private, so you probably cannot access them directly. They would need to be public. Also, I still don't see where you import Ball in the chain class such that it can use it. -
How can i know how to redeem the code? how can i get this code?
how can i know how to redeem the code? how can i get this code? please i need you help
<Email Edited by Host>You are trying to create a new Apple ID? You don't have one yet? Is that correct?
If so, then see this article on how to creat your Apple ID - and make up a password for it. Remember to write it down immediately.
http://support.apple.com/en-us/HT203993 -
I forgot the codeslot of my ipod. How can I delete this code?
I forgot the codeslot of my ipod. How can I delete this code? Can anybody help help me? I'm sorry for the bad English.
Connect it to iTunes and Restore it.
-
How can i rewrite this code into java?
How can i rewrite this code into a java that has a return value?
this code is written in vb6
Private Function IsOdd(pintNumberIn) As Boolean
If (pintNumberIn Mod 2) = 0 Then
IsOdd = False
Else
IsOdd = True
End If
End Function
Private Sub cmdTryIt_Click()
Dim intNumIn As Integer
Dim blnNumIsOdd As Boolean
intNumIn = Val(InputBox("Enter a number:", "IsOdd Test"))
blnNumIsOdd = IsOdd(intNumIn)
If blnNumIsOdd Then
Print "The number that you entered is odd."
Else
Print "The number that you entered is not odd."
End If
End Sub873221 wrote:
I'm sorry I'am New to Java.Are you new to communication? You don't have to know anything at all about Java to know that "I have an error," doesn't say anything useful.
I'm just trying to get you to think about what your post actually says, and what others will take from it.
what does this error mean? what code should i replace and add? thanks for all response
C:\EvenOdd.java:31: isOdd(int) in EvenOdd cannot be applied to ()
isOdd()=true;
^
C:\EvenOdd.java:35: isOdd(int) in EvenOdd cannot be applied to ()
isOdd()=false;
^
2 errors
Telling you "what code to change it to" will not help you at all. You need to learn Java, read the error message, and think about what it says.
It's telling you exactly what is wrong. At line 31 of EvenOdd.java, you're calling isOdd(), with no arguments, but the isOdd() method requires an int argument. If you stop ant think about it, that should make perfect sense. How can you ask "is it odd?" without specifying what "it" is?
So what is this all about? Is this homework? You googled for even odd, found a solution in some other language, and now you're just trying to translate it to Java rather than actually learning Java well enough to simply write this trivial code yourself? -
How can i improve this code ?
DATA: t_bkpf TYPE bkpf.
DATA: t_bseg type bseg_t.
DATA: wa_bseg like line of t_bseg.
select * from bkpf into t_bkpf where document type ='KZ' and bldat in s_bldat.
select single * from bseg into wa_bseg where belnr = t_bkpf-belnr.
append wa_bseg to t_bseg.
endselect.
loop at t_bseg into wa_bseg.
at new belnr.
if wa_bseg-koart EQ 'K'.
// pick vendor wrbtr
else
// pick other line item's wrbtr
endif.
endat.
endloop.
i am guessing my select statements arnt efficient performance wise, secondly in the loop when i use 'at new belnr' it aint showing my any values whereas i get all the vendors(KOART EQ 'K') when i dont use 'at new belnr' .
why is this so and how can i make the code efficient ?
Thanks..
ShehryarHi,
1.Dont read all the fields from the table unless it is required in your program.
This will tremendously improve your performance.
2.Make use of the key fields of the table wherever possible
In your scenario you could use the fields BUKRS,BELNR,GJAHR of the table BKPF in the WHERE Clause rather than
other fields.This will improve your performance a lot..
3.As BSEG is a cluster table it will cause performance problem in most cases.So try to read
the required fields from it rather than reading all the fields.Again Make use of the key fields in the WHERE Clause
here too to improve the performance..
4.Remove SELECT..ENDSELECT and replace it with FOR ALL ENTRIES to improve the performance.
Cheers,
Abdul Hakim
Mark all useful answers.. -
How can I modify this script to return only certain rows of my mySQL table?
Hi there,
I have a php script that accesses a mySQL database and it was generated out of the Flex Builder wizard automatically. The script works great and there are no problems with it. It allows me to perform CRUD on a table by calling it from my Flex app. and it retrieves all the data and puts it into a nice MXML format.
My question, currently when I call "findAll" to retrieve all the data in the table, well, it retrieves ALL the rows in the table. That's fine, but my table is starting to grow really large with thousands of rows.
I want to modify this script so that I can pass a variable into it from Flex so that it only retrieves the rows that match the "$subscriber_id" variable that I pass. In this way the results are not the entire table's data, only the rows that match 'subscriber_id'.
I know how to pass a variable from Flex into php and the code on the php side to pick it up would look like this:
$subscriberID = $_POST['subscriberID'];
Can anyone shed light as to the proper code modification in "findAll" which will take my $subscriberID variable and compare it to the 'subscriber_id' field and then only return those rows that match? I think it has something to do with lines 98 to 101.
Any help is appreciated.
<?php
require_once(dirname(__FILE__) . "/2257safeDBconn.php");
require_once(dirname(__FILE__) . "/functions.inc.php");
require_once(dirname(__FILE__) . "/XmlSerializer.class.php");
* This is the main PHP file that process the HTTP parameters,
* performs the basic db operations (FIND, INSERT, UPDATE, DELETE)
* and then serialize the response in an XML format.
* XmlSerializer uses a PEAR xml parser to generate an xml response.
* this takes a php array and generates an xml according to the following rules:
* - the root tag name is called "response"
* - if the current value is a hash, generate a tagname with the key value, recurse inside
* - if the current value is an array, generated tags with the default value "row"
* for example, we have the following array:
* $arr = array(
* "data" => array(
* array("id_pol" => 1, "name_pol" => "name 1"),
* array("id_pol" => 2, "name_pol" => "name 2")
* "metadata" => array(
* "pageNum" => 1,
* "totalRows" => 345
* we will get an xml of the following form
* <?xml version="1.0" encoding="ISO-8859-1"?>
* <response>
* <data>
* <row>
* <id_pol>1</id_pol>
* <name_pol>name 1</name_pol>
* </row>
* <row>
* <id_pol>2</id_pol>
* <name_pol>name 2</name_pol>
* </row>
* </data>
* <metadata>
* <totalRows>345</totalRows>
* <pageNum>1</pageNum>
* </metadata>
* </response>
* Please notice that the generated server side code does not have any
* specific authentication mechanism in place.
* The filter field. This is the only field that we will do filtering after.
$filter_field = "subscriber_id";
* we need to escape the value, so we need to know what it is
* possible values: text, long, int, double, date, defined
$filter_type = "text";
* constructs and executes a sql select query against the selected database
* can take the following parameters:
* $_REQUEST["orderField"] - the field by which we do the ordering. MUST appear inside $fields.
* $_REQUEST["orderValue"] - ASC or DESC. If neither, the default value is ASC
* $_REQUEST["filter"] - the filter value
* $_REQUEST["pageNum"] - the page index
* $_REQUEST["pageSize"] - the page size (number of rows to return)
* if neither pageNum and pageSize appear, we do a full select, no limit
* returns : an array of the form
* array (
* data => array(
* array('field1' => "value1", "field2" => "value2")
* metadata => array(
* "pageNum" => page_index,
* "totalRows" => number_of_rows
function findAll() {
global $conn, $filter_field, $filter_type;
* the list of fields in the table. We need this to check that the sent value for the ordering is indeed correct.
$fields = array('id','subscriber_id','lastName','firstName','birthdate','gender');
$where = "";
if (@$_REQUEST['filter'] != "") {
$where = "WHERE " . $filter_field . " LIKE " . GetSQLValueStringForSelect(@$_REQUEST["filter"], $filter_type);
$order = "";
if (@$_REQUEST["orderField"] != "" && in_array(@$_REQUEST["orderField"], $fields)) {
$order = "ORDER BY " . @$_REQUEST["orderField"] . " " . (in_array(@$_REQUEST["orderDirection"], array("ASC", "DESC")) ? @$_REQUEST["orderDirection"] : "ASC");
//calculate the number of rows in this table
$rscount = mysql_query("SELECT count(*) AS cnt FROM `modelName` $where");
$row_rscount = mysql_fetch_assoc($rscount);
$totalrows = (int) $row_rscount["cnt"];
//get the page number, and the page size
$pageNum = (int)@$_REQUEST["pageNum"];
$pageSize = (int)@$_REQUEST["pageSize"];
//calculate the start row for the limit clause
$start = $pageNum * $pageSize;
//construct the query, using the where and order condition
$query_recordset = "SELECT id,subscriber_id,lastName,firstName,birthdate,gender FROM `modelName` $where $order";
//if we use pagination, add the limit clause
if ($pageNum >= 0 && $pageSize > 0) {
$query_recordset = sprintf("%s LIMIT %d, %d", $query_recordset, $start, $pageSize);
$recordset = mysql_query($query_recordset, $conn);
//if we have rows in the table, loop through them and fill the array
$toret = array();
while ($row_recordset = mysql_fetch_assoc($recordset)) {
array_push($toret, $row_recordset);
//create the standard response structure
$toret = array(
"data" => $toret,
"metadata" => array (
"totalRows" => $totalrows,
"pageNum" => $pageNum
return $toret;
* constructs and executes a sql count query against the selected database
* can take the following parameters:
* $_REQUEST["filter"] - the filter value
* returns : an array of the form
* array (
* data => number_of_rows,
* metadata => array()
function rowCount() {
global $conn, $filter_field, $filter_type;
$where = "";
if (@$_REQUEST['filter'] != "") {
$where = "WHERE " . $filter_field . " LIKE " . GetSQLValueStringForSelect(@$_REQUEST["filter"], $filter_type);
//calculate the number of rows in this table
$rscount = mysql_query("SELECT count(*) AS cnt FROM `modelName` $where");
$row_rscount = mysql_fetch_assoc($rscount);
$totalrows = (int) $row_rscount["cnt"];
//create the standard response structure
$toret = array(
"data" => $totalrows,
"metadata" => array()
return $toret;Hi there,
I have a php script that accesses a mySQL database and it was generated out of the Flex Builder wizard automatically. The script works great and there are no problems with it. It allows me to perform CRUD on a table by calling it from my Flex app. and it retrieves all the data and puts it into a nice MXML format.
My question, currently when I call "findAll" to retrieve all the data in the table, well, it retrieves ALL the rows in the table. That's fine, but my table is starting to grow really large with thousands of rows.
I want to modify this script so that I can pass a variable into it from Flex so that it only retrieves the rows that match the "$subscriber_id" variable that I pass. In this way the results are not the entire table's data, only the rows that match 'subscriber_id'.
I know how to pass a variable from Flex into php and the code on the php side to pick it up would look like this:
$subscriberID = $_POST['subscriberID'];
Can anyone shed light as to the proper code modification in "findAll" which will take my $subscriberID variable and compare it to the 'subscriber_id' field and then only return those rows that match? I think it has something to do with lines 98 to 101.
Any help is appreciated.
<?php
require_once(dirname(__FILE__) . "/2257safeDBconn.php");
require_once(dirname(__FILE__) . "/functions.inc.php");
require_once(dirname(__FILE__) . "/XmlSerializer.class.php");
* This is the main PHP file that process the HTTP parameters,
* performs the basic db operations (FIND, INSERT, UPDATE, DELETE)
* and then serialize the response in an XML format.
* XmlSerializer uses a PEAR xml parser to generate an xml response.
* this takes a php array and generates an xml according to the following rules:
* - the root tag name is called "response"
* - if the current value is a hash, generate a tagname with the key value, recurse inside
* - if the current value is an array, generated tags with the default value "row"
* for example, we have the following array:
* $arr = array(
* "data" => array(
* array("id_pol" => 1, "name_pol" => "name 1"),
* array("id_pol" => 2, "name_pol" => "name 2")
* "metadata" => array(
* "pageNum" => 1,
* "totalRows" => 345
* we will get an xml of the following form
* <?xml version="1.0" encoding="ISO-8859-1"?>
* <response>
* <data>
* <row>
* <id_pol>1</id_pol>
* <name_pol>name 1</name_pol>
* </row>
* <row>
* <id_pol>2</id_pol>
* <name_pol>name 2</name_pol>
* </row>
* </data>
* <metadata>
* <totalRows>345</totalRows>
* <pageNum>1</pageNum>
* </metadata>
* </response>
* Please notice that the generated server side code does not have any
* specific authentication mechanism in place.
* The filter field. This is the only field that we will do filtering after.
$filter_field = "subscriber_id";
* we need to escape the value, so we need to know what it is
* possible values: text, long, int, double, date, defined
$filter_type = "text";
* constructs and executes a sql select query against the selected database
* can take the following parameters:
* $_REQUEST["orderField"] - the field by which we do the ordering. MUST appear inside $fields.
* $_REQUEST["orderValue"] - ASC or DESC. If neither, the default value is ASC
* $_REQUEST["filter"] - the filter value
* $_REQUEST["pageNum"] - the page index
* $_REQUEST["pageSize"] - the page size (number of rows to return)
* if neither pageNum and pageSize appear, we do a full select, no limit
* returns : an array of the form
* array (
* data => array(
* array('field1' => "value1", "field2" => "value2")
* metadata => array(
* "pageNum" => page_index,
* "totalRows" => number_of_rows
function findAll() {
global $conn, $filter_field, $filter_type;
* the list of fields in the table. We need this to check that the sent value for the ordering is indeed correct.
$fields = array('id','subscriber_id','lastName','firstName','birthdate','gender');
$where = "";
if (@$_REQUEST['filter'] != "") {
$where = "WHERE " . $filter_field . " LIKE " . GetSQLValueStringForSelect(@$_REQUEST["filter"], $filter_type);
$order = "";
if (@$_REQUEST["orderField"] != "" && in_array(@$_REQUEST["orderField"], $fields)) {
$order = "ORDER BY " . @$_REQUEST["orderField"] . " " . (in_array(@$_REQUEST["orderDirection"], array("ASC", "DESC")) ? @$_REQUEST["orderDirection"] : "ASC");
//calculate the number of rows in this table
$rscount = mysql_query("SELECT count(*) AS cnt FROM `modelName` $where");
$row_rscount = mysql_fetch_assoc($rscount);
$totalrows = (int) $row_rscount["cnt"];
//get the page number, and the page size
$pageNum = (int)@$_REQUEST["pageNum"];
$pageSize = (int)@$_REQUEST["pageSize"];
//calculate the start row for the limit clause
$start = $pageNum * $pageSize;
//construct the query, using the where and order condition
$query_recordset = "SELECT id,subscriber_id,lastName,firstName,birthdate,gender FROM `modelName` $where $order";
//if we use pagination, add the limit clause
if ($pageNum >= 0 && $pageSize > 0) {
$query_recordset = sprintf("%s LIMIT %d, %d", $query_recordset, $start, $pageSize);
$recordset = mysql_query($query_recordset, $conn);
//if we have rows in the table, loop through them and fill the array
$toret = array();
while ($row_recordset = mysql_fetch_assoc($recordset)) {
array_push($toret, $row_recordset);
//create the standard response structure
$toret = array(
"data" => $toret,
"metadata" => array (
"totalRows" => $totalrows,
"pageNum" => $pageNum
return $toret;
* constructs and executes a sql count query against the selected database
* can take the following parameters:
* $_REQUEST["filter"] - the filter value
* returns : an array of the form
* array (
* data => number_of_rows,
* metadata => array()
function rowCount() {
global $conn, $filter_field, $filter_type;
$where = "";
if (@$_REQUEST['filter'] != "") {
$where = "WHERE " . $filter_field . " LIKE " . GetSQLValueStringForSelect(@$_REQUEST["filter"], $filter_type);
//calculate the number of rows in this table
$rscount = mysql_query("SELECT count(*) AS cnt FROM `modelName` $where");
$row_rscount = mysql_fetch_assoc($rscount);
$totalrows = (int) $row_rscount["cnt"];
//create the standard response structure
$toret = array(
"data" => $totalrows,
"metadata" => array()
return $toret; -
How can I modify this to process 80,000 records at a time until finish.
Hello it's me again -
Without using a rownum limit in my cursor declare my record-set is around 10 million records. This causes problems within our environment. Is there a way I can loop the following code and only do 80,000 at a time.
1 process 80,000
2. process next 80,000.
How would I redeclare the cursor in a loop and grab the next 80,000?
Thanks again
Steve
SET SERVEROUTPUT ON
DECLARE
CURSOR vt_mlr_cursor IS Select master_key, tn, user2 from vt_mlr Where user2 is not null and rownum < 80001;
USERFIELD VARCHAR2(100);
R_count NUMBER := 0;
Field1 VARCHAR2(20);
Field2 VARCHAR2(20);
key VARCHAR2(10);
phone VARCHAR2(11);
BEGIN
FOR vt_mlr_record IN vt_mlr_cursor
LOOP
BEGIN
key := vt_mlr_record.master_key;
phone := vt_mlr_record.tn;
USERFIELD := vt_mlr_record.user2;
Field1 := SUBSTR(vt_mlr_record.user2,12,4);
Field2 := SUBSTR(vt_mlr_record.user2,28,4);
UPDATE vt_mlr
SET
line_medr = Field1,
line_aidr = Field2
WHERE
master_key = vt_mlr_record.master_key;
R_count := R_count + 1;
EXCEPTION
when others then
Insert into temp_reject (REJECT_KEY, REJECT_TN, REJECT_VALUE) VALUES
(key, phone, 'USER2 ' || USERFIELD );
R_count := R_count - 1;
END;
END LOOP;
commit;
EXCEPTION
when others then
DBMS_OUTPUT.PUT_LINE('Error code ' || sqlcode || ' Error desc' || SUBSTR(sqlerrm,1,200));
END;Add a "last_update" or "modified" column to your table.
Then do this:
declare
CURSOR vt_mlr_cursor IS
select master_key, tn, user2
from vt_mlr
where user2 is not null and rownum < 80001
and modified != 'Y'
(or)
and last_update < begin_date ;
begin_date constant date := sysdate ;
begin
update vt_mlr
set line_medr = Field1,
line_aidr = Field2,
modified = 'Y'
(or)
last_update = sysdate -
How can I simplify this code?
Here's some code I am working on for my CompScience class. If any of you more advanced java users can assist me in simpliying this code, it will be much appreciated. Thanks
import javax.swing.JOptionPane;
public class lab09b
public static void main (String args[])
String str;
int num = 1, den = 1; //Initializes variables for use.
Rational2 r3 = new Rational2 (num,den); //Creates new Rational2 object to be used for math operations.
str = JOptionPane.showInputDialog("Enter Numerator 1:");
num = Integer.parseInt(str);
str = JOptionPane.showInputDialog("Enter Denominator 1:");
den = Integer.parseInt(str);
Rational1 rA = new Rational1 (num,den); //Creates object to store original input of fraction 1.
Rational2 r1 = new Rational2 (num,den); //Creates object to store reduced input of fraction 1.
str = JOptionPane.showInputDialog("Enter Numerator 2:");
num = Integer.parseInt(str);
str = JOptionPane.showInputDialog("Enter Denominator 2:");
den = Integer.parseInt(str);
Rational1 rB = new Rational1 (num,den); //Creates object to store original input of fraction 2.
Rational2 r2 = new Rational2 (num,den); //Creates object to store reduced input of fraction 1.
r3.add(r1,r2);
JOptionPane.showMessageDialog(null,rA.getOriginal()+"+"+rB.getOriginal()+"="+r3.getRational()); //Outputs results of addition
r3.multiply(r1,r2);
JOptionPane.showMessageDialog(null,rA.getOriginal()+"*"+rB.getOriginal()+"="+r3.getRational()); //Outputs results of multiplication.
System.exit(0);
class Rational1
protected int num; // Entered numerator.
protected int den; // Entered denominator.
private int getGCF(int n1,int n2) //Method for reduction.
int rem = 0;
int gcf = 0;
do
rem = n1 % n2;
if (rem == 0)
gcf = n2;
else
n1 = n2;
n2 = rem;
while (rem != 0);
return gcf;
public void reduce() //Modifies fraction to a equivalent simplified rational.
int gcf = getGCF(num,den);
num = num / gcf;
den = den / gcf;
public Rational1(int n, int d) //Constructs Rational1 without reducing it.
num = n;
if (d == 0)
System.out.println("Illegal denominator; altered to 1");
den = 1;
else
den = d;
public int getNum() //Returns Numerator.
return num;
public int getDen() //Returns Denominator.
return den;
public String getOriginal() //Returns Original Fraction.
return ""+num+"/"+den;
class Rational2 extends Rational1 //Class used to modify fractions.
public Rational2(int n, int d) //Constructs Rational2 using superclass constructor.
super(n,d);
public String getRational() //Returns the reduced fraction version.
super.reduce();
return ""+num+"/"+den;
public void add(Rational2 r1, Rational2 r2) //Adds two rationals together.
den = r1.getDen() * r2.getDen();
num = r1.getNum() * r2.getDen() + r2.getNum() * r1.getDen();
public void multiply(Rational2 r1, Rational2 r2) //Multiplies two rationals.
den = r1.getDen() * r2.getDen();
num = r1.getNum() * r2.getNum();
}seems simple enough to me.... you want complicated code... I could find you some good complicated code, and you'll look at yours and say, wow, this is pretty simple.
What part are you expecting to simplify?
Does it compile? Does it run? Does it do what you expect it to do? -
How can I get this code to display 20 lines
I need to get this code I have written to display 20 lines at a time, then the 20 using the Enter key.
How would I approach this?
I thought of making a RandomAcessFile object, but that seems like overthinking the problem, and I'm not sure that I could get that to work anyway.
import java.io.*;
public class ReadIt
public static void main(String[] args)
throws IOException
System.out.println ("Enter The Desired .java Filename.");
System.out.println ("Do not add the .java extention.");
String fname;
EasyIn type = new EasyIn();
fname = type.readString();
String fndotjava = new String(fname + ".java");
//System.out.println (fndotjava);
File inFile = new File(fndotjava);
InputStream istream;
OutputStream ostream;
istream = new FileInputStream(inFile);
ostream = System.out;
int c;
try
while((c = istream.read()) != -1)
ostream.write(c);
catch(IOException e)
System.out.println("Error: " + e.getMessage());
finally
istream.close();
ostream.close();
}Thanks
BradWell, a RandomAccessFile together with a counter should work. However, you can also achieve this by buffering the input rather than writing it directly out
java.util.Vector vect = new java.util.Vector();
try{
while((c = istream.read()) != -1){
vect.append(c);
catch(IOException e){
System.out.println("Error: " + e.getMessage());
finally{
istream.close();
} with the help of
java.util.Vector.size() and
java.util.Vector.elementAt(int index)
you are able to display only 20 lines at a time, you just need the additional code for reading System.in
public static void prompt(String s){
System.out.print(s + " ");
System.out.flush();
public static String readData ( BufferedReader in) {
boolean verfuegbar = true;
while ( verfuegbar){
try{
S = in.readLine();
if ( S != null)verfuegbar = false ;
catch (IOException e){System.out.print (e);}
return S;
}now it should work with
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
prompt("return for continuing");
int twentscount = 0;
int count = 0;
do{
while( count < 20 && twentscount+count < vect.size() ){
outstream.write(vect.elementAt(twentscount + count).toString() );
count++;
prompt("return");
readData(in);
twentscount += 20;
count = 0;
while(twentscount + count < vect.size());sure, this is code from head, and you can make many changes (e.g. instead of using twentscount use the modulo (%) operator saving one variable (while count % 20 != 0 ).
I'm also not sure if it will definitly run , since i haven't tested it (especialy for index borders).
I hope this will give you enough hints for this possible solution.
Adrian -
How can I modify this makefile to create proper ARMV7 dylibs?
I need to modify this makefile in order to create proper dylibs for inclusion in my IOS projects. If I just using the dylibs generated without changing this file, I get this error trying to use the dylibs:
ld: warning: ld: warning: ignoring file Undefined symbols for architecture armv7s:
"_mongo_connect", referenced from:
-[ViewController viewDidLoad] in ViewController.o
libbson.dylib, file was built for unsupported file format
( 0xcf 0xfa 0xed 0xfe 0x 7 0x 0 0x 0 0x 1 0x 3 0x 0 0x 0 0x 0 0x 6 0x 0 0x 0 0x 0 ) which is not the architecture being linked (armv7s):
Undefined symbols for architecture armv7s:
"_mongo_connect", referenced from:
-[ViewController viewDidLoad] in ViewController.o
libbson.dylibignoring file
Undefined symbols for architecture armv7s:
"_mongo_connect", referenced from:
-[ViewController viewDidLoad] in ViewController.o
libmongoc.dylib, file was built for unsupported file format
( 0xcf 0xfa 0xed 0xfe 0x 7 0x 0 0x 0 0x 1 0x 3 0x 0 0x 0 0x 0 0x 6 0x 0 0x 0 0x 0 ) which is not the architecture being linked (armv7s):
Undefined symbols for architecture armv7s:
"_mongo_connect", referenced from:
-[ViewController viewDidLoad] in ViewController.o
libmongoc.dylib
Undefined symbols for architecture armv7s:
"_mongo_connect", referenced from:
-[ViewController viewDidLoad] in ViewController.o
The makefile:
# MongoDB C Driver Makefile
# Copyright 2009, 2010 10gen Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Version
MONGO_MAJOR=0
MONGO_MINOR=6
MONGO_PATCH=0
BSON_MAJOR=$(MONGO_MAJOR)
BSON_MINOR=$(MONGO_MINOR)
BSON_PATCH=$(MONGO_PATCH)
# Library names
MONGO_LIBNAME=libmongoc
BSON_LIBNAME=libbson
# Standard or posix env.
ENV?=posix
# TODO: add replica set test, cpp test, platform tests, json_test
TESTS=test_auth test_bcon test_bson test_bson_subobject test_count_delete \
test_cursors test_endian_swap test_errors test_examples \
test_functions test_gridfs test_helpers \
test_oid test_resize test_simple test_sizes test_update \
test_validate test_write_concern test_commands
MONGO_OBJECTS=src/bcon.o src/bson.o src/encoding.o src/gridfs.o src/md5.o src/mongo.o \
src/numbers.o
BSON_OBJECTS=src/bcon.o src/bson.o src/numbers.o src/encoding.o
ifeq ($(ENV),posix)
TESTS+=test_env_posix test_unix_socket
MONGO_OBJECTS+=src/env_posix.o
else
MONGO_OBJECTS+=src/env_standard.o
endif
DYN_MONGO_OBJECTS=$(foreach i,$(MONGO_OBJECTS),$(patsubst %.o,%.os,$(i)))
DYN_BSON_OBJECTS=$(foreach i,$(BSON_OBJECTS),$(patsubst %.o,%.os,$(i)))
# Compile flags
ALL_DEFINES=$(DEFINES)
ALL_DEFINES+=-D_POSIX_SOURCE
CC:=$(shell sh -c 'type $(CC) >/dev/null 2>/dev/null && echo $(CC) || echo gcc')
DYN_FLAGS:=-fPIC -DMONGO_DLL_BUILD
# Endianness check
endian := $(shell sh -c 'echo "ab" | od -x | grep "6261" >/dev/null && echo little || echo big')
ifeq ($(endian),big)
ALL_DEFINES+=-DMONGO_BIG_ENDIAN
endif
# Int64 type check
int64:=$(shell ./check_int64.sh $(CC) stdint.h && echo stdint)
ifeq ($(int64),stdint)
ALL_DEFINES+=-DMONGO_HAVE_STDINT
else
int64:=$(shell ./check_int64.sh $(CC) unistd.h && echo unistd)
ifeq ($(int64),unistd)
ALL_DEFINES+=-DMONGO_HAVE_UNISTD
endif
endif
$(shell rm header_check.tmp tmp.c)
TEST_DEFINES=$(ALL_DEFINES)
TEST_DEFINES+=-DTEST_SERVER="\"127.0.0.1\""
OPTIMIZATION?=-O3
WARNINGS?=-Wall
DEBUG?=-ggdb
STD?=c99
PEDANTIC?=-pedantic
ALL_CFLAGS=-std=$(STD) $(PEDANTIC) $(CFLAGS) $(OPTIMIZATION) $(WARNINGS) $(DEBUG) $(ALL_DEFINES)
ALL_LDFLAGS=$(LDFLAGS)
# Shared libraries
DYLIBSUFFIX=so
STLIBSUFFIX=a
MONGO_DYLIBNAME=$(MONGO_LIBNAME).$(DYLIBSUFFIX)
MONGO_DYLIB_MAJOR_NAME=$(MONGO_DYLIBNAME).$(MONGO_MAJOR)
MONGO_DYLIB_MINOR_NAME=$(MONGO_DYLIB_MAJOR_NAME).$(MONGO_MINOR)
MONGO_DYLIB_PATCH_NAME=$(MONGO_DYLIB_MINOR_NAME).$(MONGO_PATCH)
MONGO_DYLIB_MAKE_CMD=$(CC) -shared -Wl,-soname,$(MONGO_DYLIB_MINOR_NAME) -o $(MONGO_DYLIBNAME) $(ALL_LDFLAGS) $(DYN_MONGO_OBJECTS)
BSON_DYLIBNAME=$(BSON_LIBNAME).$(DYLIBSUFFIX)
BSON_DYLIB_MAJOR_NAME=$(BSON_DYLIBNAME).$(BSON_MAJOR)
BSON_DYLIB_MINOR_NAME=$(BSON_DYLIB_MAJOR_NAME).$(BSON_MINOR)
BSON_DYLIB_PATCH_NAME=$(BSON_DYLIB_MINOR_NAME).$(BSON_PATCH)
BSON_DYLIB_MAKE_CMD=$(CC) -shared -Wl,-soname,$(BSON_DYLIB_MINOR_NAME) -o $(BSON_DYLIBNAME) $(ALL_LDFLAGS) $(DYN_BSON_OBJECTS)
# Static libraries
MONGO_STLIBNAME=$(MONGO_LIBNAME).$(STLIBSUFFIX)
BSON_STLIBNAME=$(BSON_LIBNAME).$(STLIBSUFFIX)
# Overrides
kernel_name := $(shell sh -c 'uname -s 2>/dev/null || echo not')
ifeq ($(kernel_name),SunOS)
ALL_LDFLAGS+=-ldl -lnsl -lsocket
INSTALL_CMD=cp -r
MONGO_DYLIB_MAKE_CMD=$(CC) -G -o $(MONGO_DYLIBNAME) -h $(MONGO_DYLIB_MINOR_NAME) $(ALL_LDFLAGS)
BSON_DYLIB_MAKE_CMD=$(CC) -G -o $(BSON_DYLIBNAME) -h $(BSON_DYLIB_MINOR_NAME) $(ALL_LDFLAGS)
endif
ifeq ($(kernel_name),Darwin)
ALL_CFLAGS+=-std=$(STD) $(CFLAGS) $(OPTIMIZATION) $(WARNINGS) $(DEBUG) $(ALL_DEFINES)
DYLIBSUFFIX=dylib
MONGO_DYLIB_MINOR_NAME=$(MONGO_LIBNAME).$(DYLIBSUFFIX).$(MONGO_MAJOR).$(MONGO_M INOR)
MONGO_DYLIB_MAJOR_NAME=$(MONGO_LIBNAME).$(DYLIBSUFFIX).$(MONGO_MAJOR)
MONGO_DYLIB_MAKE_CMD=$(CC) -shared -Wl,-install_name,$(MONGO_DYLIB_MINOR_NAME) -o $(MONGO_DYLIBNAME) $(ALL_LDFLAGS) $(DYN_MONGO_OBJECTS)
BSON_DYLIB_MINOR_NAME=$(BSON_LIBNAME).$(DYLIBSUFFIX).$(BSON_MAJOR).$(BSON_MINOR )
BSON_DYLIB_MAJOR_NAME=$(BSON_LIBNAME).$(DYLIBSUFFIX).$(BSON_MAJOR)
BSON_DYLIB_MAKE_CMD=$(CC) -shared -Wl,-install_name,$(BSON_DYLIB_MINOR_NAME) -o $(BSON_DYLIBNAME) $(ALL_LDFLAGS) $(DYN_BSON_OBJECTS)
endif
# Installation
ifeq ($(kernel_name),SunOS)
INSTALL?=cp -r
endif
INSTALL?= cp -a
INSTALL_INCLUDE_PATH?=/usr/local/include
INSTALL_LIBRARY_PATH?=/usr/local/lib
# TARGETS
all: $(MONGO_DYLIBNAME) $(BSON_DYLIBNAME) $(MONGO_STLIBNAME) $(BSON_STLIBNAME)
# Dependency targets. Run 'make deps' to generate these.
bcon.o: src/bcon.c src/bcon.h src/bson.h
bson.o: src/bson.c src/bson.h src/encoding.h
encoding.o: src/encoding.c src/bson.h src/encoding.h
env_standard.o: src/env_standard.c src/env.h src/mongo.h src/bson.h
env_posix.o: src/env_posix.c src/env.h src/mongo.h src/bson.h
gridfs.o: src/gridfs.c src/gridfs.h src/mongo.h src/bson.h
md5.o: src/md5.c src/md5.h
mongo.o: src/mongo.c src/mongo.h src/bson.h src/md5.h src/env.h
numbers.o: src/numbers.c
$(MONGO_DYLIBNAME): $(DYN_MONGO_OBJECTS)
$(MONGO_DYLIB_MAKE_CMD)
$(MONGO_STLIBNAME): $(MONGO_OBJECTS)
$(AR) -rs $@ $(MONGO_OBJECTS)
$(BSON_DYLIBNAME): $(DYN_BSON_OBJECTS)
$(BSON_DYLIB_MAKE_CMD)
$(BSON_STLIBNAME): $(BSON_OBJECTS)
$(AR) -rs $@ $(BSON_OBJECTS)
install:
mkdir -p $(INSTALL_INCLUDE_PATH) $(INSTALL_LIBRARY_PATH)
$(INSTALL) src/mongo.h src/bson.h $(INSTALL_INCLUDE_PATH)
$(INSTALL) $(MONGO_DYLIBNAME) $(INSTALL_LIBRARY_PATH)/$(MONGO_DYLIB_PATCH_NAME)
$(INSTALL) $(BSON_DYLIBNAME) $(INSTALL_LIBRARY_PATH)/$(BSON_DYLIB_PATCH_NAME)
cd $(INSTALL_LIBRARY_PATH) && ln -sf $(MONGO_DYLIB_PATCH_NAME) $(MONGO_DYLIB_MINOR_NAME)
cd $(INSTALL_LIBRARY_PATH) && ln -sf $(BSON_DYLIB_PATCH_NAME) $(BSON_DYLIB_MINOR_NAME)
cd $(INSTALL_LIBRARY_PATH) && ln -sf $(MONGO_DYLIB_MINOR_NAME) $(MONGO_DYLIBNAME)
cd $(INSTALL_LIBRARY_PATH) && ln -sf $(BSON_DYLIB_MINOR_NAME) $(BSON_DYLIBNAME)
$(INSTALL) $(MONGO_STLIBNAME) $(INSTALL_LIBRARY_PATH)
$(INSTALL) $(BSON_STLIBNAME) $(INSTALL_LIBRARY_PATH)
scan-build: clean
scan-build -V -v make
test: $(TESTS)
sh runtests.sh
valgrind: $(TESTS)
sh runtests.sh -v
docs:
python docs/buildscripts/docs.py
clean:
rm -rf src/*.o src/*.os test/*.o test/*.os test_* .scon* config.log
clobber: clean
rm -rf $(MONGO_DYLIBNAME) $(MONGO_STLIBNAME) $(BSON_DYLIBNAME) $(BSON_STLIBNAME) docs/html docs/source/doxygen
deps:
$(CC) -MM -DMONGO_HAVE_STDINT src/*.c
32bit:
$(MAKE) CFLAGS="-m32" LDFLAGS="-pg"
test_%: test/%_test.c test/test.h $(MONGO_STLIBNAME)
$(CC) -o $@ -L. -Isrc $(TEST_DEFINES) $(ALL_LDFLAGS) $< $(MONGO_STLIBNAME)
%.o: %.c
$(CC) -o $@ -c $(ALL_CFLAGS) $<
%.os: %.c
$(CC) -o $@ -c $(ALL_CFLAGS) $(DYN_FLAGS) $<
.PHONY: 32bit all clean clobber deps docs install test valgrindHi Petar,
Thanks for your answer. No doubt that we could solve the issue using on of the way you suggested.
However, even though I had the evdre issue right after applying time dimension modifications, it occurs that the evdre issue was not due to time dimension modifications. I tested it better and I can tell that using "total" as a level works.
Best regards,
Ludovic -
How can I use this code in Muse?
Please, tell me with details how to paste this code, which the "add this" widget on Muse to appear...
<!-- AddThis Smart Layers BEGIN -->
<!-- Go to http://www.addthis.com/get/smart-layers to customize -->
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-538d2f0f4872fcfe"></script>
<script type="text/javascript">
addthis.layers({
'theme' : 'transparent',
'follow' : {
'services' : [
{'service': 'facebook', 'id': 'africa.si.zgz'},
{'service': 'twitter', 'id': 'Africa_Si'},
{'service': 'google_follow', 'id': 'u/0/b/103262715708033329485/103262715708033329485/posts'},
{'service': 'linkedin', 'id': 'África-sí', 'usertype': 'company'},
{'service': 'youtube', 'id': 'africasizgz'}
'whatsnext' : {}
</script>
<!-- AddThis Smart Layers END -->
Thank you!Thank you, but I still have a problem.... When a copy it directly on Muse through "ctrl + v" I see the whole code as text on Muse and when I paste it thorugh object--> Insert HTML Muse says that they "couldn't generate de miniature", do you know what I'm doing wrong?
Thank you! -
How can I fix this code ?
hello,
I have a small problem with this code:
#include <fstream>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <string>
#include <vector>
using namespace std;
int main()
string from, to;
cin >> from >> to;
ifstream is(from.c_str());
istream_iterator<string> ii(is);
istream_iterator<string> eos;
// line 24: Error:
vector<string> b(ii, eos); // line 24: Error:
sort(b.begin(), b.end());
ofstream os(to.c_str());
ostream_iterator<string> oo(os, "\n");
unique_copy(b.begin(), b.end(), oo);
return !is.eof() && !os;
return 0;
}When I compile this happens
bash-2.05$ CC -V
CC: Sun C++ 5.6 2004/06/02
bash-2.05$ CC -o std_vector.out std_vector.cpp
"std_vector.cpp", line 24: Error:
Could not find a match for
std::vector<std::string>::vector(std::istream_iterator<std::string, char, std::char_traits<char>, int>, std::istream_iterator<std::string, char, std::char_traits<char>, int>)needed in main().
1 Error(s) detected.
What can I do ?
best regards
Morten GulbrandsenYou have run into a documented limitation of the default libCstd implementation of the C++ standard library. The default library is not a complete implementation, and in particular lacks required template member functions that allow implicit type conversions. We still use this library for binary compatibility with earlier releases.
The optional STLport version of the library is a full implementation of hte C++ Standard Library. If you don't need binary compatibility, meaning you don't need to link to code that uses libCstd, you can add the option -library=stlport4 to every CC command line, compiling and linking. Your sample code compiles with STLport.
If you need to use libCstd, you might get this code to work by inserting explicit type conversions. I have not tried to see whether that actually can be done. -
i have tried to rewrite this code but keep getting errors. ive read loads of tutorials on actionperformed and mouseclicked i just need som1 to point me in the right direction
heres the code
public boolean mouseUp(Event e, int x, int y){
if (y == 0)
swit = true;
return true;
//else
if (pics[getMC(x,y)].getID() > rw*col/2){
return true;}
if (0 == track)
card1 = pics[getMC(x,y)];
start = new Date();
etime.start();
track = 2;
stat = "pic again";
repaint();
return true;
if (1 == track){
card1 = pics[getMC(x,y)];
track = 2;
stat = "pick again";
repaint();
return true;
else if (2 == track)
if (card1 == pics[getMC(x,y)]) return true;
card2 = pics[getMC(x,y)];
track = 3;
attempts++;
if (card1.getID() == card2.getID())
stat = "well done";
matched++;
if (rw*col/2 == matched)
stat = "finished";
etime = null;
else
stat = "Try Again";
repaint();
return true;
else
return false;
}Hi,
Do you want your code to listen to different Mouse events? and what other events?
ex:
copy the content of the below link and run the application
http://java.sun.com/docs/books/tutorial/uiswing/examples/events/MouseEventDemoProject/src/events/MouseEventDemo.java
http://java.sun.com/docs/books/tutorial/uiswing/examples/events/MouseEventDemoProject/src/events/BlankArea.java
If you have any problem with the code; please let us know
Regards,
Alan Mehio
London,UK
Maybe you are looking for
-
Error,while importing METADATA from production to development
Folks, I am getting the following error while importing the metadata. I have exported from production server and want to do some modification to the existing mappings. Can some body help me to resolve this? Here is the error. Import started at 10/07/
-
Hey Everyone, I already own a 2012 Mac Pro Desktop. I do some pretty advanced video editing on it, using FCPX and After Effects, with FXFactory and many other plugins. I need to invest in a MacBook Pro so I can transfer my projects and edit at differ
-
How do I create this window effect?
I was looking at this photo http://image.shutterstock.com/display_pic_with_logo/442024/442024,1297015560,3/stock-vecto r-download-button-set-vector-set-for-web-70603081.jpg trying to figure out how they get the little window to appear like that. I ca
-
OAS's application migrates 4.0.8 to the OAS 10G
I am trying to migrate an application that runs in 4.0.8 to the OAS 10G, and i want to know if you know if some procedure for best practice for do this.
-
According to iTunes, I have 5,15GB of songs in my library. However, iTunes won't allow me to sync them to my iPod touch 8GB, saying I need to clear 3 GB. How do I solve this problem?