Need help with loop cursor
Hi,
I'm doing a data conversion and am fairly new to PL/SQL.
I have a cursor and in the loop i have a select statement
which returns ORA-01403(no data found). I need to skip this
row in the cursor and continue with the next.
BEGIN
OPEN cur_fill_split;
LOOP
FETCH cur_fill_split into S_ASR,S_CLIENT_NO, S_DIRCODE, S_SPLIT_RATE, I_WAYS,
S_BRANCH_NUMBER, S_BRANCH_NAME, S_DIV_NUMBER, S_DIV_NAME, S_ITEMCODE, S_LINE;
EXIT WHEN cur_fill_split%NOTFOUND;
select order_number INTO N_ORDER_NUMBER from order_header
where cmr_number||client_number||dir_number = s_asr||s_client_no||s_dircode;
SELECT SEQ INTO I_SEQ FROM ORDER_DETAIL
WHERE ORDER_NUMBER = N_ORDER_NUMBER
AND LINE_ORDER_NUMBER = TO_NUMBER(S_LINE);
********(errors on the above select)********
END LOOP;
CLOSE cur_fill_split;
END;
Thanks,
Brian
Hi,
I think there r 2 methods, one is by giving begin - end inside the loop as shown below 1st ex:
& the 2nd method is by selecting the record count & then based on that value executing further commands.
I think 2nd method is more safer than the 1st method.
Method 1:
1)
-- ---------------Procedure Begin------------------
BEGIN
OPEN cur_fill_split;
LOOP
FETCH cur_fill_split into S_ASR,S_CLIENT_NO, S_DIRCODE, S_SPLIT_RATE, I_WAYS,
S_BRANCH_NUMBER, S_BRANCH_NAME, S_DIV_NUMBER, S_DIV_NAME, S_ITEMCODE, S_LINE;
EXIT WHEN cur_fill_split%NOTFOUND;
select order_number INTO N_ORDER_NUMBER from order_header
where cmr_number||client_number||dir_number = s_asr||s_client_no||s_dircode;
BEGIN
SELECT SEQ INTO I_SEQ FROM ORDER_DETAIL
WHERE ORDER_NUMBER = N_ORDER_NUMBER
AND LINE_ORDER_NUMBER = TO_NUMBER(S_LINE);
EXCEPTION
WHEN NO_DATA_FOUND THEN
NULL;
END;
END LOOP;
CLOSE cur_fill_split;
END;
-- ---------------Procedure End------------------
Method 2)
By selecting the record count & based on that records, deciding the program control.
-- ---------------Procedure Begin------------------
declare
rec_cnt number := 0;
BEGIN
OPEN cur_fill_split;
LOOP
FETCH cur_fill_split into S_ASR,S_CLIENT_NO, S_DIRCODE, S_SPLIT_RATE, I_WAYS,
S_BRANCH_NUMBER, S_BRANCH_NAME, S_DIV_NUMBER, S_DIV_NAME, S_ITEMCODE, S_LINE;
EXIT WHEN cur_fill_split%NOTFOUND;
select order_number INTO N_ORDER_NUMBER from order_header
where cmr_number||client_number||dir_number = s_asr||s_client_no||s_dircode;
/* Here we are using cnt variable & checking for
the record count, if count = 0, then it will skip */
select count(*) into rec_cnt from ORDER_DETAIL
WHERE ORDER_NUMBER = N_ORDER_NUMBER
AND LINE_ORDER_NUMBER = TO_NUMBER(S_LINE);
if rec_cnt > 0 then
SELECT SEQ INTO I_SEQ FROM ORDER_DETAIL
WHERE ORDER_NUMBER = N_ORDER_NUMBER
AND LINE_ORDER_NUMBER = TO_NUMBER(S_LINE);
end if;
END LOOP;
CLOSE cur_fill_split;
END;
-- ---------------Procedure End------------------
Try it out & mail me
Good luck
Similar Messages
-
Hello everyone this is my first time posting here, i have always find java easy(up to this point), this is my first class in programming java i am just needing help with the "for loops" i cant seem to get the program generate 10 random math questions. if you guys can please help i will appreciate it, i have been working on it for a couple of hours. I am not finished with it yet but thats the only thing i need help with.
import javax.swing.JOptionPane;
public class Lab5
public static void main(String[] args)
int num1 = (int) (Math.random() * 100 + 1);
int num2 = (int) (Math.random() * 100 + 1);
int sum = num1 + num2;
int product = num1 * num2;
int quotient = num1 / num2;
int difference = num1 - num2;
for (int i = 0; i > 11; i++);
int number = (int)(Math.random()*4);
if (number == 0 )
String s1 = JOptionPane.showInputDialog(null, num1 + " + " + num2 + "=" );
if(number == 1)
String s3 = JOptionPane.showInputDialog(null, num1 + " - " + num2 + "=" );
if(number == 2)
String s3 = JOptionPane.showInputDialog(null, num1 + " x " + num2 + "=" );
if(number == 3)
String s4 = JOptionPane.showInputDialog(null, num1 + " ÷ " + num2 + "=" );for (int i = 0; i > 11; i++);Two problems with this line:
1) The second part of a For loop is the constraint. You have said that for the loop to be entered, i must be greater than 11. Well since you've also told i to begin at 0, this will never happen. Thus, the loop will never enter. You may have meant less than?
2) You put a semicolon in the line. Semicolons are used to end statements. The For loop, when used as a block with curly braces, is not a single statement and does not require a semicolon. Here's the two structures of a basic For loop:
for(int i = 0; i <= 100; i++) {
//this is a block. you can put multiple statements in here and they are all part of the loop
int a = 1;
int b = i;
//if your loop only needs to use a single statement, no braces are required
for(int i = 0; i <= 100; i++)
int a = i; -
Need help with **** Invalid Cursor State ****
Hi,
can someone tell me why am i getting this error....
//******java.sql.SQLException: [Microsoft][ODBC Driver Manager] Invalid cursor state
Any help is greatly appreciated.....
Thanks in advance.
//***********this is the output on servlet side**************//
Starting service Tomcat-Standalone
Apache Tomcat/4.0.3
Starting service Tomcat-Apache
Apache Tomcat/4.0.3
init
DBServlet init: Start
DataAccessor init: Start
Accessor init: Loading Database Driver: sun.jdbc.odbc.JdbcOdbcDriver
DataAccessor init: Getting a connection to - jdbc:odbc:SCANODBC
username SYSDBA
password masterkey
DataAccessor init: Preparing searchPolicy
DataAccessor init: Prepared policySearch
DataAccessor init: Prepared ssnSearch
DataAccessor init: End
After the myDataAccessor
Database Connection...
in doGet(...)
SSSSSSSGetpolicynumber
In GetPolicyInformation
b05015195
Getting Policy Informaton for = b05015195
okay, building vector for policy
in GetPolicyInformation for = b05015195
starting query... policy Information
finishing query... Policy Information
Inside the while(next) loop
sun.jdbc.odbc.JdbcOdbcResultSet@4db06e
sun.jdbc.odbc.JdbcOdbcResultSet@4db06e
b05015195
policy information constructor with resultset
java.sql.SQLException: [Microsoft][ODBC Driver Manager] Invalid cursor state
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6031)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:6188)
at sun.jdbc.odbc.JdbcOdbc.SQLGetDataString(JdbcOdbc.java:3266)
at sun.jdbc.odbc.JdbcOdbcResultSet.getDataString(JdbcOdbcResultSet.java:
5398)
at sun.jdbc.odbc.JdbcOdbcResultSet.getString(JdbcOdbcResultSet.java:326)
at sun.jdbc.odbc.JdbcOdbcResultSet.getString(JdbcOdbcResultSet.java:383)
at viewscreenappletservlet.policyinformation.<init>(policyinformation.ja
va:56)
at viewscreenappletservlet.DatabaseAccessor.getPolicyInformation(Databas
eAccessor.java:145)
at viewscreenappletservlet.Servlet.policyDisplay(Servlet.java:108)
at viewscreenappletservlet.Servlet.doGet(Servlet.java:91)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServl
et.java:446)
at org.apache.catalina.servlets.InvokerServlet.doGet(InvokerServlet.java
:180)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:193)
at filters.ExampleFilter.doFilter(ExampleFilter.java:149)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:213)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:193)
at filters.ExampleFilter.doFilter(ExampleFilter.java:149)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:213)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:243)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline
.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:190)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline
.java:566)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authentica
torBase.java:475)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline
.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:
2343)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:180)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline
.java:566)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatche
rValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline
.java:564)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline
.java:564)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:
468)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline
.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:174)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline
.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcesso
r.java:1012)
at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.ja
va:1107)
at java.lang.Thread.run(Thread.java:484)
result set closed
1
sending response
Sending policy vector to applet...
Data transmission complete.1) JDBC-ODBC driver is buggy
2) Some drivers (truly speaking most of them) doesn't
support cursors or supports them in a wrong way
Paul -
Urgen I need help with a cursor
this my cursor, I created it in a button trigger
DECLARE
ins_mue_id resultado_v.mue_id%TYPE;
ins_pru_cod resultado_v.des_pru_codigo%TYPE;
cursor res_cur IS
select mue_id, des_pru_codigo from resultado_v where mue_id = :entrar_muestra.mue_mue_id;
BEGIN
OPEN res_cur;
LOOP
FETCH res_cur INTO ins_mue_id, ins_pru_cod;
EXIT WHEN res_cur%NOTFOUND;
INSERT INTO resultados (res_mue_id, res_pru_codigo) values (ins_mue_id, ins_pru_cod);
commit;
END LOOP;
CLOSE res_cur;
END;
Something's is wrong because no results were obtained. Please I need yours helpFirst of all, I have to correct my previous posting : point 2 was wrong, that type of error can't happen in a cursor, probably I was inattentive :-(
That said, if the query works correctly in Sql*Plus, then the only difference I can guess is in fields definitions : how are mue_id and :entrar_muestra.mue_mue_id defined ?
As Frank suggested I'd put a message within the loop to see if and what is read. -
Need help with comparing cursor row to a collection
I have been racking my brain trying to get get the code below to work properly. I am loading a table via bulk collect into a collection. I want to run code that tells me if the value of batch_REC.co_id exists or not in co.id collection. The best I have is below. The compiler does not like the MEMBER statement, and I do not know why. I am running 9i if that makes a difference. Any pointers would be extremely helpfull. Thank you.
Allan Richards
Washington, D.C.
--Initiate Procedure
procedure Check_Company_ID (Batches_cv_in IN refgas.batchCurTyp, truth boolean default null) is
--DECLARATIONs
TYPE CO_ID_Array IS TABLE OF NUMBER ;
Batch_REC t_batch%ROWTYPE;
number_check EXCEPTION;
PRAGMA EXCEPTION_INIT(number_check,-6502);
answer boolean;
co_id CO_ID_Array;
c NUMBER;
--Begin Code
BEGIN
dbms_output.put_line('-----');
dbms_output.put_line('Here is the data from the result set:');
--Setup Truth Output
IF truth IS NOT NULL THEN
dbms_output.put_line(CASE truth WHEN TRUE THEN 'True' WHEN FALSE THEN 'False' END);
END IF;
--Select T_COMPANY.COMPANY_ID into a collection
select t_company.COMPANY_ID
bulk collect into co_id
from t_company;
--Loop through the Cursor
LOOP
FETCH Batches_cv_in INTO Batch_REC;
EXIT WHEN Batches_cv_in%NOTFOUND;
--Check each co_id per loop for existance in t_company
BEGIN
--To detect if an entry is not a compliant number
c := to_number(Batch_REC.co_id);
--Checking each number as existing
answer := c MEMBER OF co_id;
check_company_id(truth => anwser);
--Setup for error catching
EXCEPTION
When number_check
Then
dbms_output.put_line('Company ID has invalid Characters! ' || Batch_REC.co_id ||' '|| Batch_REC.facility_id ||' '|| Batch_REC.batch_id||' '|| Batch_REC.report_date);
end;
END LOOP;
--Output Total Number of Records in Collection
dbms_output.put_line('Number of Records: ' || co_id.COUNT);
--Give "All Good" Statement if all records compare properly
IF co_id IS NULL THEN
dbms_output.put_line('All Company IDs are Good');
end if ;
end;I guess what I looking for then is a work around for 9i. Don't know if you're still watching this thread but you may be interested in this code from Steven Feuerstein (Whom God Preserve).
Cheers, APC -
Need help with loops! Where can I find them?
I have garageband '09 and when I go through my loops, over half of them are missing. That is to say they are labeled and there is a list of them, but only half work, The rest of them are see-through text and wont play music. It has said I could get them back with a software update but it always comes back that everything is up to date. im wondering if they might be in a folder and garageband doesnt know of that folder as where to look or what. Any Ideas please??
Bachman22 wrote:
only half work, The rest of them are see-through text and wont play music. It has said I could get them back with a software update
http://www.bulletsandbones.com/GB/GBFAQ.html#cantdownloadloops
(Let the page FULLY load. The link to your answer is at the top of your screen) -
Dear All,
Version : '11.2.0.2.0'
I have a procedure which gets called from a screen ( on .Net) if use pushes a particular button.
The procedure takes 15 minutes to complete.
My requirement is to intimate the front end(.Net) as soon as the procedures gets called successfully without waiting for its completion as it is going to take 15 mins.
The reason being, the front end will popup a message saying that " The process is going to take long time, A mail will be sent to u after its completion" once it has been intimated that the procedure has been called successfully.
Could you please suggest can i return a cursor to front end without even manipulating the data.
i hope my question is understandable.9876564 wrote:
Dear All,
Version : '11.2.0.2.0'
I have a procedure which gets called from a screen ( on .Net) if use pushes a particular button.
The procedure takes 15 minutes to complete.
My requirement is to intimate the front end(.Net) as soon as the procedures gets called successfully without waiting for its completion as it is going to take 15 mins.
The reason being, the front end will popup a message saying that " The process is going to take long time, A mail will be sent to u after its completion" once it has been intimated that the procedure has been called successfully.
Could you please suggest can i return a cursor to front end without even manipulating the data.
i hope my question is understandable.
It seems to me that your problem is not an Oracle one, but a user interface one.
I'm assuming the slowness of the procedure is due to how long it's taking to query the data, and if you can't speed that up then, to have the procedure return a ref cursor, the connection between the front end and the procedure must be maintained (the process on Oracle must belong to a session, and the front end needs to be connected to that session).
So, you can't have Oracle go off and start a seperate process and then pass back the ref cursor when it's finished, because even though you can spawn off seperate processes such as using DBMS_JOB or DBMS_SCHEDULER, they will run in their own 'session' and the calling code won't keep a hold on any of those sessions... they're effectively stand-alone and seperate.
What you'll have to do is likely get your .net application to spawn off a child process to the main app, that presents the message saying it'll take some time, does the call to Oracle and waits for Oracle to return the resultant ref cursor, which it can then pass back to the main application etc. Due to .net allowing for multi-tasking, that is where the split processing should take place. -
Need help with OCI8::Cursor object
I'm using ActiveRecord::Base.connection.execute to run a SQL statement against an Oracle schema that is "external" to my Rails database.
I'm building the connection on the fly using connection parameters stored in my Rails database (MySQL).
So far so good...I can create the connection and run the query...I'm getting back an OCI8::Cursor object and that's where I'm stuck.
I need to display the results of the query in a Rails view.
New to Ruby and I'm not sure how to proceed.
Here's what I'm getting back:
#<OCI8::Cursor:0xb76c679c @stmttype=1, @svc=#<OCISvcCtx:0xb76c6c24>, @env=#<OCIEnv:0xb7765928>, @defns=[nil, #<OCIDefine:0xb76c5d10>, #<OCIDefine:0xb76c5cd4>, #<OCIDefine:0xb76c5c5c>, #<OCIDefine:0xb76c5bf8>, #<OCIDefine:0xb76c5bd0>, #<OCIDefine:0xb76c5ba8>, #<OCIDefine:0xb76c5b80>, #<OCIDefine:0xb76c5b58>, #<OCIDefine:0xb76c5b30>, #<OCIDefine:0xb76c5b08>, #<OCIDefine:0xb76c5ae0>, #<OCIDefine:0xb76c5ab8>, #<OCIDefine:0xb76c5a90>, #<OCIDefine:0xb76c5a68>, #<OCIDefine:0xb76c5a40>, #<OCIDefine:0xb76c5a18>, #<OCIDefine:0xb76c59f0>, #<OCIDefine:0xb76c59c8>, #<OCIDefine:0xb76c59a0>, #<OCIDefine:0xb76c5978>, #<OCIDefine:0xb76c5950>, #<OCIDefine:0xb76c5928>, #<OCIDefine:0xb76c5914>, #<OCIDefine:0xb76c58d8>, #<OCIDefine:0xb76c58b0>, #<OCIDefine:0xb76c5888>, #<OCIDefine:0xb76c5860>, #<OCIDefine:0xb76c5838>, #<OCIDefine:0xb76c5810>, #<OCIDefine:0xb76c57e8>, #<OCIDefine:0xb76c57c0>, #<OCIDefine:0xb76c5798>, #<OCIDefine:0xb76c5770>, #<OCIDefine:0xb76c5748>, #<OCIDefine:0xb76c5720>, #<OCIDefine:0xb76c56f8>, #<OCIDefine:0xb76c56d0>, #<OCIDefine:0xb76c56a8>, #<OCIDefine:0xb76c5680>, #<OCIDefine:0xb76c5658>, #<OCIDefine:0xb76c5630>, #<OCIDefine:0xb76c5608>, #<OCIDefine:0xb76c55e0>, #<OCIDefine:0xb76c55b8>, #<OCIDefine:0xb76c5590>, #<OCIDefine:0xb76c5568>, #<OCIDefine:0xb76c5540>, #<OCIDefine:0xb76c5518>, #<OCIDefine:0xb76c54f0>, #<OCIDefine:0xb76c54c8>, #<OCIDefine:0xb76c54a0>], @binds=nil, @ctx=[32, #<Mutex:0xb76c6c38>, nil, 65535], @parms=[#<OCIParam:0xb76c66c0>, #<OCIParam:0xb76c66ac>, #<OCIParam:0xb76c6698>, #<OCIParam:0xb76c6684>, #<OCIParam:0xb76c6670>, #<OCIParam:0xb76c665c>, #<OCIParam:0xb76c6648>, #<OCIParam:0xb76c6634>, #<OCIParam:0xb76c6620>, #<OCIParam:0xb76c65f8>, #<OCIParam:0xb76c65e4>, #<OCIParam:0xb76c65d0>, #<OCIParam:0xb76c65bc>, #<OCIParam:0xb76c65a8>, #<OCIParam:0xb76c6594>, #<OCIParam:0xb76c6580>, #<OCIParam:0xb76c656c>, #<OCIParam:0xb76c6558>, #<OCIParam:0xb76c6544>, #<OCIParam:0xb76c6530>, #<OCIParam:0xb76c651c>, #<OCIParam:0xb76c6508>, #<OCIParam:0xb76c64f4>, #<OCIParam:0xb76c64e0>, #<OCIParam:0xb76c64cc>, #<OCIParam:0xb76c64b8>, #<OCIParam:0xb76c64a4>, #<OCIParam:0xb76c6490>, #<OCIParam:0xb76c647c>, #<OCIParam:0xb76c6418>, #<OCIParam:0xb76c638c>, #<OCIParam:0xb76c62c4>, #<OCIParam:0xb76c61e8>, #<OCIParam:0xb76c6080>, #<OCIParam:0xb76c6058>, #<OCIParam:0xb76c5fcc>, #<OCIParam:0xb76c5fb8>, #<OCIParam:0xb76c5f68>, #<OCIParam:0xb76c5f54>, #<OCIParam:0xb76c5ea0>, #<OCIParam:0xb76c5e64>, #<OCIParam:0xb76c5e14>, #<OCIParam:0xb76c5e00>, #<OCIParam:0xb76c5dec>, #<OCIParam:0xb76c5dd8>, #<OCIParam:0xb76c5dc4>, #<OCIParam:0xb76c5db0>, #<OCIParam:0xb76c5d9c>, #<OCIParam:0xb76c5d88>, #<OCIParam:0xb76c5d74>, #<OCIParam:0xb76c5d60>], @stmt=#<OCIStmt:0xb76c6760>>
My problem is that I simply don't have a firm enough grasp on the basics of Ruby to dissect this thing and get at it's innards.
If someone could drop me a code snippet that shows how to reference the contents of this in my erb file I think I'll be off to the races.If you want low level access to Oracle database then you can use ruby-oci8 API directly without using ActiveRecord.
You can read about ruby-oci8 API at http://ruby-oci8.rubyforge.org/en/api.html
But if you want to use ActiveRecord then install and use oracle_enhanced adapter, see http://wiki.github.com/rsim/oracle-enhanced
If you have any questions about oracle_enhanced adapter then probably it is better to ask them in http://groups.google.com/group/oracle-enhanced discussion group.
It is not recommended approach to establish ActiveRecord connection and then use low level ruby-oci8 API.
And if you have some problem then please describe exactly what you are doing and what you would like to achive and then also what error do you get. -
Need help with looping/repeat webpage in Apple Script
I would like to repeat an action in AppleScript by opening up a URL page in Safari, closing it, and then re-opening it again.
Can someone please help me with this action? Please be very specific in your response. I am not very familiar with this program.
Thank youtell application "Safari"
repeat with theURL in theURLs
make new document
set URL of front document to theURL
delay 1
repeat until ((do JavaScript "document.readyState" in front document) is "complete")
delay 1
end repeat
close front document
end repeat
end tell
This is what I have so far..but it is not working. It only opens it up ONCE. What I want is for the web page to repeatedly be generating every 1 or 2 seconds, after it closes out the previous one.
I want only ONE website continously being opened up.
Someone help please!! -
Need help with Loop Statements!!!
Hi
im a student just starting to learn Java. I have an assignment but am stuck on the folowing question:
"Describe the operation of the 'for' loop Flow Control statement explaining the function of the initialisation, conditional and iteration parts.
Also describe the operation for the 'while' loop Flow Control statement expaling the function of the initialisation, conditional and iteration parts."
Could someone please help answer it?
(Ive looked in some books but cant find much on asnwering it)
Any help would be much appreciated!
Thanks"Could someone please help answer it?
(Ive looked in some books but cant find much on asnwering it)" - Yes
put this into a for loop so that it takes any number of arguments from the command line - eg
my name is Susie Woosie Floosie (and any number of additional names)
at present it will only output - eg
my name is Susie Woosie
public class forLoop{
public static void main (String []args) {
String firstName = args[0];
String secondName = args[1];
System.out.println("my name is "+firstName+" "+secondName); -
The script below analyses an indesign doc for missing links and then places library asset on the page, cuts and "pastes into" any frame with a missing link (the cut and paste thing sucks, but we can't figure out any other way to avoid an external image source for the missing pic placeholder graphic). The loop finds the missing links except for 2. If there are 5 missing links, it finds 3. If there are 10 missing links, it finds 8...etc. Why won't it catch them all?
Script below:
myCheckGraphics();
function myCheckGraphics(){
myDocument=app.activeDocument;
for(var myCounter = 0; myCounter < myDocument.allGraphics.length; myCounter++){
var myGraphic = myDocument.allGraphics[myCounter];
if(myGraphic.itemLink.status == LinkStatus.LINK_MISSING){
var myLib=app.libraries.item("Missing Link.indl");
if(File.fs == "Macintosh"){
var myLibPath=app.open(File("/Applications/Adobe Indesign CS3/Cover Setup/Missing Link.indl"));
else{
myLibPath=app.open(File("/c/Program%20Files/Adobe/Cover Setup/Missing Link.indl"));
var selectMiss=app.select(myGraphic);
missLink=app.selection[0].parent;
var selectBox=app.select(missLink);
var myX=missLink.visibleBounds;
var myTop=myX[0];
var myLeft=myX[1];
var myBottom=myX[2];
var myRight=myX[3];
var myWide=myRight-myLeft;
var myBigBottom=myBottom-myTop;
if((myWide>35)||(myBigBottom>20)){
myAss=myLib.assets.item("Missing Link Big");
else if((myWide>15)||(myBigBottom>10)){
myAss=myLib.assets.item("Missing Link Medium");
else{
myAss=myLib.assets.item("Missing Link Small");
myMissAlert();
}//end if missing link
}//end for loop
function myMissAlert(){
////place the asset.//////
myAss.placeAsset (myDocument) ;
var myAsset=myDocument.pageItems.item("Missing Link");
var selectAss=app.select(myAsset);
var myDupe = app.copy() ;
var det=myAsset.remove();
var selectBox=app.select(missLink);
var myPaste=app.pasteInto()
app.select(NothingEnum.nothing, undefined);A fairly recurrent "problem" with Indesign.
The loop checks for missing links on an array of images. However, as soon as you correct one of these links, the array it's checking gets updated in the background, so the loop seems to skip every other image!
Suppose you have an array
missingLinks = [ "a", "b", "c" ]
(where all are missing) and you loop from 0 to 2. The first one checks #0 and corrects it. Now the array will change (in the background) to
["b", "c"]
... and your loop happily continues with #1 -- "c".
The common solution is to loop over the array backwards:
for(var myCounter = myDocument.allGraphics.length-1; myCounter >= 0; myCounter--)
Notice you have to use "length - 1" and check "myCounter >= 0", because the array elements are numbered from 0 to length-1 -- perfectly logical for a computer, somewhat less so for a human. The regular forwards loop does exactly the same, but it's a bit more 'hidden' from casual inspection. -
I need help with looping a java file
I am wondering is it possable to loop a java file. By this i mean re-run it again from a particular point in the program. Like where i have marked out below.
import java.util.*;
public class Player
public static void main(String[] args){
Songs listing = new Songs();
Player gui = new Player();
listing.readarray();
// I would like to loop it here once the option has been selected.
Scanner myScanner = new Scanner(System.in);
int option1;
System.out.println("--------Options-------");
System.out.println(" ");
System.out.println("Type Option Number ");
System.out.println(" ");
System.out.println("1 :View Songs");
System.out.println("2 :View Playlist");
System.out.println("3 :Edit Playlist");
System.out.println("4 :Play Playlist");
System.out.println(" ");
System.out.println("What option would you like?");
option1 = myScanner.nextInt();
if (option1 == 1)
listing.disparray();import java.util.*;
public class Player
public static void main(String[] args){
Songs listing = new Songs();
Player gui = new Player();
listing.readarray();
*while (true)*
// I would like to loop it here once the option has been selected.
Scanner myScanner = new Scanner(System.in);
int option1;
System.out.println("--------Options-------");
System.out.println(" ");
System.out.println("Type Option Number ");
System.out.println(" ");
System.out.println("1 :View Songs");
System.out.println("2 :View Playlist");
System.out.println("3 :Edit Playlist");
System.out.println("4 :Play Playlist");
System.out.println(" ");
System.out.println("What option would you like?");
option1 = myScanner.nextInt();
if (option1 == 1)
listing.disparray();
}} -
I need help with shooting in my flash game for University
Hi there
Ive tried to make my tank in my game shoot, all the code that is there works but when i push space to shoot which is my shooting key it does not shoot I really need help with this and I would appriciate anyone that could help
listed below should be the correct code
//checking if the space bar is pressed and shooting is allowed
if(evt.keyCode == 32 && shootAllow){
//making it so the user can't shoot for a bit
shootAllow = false;
//declaring a variable to be a new Bullet
var newBullet:Bullet = new Bullet();
//changing the bullet's coordinates
newBullet.y = tank_mc.y + tank_mc.width/2 - newBullet.width/2;
newBullet.x = tank_mc.x;
//then we add the bullet to stage
addChild(newBullet);
listed below is my entire code
import flash.display.MovieClip;
//declare varibles to create mines
//how much time before allowed to shoot again
var cTime:int = 0;
//the time it has to reach in order to be allowed to shoot (in frames)
var cLimit:int = 12;
//whether or not the user is allowed to shoot
var shootAllow:Boolean = true;
var minesInGame:uint;
var mineMaker:Timer;
var cursor:MovieClip;
var index:int=0;
var tankMine_mc:MovieClip;
var antiTankmine_mc:MovieClip;
var maxHP:int = 100;
var currentHP:int = maxHP;
var percentHP:Number = currentHP / maxHP;
function initialiseMine():void
minesInGame = 15;
//create a timer fires every second
mineMaker = new Timer(6000, minesInGame);
//tell timer to listen for Timer event
mineMaker.addEventListener(TimerEvent.TIMER, createMine);
//start the timer
mineMaker.start();
function createMine(event:TimerEvent):void
//var tankMine_mc:MovieClip;
//create a new instance of tankMine
tankMine_mc = new Mine();
//set the x and y axis
tankMine_mc.y = 513;
tankMine_mc.x = 1080;
// adds mines to stage
addChild(tankMine_mc);
tankMine_mc.addEventListener(Event.ENTER_FRAME, moveHorizontal);
function moveHorizontal(evt:Event):void{
evt.target.x -= Math.random()*5;
if (evt.target.x >= stage.stageWidth)
evt.target.removeEventListener(Event.ENTER_FRAME, moveHorizontal);
removeChild(DisplayObject(evt.target));
initialiseMine();
//declare varibles to create mines
var atmInGame:uint;
var atmMaker:Timer;
function initialiseAtm():void
atmInGame = 15;
//create a timer fires every second
atmMaker = new Timer(8000, minesInGame);
//tell timer to listen for Timer event
atmMaker.addEventListener(TimerEvent.TIMER, createAtm);
//start the timer
atmMaker.start();
function createAtm(event:TimerEvent):void
//var antiTankmine_mc
//create a new instance of tankMine
antiTankmine_mc = new Atm();
//set the x and y axis
antiTankmine_mc.y = 473;
antiTankmine_mc.x = 1080;
// adds mines to stage
addChild(antiTankmine_mc);
antiTankmine_mc.addEventListener(Event.ENTER_FRAME, moveHorizontal);
function moveHorizontal_2(evt:Event):void{
evt.target.x -= Math.random()*10;
if (evt.target.x >= stage.stageWidth)
evt.target.removeEventListener(Event.ENTER_FRAME, moveHorizontal);
removeChild(DisplayObject(evt.target));
initialiseAtm();
function moveForward():void{
bg_mc.x -=10;
function moveBackward():void{
bg_mc.x +=10;
var tank_mc:Tank;
// create a new Tank and put it into the variable
// tank_mc
tank_mc= new Tank;
// set the location ( x and y) of tank_mc
tank_mc.x=0;
tank_mc.y=375;
// show the tank_mc on the stage.
addChild(tank_mc);
stage.addEventListener(KeyboardEvent.KEY_DOWN, onMovementKeys);
//creates the movement
function onMovementKeys(evt:KeyboardEvent):void
//makes the tank move by 10 pixels right
if (evt.keyCode==Keyboard.D)
tank_mc.x+=5;
//makes the tank move by 10 pixels left
if (evt.keyCode==Keyboard.A)
tank_mc.x-=5
//checking if the space bar is pressed and shooting is allowed
if(evt.keyCode == 32 && shootAllow){
//making it so the user can't shoot for a bit
shootAllow = false;
//declaring a variable to be a new Bullet
var newBullet:Bullet = new Bullet();
//changing the bullet's coordinates
newBullet.y = tank_mc.y + tank_mc.width/2 - newBullet.width/2;
newBullet.x = tank_mc.x;
//then we add the bullet to stage
addChild(newBullet);
if (tank_mc.hitTestObject(antiTankmine_mc))
//tank_mc.gotoAndPlay("hit");
currentHP -= 10;
// remove anti tank mine
removeChild(antiTankmine_mc);
if (tank_mc.hitTestObject(tankMine_mc))
//tank_mc.gotoAndPlay("hit");
currentHP -= 10;
// remove anti tank mine
removeChild(tankMine_mc);
//var maxHP:int = 100;
//var currentHP:int = maxHP;
//var percentHP:Number = currentHP / maxHP;
//Incrementing the cTime
//checking if cTime has reached the limit yet
if(cTime < cLimit){
cTime ++;
} else {
//if it has, then allow the user to shoot
shootAllow = true;
//and reset cTime
cTime = 0;
function updateHealthBar():void
percentHP = currentHP / maxHP;
healthBar.barColor.scaleX = percentHP;
if(currentHP <= 0)
currentHP = 0;
trace("Game Over");
updateHealthBar();USe the trace function to analyze what happens and what fails to happen in the code you showed. trace the conditional values to see if they are set up to allow a shot when you press the key
-
Help with looping and counting
i am in a CS 1 class and need help with this loop
/*Write a program that will allow the user to enter a character
until the capital letter Z is entered
The program should count the number of letters entered
and print the total after the loop is completed*/
here is what i have it doesn't end nor does it count and i don't know hwo to make it count also i suck at do..while loops hehe
char b,Z=0;
Scanner a = new Scanner(System.in);
do
System.out.print("Enter a letter: "+"\n");
b=a.next().charAt(0);
while (b !=Z);
i know that its not even close to being right just help me out here
Edited by: purplesmurf on Nov 14, 2008 7:25 PMThe following program will count the number of chacters entered until Z is enetered.
import java.io.*;
class count
public static void main(String[] args)throws IOException
char ch;
int cnt=0;
DataInputStream br=new DataInputStream(System.in);
do
System.out.print("Enter a character:");
ch=(char)br.read();
if(ch!='Z')
cnt++;
else
break;
}while((ch=(char)br.read())!='Z');
System.out.println("The Number of entered characters are:"+cnt);
} -
Need Help With File Matching Records
I need help with my file matching program.
Here is how it suppose to work: FileMatch class should contain methods to read oldmast.txt and trans.txt. When a match occurs (i.e., records with the same account number appear in both the master file and the transaction file), add the dollar amount in the transaction record to the current balance in the master record, and write the "newmast.txt" record. (Assume that purchases are indicated by positive amounts in the transaction file and payments by negative amounts.)
When there is a master record for a particular account, but no corresponding transaction record, merely write the master record to "newmast.txt". When there is a transaction record, but no corresponding master record, print to a log file the message "Unmatched transaction record for account number ..." (fill in the account number from the transaction record). The log file should be a text file named "log.txt".
Here is my following program code:
// Exercise 14.8: CreateTextFile.java
// creates a text file
import java.io.FileNotFoundException;
import java.lang.SecurityException;
import java.util.Formatter;
import java.util.FormatterClosedException;
import java.util.NoSuchElementException;
import java.util.Scanner;
import org.egan.AccountRecord;
import org.egan.TransactionRecord;
public class CreateTextFile
private Formatter output1; // object used to output text to file
private Formatter output2; // object used to output text to file
// enable user to open file
public void openTransFile()
try
output1 = new Formatter("trans.txt");
catch (SecurityException securityException)
System.err.println("You do not have write access to this file.");
System.exit(1);
} // end catch
catch (FileNotFoundException filesNotFoundException)
System.err.println("Error creating file.");
System.exit(1);
} // end method openTransFile
// enable user to open file
public void openOldMastFile()
try
output2 = new Formatter("oldmast.txt");
catch (SecurityException securityException)
System.err.println("You do not have write access to this file.");
System.exit(1);
} // end catch
catch (FileNotFoundException filesNotFoundException)
System.err.println("Error creating file.");
System.exit(1);
} // end method openOldMastFile
// add transaction records to file
public void addTransactionRecords()
// object to be written to file
TransactionRecord record1 = new TransactionRecord();
Scanner input1 = new Scanner(System.in);
System.out.printf("%s\n%s\n%s\n%s\n\n",
"To terminate input, type the end-of-file indicator",
"when you are prompted to enter input.",
"On UNIX/Linux/Mac OS X type <ctrl> d then press Enter",
"On Windows type <ctrl> z then press Enter");
System.out.printf("%s\n%s",
"Enter account number (> 0) and amount.","? ");
while (input1.hasNext()) // loop until end-of-file indicator
try // output values to file
// retrieve data to be output
record1.setAccount(input1.nextInt()); // read account number
record1.setAmount(input1.nextDouble()); // read amount
if (record1.getAccount() > 0)
// write new record
output1.format("%d %.2f\n", record1.getAccount(), record1.getAmount());
} // end if
else
System.out.println("Account number must be greater than 0.");
} // end else
} // end try
catch (FormatterClosedException formatterClosedException)
System.err.println("Error writing to file.");
return;
} // end catch
catch (NoSuchElementException elementException)
System.err.println("Invalid input. Please try again.");
input1.nextLine(); // discard input so user can try again
} // end catch
System.out.printf("%s %s\n%s", "Enter account number (> 0) ",
"and amount.","? ");
} // end while
} // end method addTransactionRecords
// add account records to file
public void addAccountRecords()
// object to be written to file
AccountRecord record2 = new AccountRecord();
Scanner input2 = new Scanner(System.in);
System.out.printf("%s\n%s\n%s\n%s\n\n",
"To terminate input, type the end-of-file indicator",
"when you are prompted to enter input.",
"On UNIX/Linux/Mac OS X type <ctrl> d then press Enter",
"On Windows type <ctrl> z then press Enter");
System.out.printf("%s\n%s",
"Enter account number (> 0), first name, last name and balance.","? ");
while (input2.hasNext()) // loop until end-of-file indicator
try // output values to file
// retrieve data to be output
record2.setAccount(input2.nextInt()); // read account number
record2.setFirstName(input2.next()); // read first name
record2.setLastName(input2.next()); // read last name
record2.setBalance(input2.nextDouble()); // read balance
if (record2.getAccount() > 0)
// write new record
output2.format("%d %s %s %.2f\n", record2.getAccount(), record2.getFirstName(),
record2.getLastName(), record2.getBalance());
} // end if
else
System.out.println("Account number must be greater than 0.");
} // end else
} // end try
catch (FormatterClosedException formatterClosedException)
System.err.println("Error writing to file.");
return;
} // end catch
catch (NoSuchElementException elementException)
System.err.println("Invalid input. Please try again.");
input2.nextLine(); // discard input so user can try again
} // end catch
System.out.printf("%s %s\n%s", "Enter account number (> 0),",
"first name, last name and balance.","? ");
} // end while
} // end method addAccountRecords
// close file
public void closeTransFile()
if (output1 != null)
output1.close();
} // end method closeTransFile
// close file
public void closeOldMastFile()
if (output2 != null)
output2.close();
} // end method closeOldMastFile
} // end class CreateTextFile--------------------------------------------------------------------------------------------------
// Exercise 14.8: CreateTextFileTest.java
// Testing class CreateTextFile
public class CreateTextFileTest
// main method begins program execution
public static void main( String args[] )
CreateTextFile application = new CreateTextFile();
application.openTransFile();
application.addTransactionRecords();
application.closeTransFile();
application.openOldMastFile();
application.addAccountRecords();
application.closeOldMastFile();
} // end main
} // end class CreateTextFileTest-------------------------------------------------------------------------------------------------
// Exercise 14.8: TransactionRecord.java
// A class that represents on record of information
package org.egan; // packaged for reuse
public class TransactionRecord
private int account;
private double amount;
// no-argument constructor calls other constructor with default values
public TransactionRecord()
this(0,0.0); // call two-argument constructor
} // end no-argument AccountRecord constructor
// initialize a record
public TransactionRecord(int acct, double amt)
setAccount(acct);
setAmount(amt);
} // end two-argument TransactionRecord constructor
// set account number
public void setAccount(int acct)
account = acct;
} // end method setAccount
// get account number
public int getAccount()
return account;
} // end method getAccount
// set amount
public void setAmount(double amt)
amount = amt;
} // end method setAmount
// get amount
public double getAmount()
return amount;
} // end method getAmount
} // end class TransactionRecord -------------------------------------------------------------------------------------------------
// Exercise 14.8: AccountRecord.java
// A class that represents on record of information
package org.egan; // packaged for reuse
import org.egan.TransactionRecord;
public class AccountRecord
private int account;
private String firstName;
private String lastName;
private double balance;
// no-argument constructor calls other constructor with default values
public AccountRecord()
this(0,"","",0.0); // call four-argument constructor
} // end no-argument AccountRecord constructor
// initialize a record
public AccountRecord(int acct, String first, String last, double bal)
setAccount(acct);
setFirstName(first);
setLastName(last);
setBalance(bal);
} // end four-argument AccountRecord constructor
// set account number
public void setAccount(int acct)
account = acct;
} // end method setAccount
// get account number
public int getAccount()
return account;
} // end method getAccount
// set first name
public void setFirstName(String first)
firstName = first;
} // end method setFirstName
// get first name
public String getFirstName()
return firstName;
} // end method getFirstName
// set last name
public void setLastName(String last)
lastName = last;
} // end method setLastName
// get last name
public String getLastName()
return lastName;
} // end method getLastName
// set balance
public void setBalance(double bal)
balance = bal;
} // end method setBalance
// get balance
public double getBalance()
return balance;
} // end method getBalance
// combine balance and amount
public void combine(TransactionRecord record)
balance = (getBalance() + record.getAmount());
} // end method combine
} // end class AccountRecord -------------------------------------------------------------------------------------------------
// Exercise 14.8: FileMatch.java
import java.io.File;
import java.io.FileNotFoundException;
import java.lang.IllegalStateException;
import java.util.NoSuchElementException;
import java.util.Scanner;
import java.util.Formatter;
import java.util.FormatterClosedException;
import org.egan.AccountRecord;
import org.egan.TransactionRecord;
public class FileMatch
private Scanner inTransaction;
private Scanner inOldMaster;
private Formatter outNewMaster;
private Formatter theLog;
// enable user to open file
public void openTransFile()
try
inTransaction = new Scanner(new File("trans.txt"));
} // end try
catch (FileNotFoundException fileNotFoundException)
System.err.println("Error opening file.");
System.exit(1);
} // end catch
} // end method openTransFile
// enable user to open file
public void openOldMastFile()
try
inOldMaster = new Scanner(new File("oldmast.txt"));
} // end try
catch (FileNotFoundException fileNotFoundException)
System.err.println("Error opening file.");
System.exit(1);
} // end catch
} // end method openOldMastFile
// enable user to open file
public void openNewMastFile()
try
outNewMaster = new Formatter("newmast.txt");
catch (SecurityException securityException)
System.err.println("You do not have write access to this file.");
System.exit(1);
} // end catch
catch (FileNotFoundException filesNotFoundException)
System.err.println("Error creating file.");
System.exit(1);
} // end method openNewMastFile
// enable user to open file
public void openLogFile()
try
theLog = new Formatter("log.txt");
catch (SecurityException securityException)
System.err.println("You do not have write access to this file.");
System.exit(1);
} // end catch
catch (FileNotFoundException filesNotFoundException)
System.err.println("Error creating file.");
System.exit(1);
} // end method openLogFile
// update records
public void updateRecords()
TransactionRecord transaction = new TransactionRecord();
AccountRecord account = new AccountRecord();
try // read records from file using Scanner object
System.out.println("Start file matching.");
while (inTransaction.hasNext() && inOldMaster.hasNext())
transaction.setAccount(inTransaction.nextInt()); // read account number
transaction.setAmount(inTransaction.nextDouble()); // read amount
account.setAccount(inOldMaster.nextInt()); // read account number
account.setFirstName(inOldMaster.next()); // read first name
account.setLastName(inOldMaster.next()); // read last name
account.setBalance(inOldMaster.nextDouble()); // read balance
if (transaction.getAccount() == account.getAccount())
while (inTransaction.hasNext() && transaction.getAccount() == account.getAccount())
account.combine(transaction);
outNewMaster.format("%d %s %s %.2f\n",
account.getAccount(), account.getFirstName(), account.getLastName(),
account.getBalance());
transaction.setAccount(inTransaction.nextInt()); // read account number
transaction.setAmount(inTransaction.nextDouble()); // read amount
else if (transaction.getAccount() != account.getAccount())
outNewMaster.format("%d %s %s %.2f\n",
account.getAccount(), account.getFirstName(), account.getLastName(),
account.getBalance());
theLog.format("%s%d","Unmatched transaction record for account number ",transaction.getAccount());
} // end while
System.out.println("Finish file matching.");
} // end try
catch (NoSuchElementException elementException)
System.err.println("File improperly formed.");
inTransaction.close();
inOldMaster.close();
System.exit(1);
} // end catch
catch (IllegalStateException stateException)
System.err.println("Error reading from file.");
System.exit(1);
} // end catch
} // end method updateRecords
// close file and terminate application
public void closeTransFile()
if (inTransaction != null)
inTransaction.close();
} // end method closeTransFile
// close file and terminate application
public void closeOldMastFile()
if (inOldMaster != null)
inOldMaster.close();
} // end method closeOldMastFile
// close file
public void closeNewMastFile()
if (outNewMaster != null)
outNewMaster.close();
} // end method closeNewMastFile
// close file
public void closeLogFile()
if (theLog != null)
theLog.close();
} // end method closeLogFile
} // end class FileMatch-------------------------------------------------------------------------------------------------
// Exercise 14.8: FileMatchTest.java
// Testing class FileMatch
public class FileMatchTest
// main method begins program execution
public static void main( String args[] )
FileMatch application = new FileMatch();
application.openTransFile();
application.openOldMastFile();
application.openNewMastFile();
application.openLogFile();
application.updateRecords();
application.closeLogFile();
application.closeNewMastFile();
application.closeOldMastFile();
application.closeTransFile();
} // end main
} // end class FileMatchTest-------------------------------------------------------------------------------------------------
Sample data for master file:
Master file
Account Number Name Balance
100 Alan Jones 348.17
300 Mary Smith 27.19
500 Sam Sharp 0.00
700 Suzy Green -14.22Sample data for transaction file:
Transaction file Transaction
Account Number Amount
100 27.14
300 62.11
300 83.89
400 100.56
700 80.78
700 1.53
900 82.17 -------------------------------------------------------------------------------------------------
My FileMatch class program above has bugs in it.
The correct results for the newmast.txt:
100 Alan Jones 375.31
300 Mary Smith 173.19
500 Sam Sharp 0.00
700 Suzy Green 68.09The correct results for the log.txt:
Unmatched transaction record for account number 400Unmatched transaction record for account number 900------------------------------------------------------------------------------------------------
My results for the newmast.txt:
100 Alan Jones 375.31
300 Mary Smith 111.08
500 Sam Sharp 0.00
700 Suzy Green -12.69My results for the log.txt
Unmatched transaction record for account number 700-------------------------------------------------------------------------------------------------
I am not sure what is wrong with my code above to make my results different from the correct results.
Much help is appreciated. Please help.From the output, it looks like one problem is just formatting -- apparently you're including a newline in log entries and not using tabs for the newmast output file.
As to why the numbers are off -- just from glancing over it, it appears that the problem is when you add multiple transaction values. Since account.combine() is so simple, I suspect that you're either adding creating transaction objects incorrectly or not creating them when you should be.
Create test input data that isolates a single case of this (e.g., just the Mary Smith case), and then running your program in a debugger or adding debugging code to the add/combine method, so you can see what's happening in detail.
Also I'd recommend reconsidering your design. It's a red flag if a class has a name with "Create" in it. Classes represent bundles of independant state and transformations on that state, not things to do.
Maybe you are looking for
-
I have rented a movie from iTunes but where is it now? I have looked under videos,as someone suggested, but there is nothing there and no tabs to choose.
-
Quick selection tool always contains minus sign
I am obviously not a very experienced Photoshop user and I have a question about the Quick Selection tool. I am using CS6 on a Mac with OS X 10.9 Mavericks. I watched a couple tutorials and my system is behaving differently. In the tutorials I watche
-
Hello, I have a problem that I have to write code to address the issue of modem disconnections while copying data. The problem is that I have to programmactially dial modems and copy programs to a remote windows based system. The issue is that I some
-
I still can not see the update "Nokia Belle Refresh". I have a Nokia N8-00 from Claro Argentina. According to the official Nokia Argentina now available that version: http://www.nokia.com/ar-es/soporte/producto/n8-00/ Nokia N8-00 user Solved! Go to S
-
Perceive changes in an input from in uix
Hi all, I have a UIX page with a databound input form (bound to a view object) and three buttons: - save: allows to save data - cancel: executes rollback - exit: calls a javascript funtion that prompts a modal window to ask user if she wants to save