Delayed Movement For Loop
I know this question has probably been asked and answered before, but after searching/reading in the forums, I'm still confused.
So I would like my VI to effectively move a stage a given distance with incremental sizes with pauses of between each step.
Effectively: "Go To" _____ With X step size: causes the VI to: move, pause, move pause...etc until the stage has reached the end.
To accomplish this I set up a for loop inside a case structure, and took the "Go To" / by Step Size to get the number of iterations the loop aught to run (labview apparently rounds the double result to the integer form), and then I send the "Step Size" to the MoveAbs VI.
I am not sure if my logic is terribly off, but when I perform the command, the stage at least moves, but not to the correct location.When I inserted probes, they list the correct values being sent to the subvi's etc...
Does anyone have an idea why this would not work? Any better ideas to institute this type of motion?
Thanks
Attachments:
delayedmotiontrial2.vi 85 KB
Hey Tim,
I've got another question for you--I've been working on the program and I think I finally understand the basic outline. I've been trying to add other subvi's to increase functionality and I came across a problem:
The error list says that the selector values of the case structure are not unique--which is true of the program I am sending you. So naturally I deleted the extra "VI INI" which was tagged onto the default case. However doing so caused my program to crash--or more accurately cycle in an infinite loop. The program initializes over and over again. The "INI VI" sends another "INI VI" to the array and gets stuck.
I am not quite sure what is wrong, because when I looked at the original program you had sent to me, and earlier versions I had edited, I noticed that they have the same code within the "INI VI" case...in addition, now when I open previous programs--that were functioning perfectly well before--I get the same error message complaining about "not unique selector values". I honestly don't recall ever adding "INI VI" to the default case...
I am attaching the program and was wondering your thoughts, especially given the retrospective error...
Let me know if I was unclear in explaining the problem etc...and thanks again for your help. Others' input welcomed too!
Nathan
Attachments:
DelayedMotionTrial7c.vi 85 KB
State Machine States.ctl 5 KB
Similar Messages
-
Hello, had to move to mavericks lost quicktime Pro, Need the feature for looping audio sections repeatedly, I have the install Key from my old QT Pro version, any ideas?
If QuickTime Player 7 isn't in the Utilities folder automatically, you can install it separately. See:
http://support.apple.com/kb/HT3678
Instructions on how to register your QuickTime Pro key can be found in that same document.
Regards. -
How do I loop a movie for Apple TV
I have looked at the archives and I cannot get it to work the way it is explained.
I have saved a QT movie with Loop checked. It loops fine after it is saved before I send it to iTunes
When I send it to iTunes it will not loop. For some reason when I create a Playlist with the movie in it and ask it to repeat it does not show up in the playlist when I want to send it to Apple TV.
Any help would be appreciated..I'm getting frustrated!
Thanks
KrisHow did you do that?
I have been waiting for a solution to loop my movie in Apple TV.
What versions of iTunes, Apple TV, did you use?
Thanks millions in advance... -
I'm trying to figure out a way to move movie clips with a for loop
I've got 10 dots called dt1-dt10 and I want to be able to set them all to y = 200.
I understand i can set i=1;i<11;i++
like
for(i=1;i<11;i++){
dt+i._y = 200;}
or
for(i=1;i<11;i++){
String("dt"+i)._y = 200;}
but the rest of it is a mess and either doesn't work, or glitches. I have yet to find a for loop help file for moving multiple movie clips.If you just want to immediately change the positions of the instances, then using a for loop will work okay, you just need to use the bracket notation [ ] to have strings be interpreted as instance names...
for(i=1;i<11;i++){
this["dt"+i]._y = 200; -
Replace the following open/fetch/close statements with a cursor FOR loop
Hi anyone could you please help me,
I would like to replace the following open/fetch/close statements with a cursor FOR loop.
Codes are:
CREATE OR REPLACE PROCEDURE COMOES.orchid_shipment_interface IS
-- get the com shipment header records
CURSOR c_com_shphdr ( p_dwn_end_dt DATE ) IS
SELECT custno client_id
, plheadno plheadno
, DECODE(carr_no,'FEDX',lading_no,'UPS',lading_no,carrier_pro_no) tracking_no
, carr_no||'/'||carr_method carrier_id
, plantid plant_id
, carr_no
, lading_no
, del_custaddr ship_to_id
, ol_type cfm_order_type
, del_custno
, shipterm freight_terms
, del_custattn attn_line
, custaddr
FROM com_plhead@com_pricing.world
WHERE status = '9'
AND (mod_dat) > p_dwn_end_dt;
-- get the com shipment address records
CURSOR c_com_shpadr (p_custaddr VARCHAR2) IS
SELECT name1 addr_name
, street1 addr_line1
, street2 addr_line2
, city city
, state state_cd
, zip zip
, country country_cd
, phone work_phone
, email email1
FROM com_address@com_pricing.world
WHERE addr_id = p_custaddr;
-- get the com shipment detail records
CURSOR c_com_shpdtl ( p_plheadno NUMBER) IS
SELECT pll.plheadno pllheadno
, pll.pllineno ord_line_no
, pll.ol_no erp_line_no
, pll.ol_segno
, pll.fg_id sku
, pll.qty_shipped ship_qty
, pll.ordno erp_ord_no
FROM com_plline@com_pricing.world pll
WHERE pll.plheadno = p_plheadno
AND NOT EXISTS (SELECT '1'
FROM com_pkg_int_interface@com_pricing.world cpi
WHERE pll.ordno = cpi.ordno
AND pll.ol_no = cpi.ol_no);
-- type declaration
-- type declaration of com table.
TYPE t_com_shphdr IS TABLE OF c_com_shphdr%ROWTYPE INDEX BY BINARY_INTEGER;
TYPE t_orchid_shphdr IS TABLE OF orchid_shipment_hdr_intf%ROWTYPE INDEX BY BINARY_INTEGER;
TYPE t_com_shpadr IS TABLE OF c_com_shpadr%ROWTYPE INDEX BY BINARY_INTEGER;
TYPE t_orchid_shpadr IS TABLE OF orchid_shipment_address_intf%ROWTYPE INDEX BY BINARY_INTEGER;
TYPE t_com_shpdtl IS TABLE OF c_com_shpdtl%ROWTYPE INDEX BY BINARY_INTEGER;
TYPE t_orchid_shpdtl IS TABLE OF orchid_shipment_dtl_intf%ROWTYPE INDEX BY BINARY_INTEGER;
lv_company_code com_customer.business_unit%TYPE;
lv_erp_ord_no com_plline.ordno%TYPE;
lv_actual_ship_date com_plline.confirm_date%TYPE;
lv_po_no com_oline.po_no%TYPE;
lv_ord_date com_oline.entrydate%TYPE;
lv_hdr_batch_ctrl_no download_batch_info.batch_ctrl_no%TYPE;
lv_adr_batch_ctrl_no download_batch_info.batch_ctrl_no%TYPE;
lv_dtl_batch_ctrl_no download_batch_info.batch_ctrl_no%TYPE;
lv_sku_desc com_salesitem.title%TYPE;
lv_ord_qty com_oldelseg.qty%TYPE;
lr_com_shphdr t_com_shphdr;
lr_orchid_shphdr t_orchid_shphdr;
lr_com_shpadr t_com_shpadr;
lr_orchid_shpadr t_orchid_shpadr;
lr_com_shpdtl t_com_shpdtl;
lr_orchid_shpdtl t_orchid_shpdtl;
-- variable declaration
ln_shphdr_seq NUMBER(10):= 0;
ln_shpadr_seg NUMBER(10):= 0;
ln_shpdtl_seq NUMBER(10):= 0;
cnt NUMBER(10):= 0;
cnt1 NUMBER(10):= 0;
ld_hdr_dwn_end_dt download_batch_info.download_end_tstamp%TYPE;
lc_hdr_dwn_status download_batch_info.dwn_status%TYPE;
ld_hdr_download_end_tstamp DATE;
ln_hdr_running_seq NUMBER(10) := 0;
ld_adr_dwn_end_dt download_batch_info.download_end_tstamp%TYPE;
lc_adr_dwn_status download_batch_info.dwn_status%TYPE;
ld_adr_download_end_tstamp DATE;
ln_adr_running_seg NUMBER(10) := 0;
ld_dtl_dwn_end_dt download_batch_info.download_end_tstamp%TYPE;
lc_dtl_dwn_status download_batch_info.dwn_status%TYPE;
ld_dtl_download_end_tstamp DATE;
ln_dtl_running_seq NUMBER(10) := 0;
BEGIN
-- get the batch control number details from batch information table for shipment header
BEGIN
SELECT batch_ctrl_no
, NVL(download_end_tstamp,TO_DATE('01/01/1980','MM/DD/YYYY'))
, dwn_status
INTO lv_hdr_batch_ctrl_no
, ld_hdr_dwn_end_dt
, lc_hdr_dwn_status
FROM comoes.download_batch_info
WHERE download_id = 'ORCHID_SHIPMENT_HDR_INTF';
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE (' No Data Found for ORCHID_SHIPMENT_HDR_INTF in Download Batch Info table...!!!');
RAISE;
WHEN TOO_MANY_ROWS THEN
DBMS_OUTPUT.PUT_LINE (' Too Many Rows found for ORCHID_SHIPMENT_HDR_INTF in Download Batch Info table...!!!');
RAISE;
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE (' Following error occured while getting batch control number for ORCHID_SHIPMENT_HDR_INTF in Download Batch Info table...!!!'||SQLERRM);
RAISE;
END;
-- get the batch control number details from batch information table for shipment address
BEGIN
SELECT batch_ctrl_no
, NVL(download_end_tstamp,TO_DATE('01/01/1980','MM/DD/YYYY'))
, dwn_status
INTO lv_adr_batch_ctrl_no
, ld_adr_dwn_end_dt
, lc_adr_dwn_status
FROM comoes.download_batch_info
WHERE download_id = 'ORCHID_SHIPMENT_ADDRESS_INTF';
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE (' No Data Found for ORCHID_SHIPMENT_ADDRESS_INTF in Download Batch Info table...!!!');
RAISE;
WHEN TOO_MANY_ROWS THEN
DBMS_OUTPUT.PUT_LINE (' Too Many Rows found for ORCHID_SHIPMENT_ADDRESS_INTF in Download Batch Info table...!!!');
RAISE;
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE (' Following error occured while getting batch control number for ORCHID_SHIPMENT_ADDRESS_INTF in Download Batch Info table...!!!'||SQLERRM);
RAISE;
END;
-- get the batch control number details from batch information table for shipment details
BEGIN
SELECT batch_ctrl_no
, NVL(download_end_tstamp,TO_DATE('01/01/1980','MM/DD/YYYY'))
, dwn_status
INTO lv_dtl_batch_ctrl_no
, ld_dtl_dwn_end_dt
, lc_dtl_dwn_status
FROM download_batch_info
WHERE download_id = 'ORCHID_SHIPMENT_DTL_INTF';
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE (' No Data Found for ORCHID_SHIPMENT_DTL_INTF in Download Batch Info table...!!!');
RAISE;
WHEN TOO_MANY_ROWS THEN
DBMS_OUTPUT.PUT_LINE (' Too Many Rows found for ORCHID_SHIPMENT_DTL_INTF in Download Batch Info table...!!!');
RAISE;
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE (' Following error occured while getting batch control number for ORCHID_SHIPMENT_DTL_INTF in Download Batch Info table...!!!'||SQLERRM);
RAISE;
END;
-- if previous run is not sucess then do nothing and return.
OPEN c_com_shphdr ( ld_hdr_dwn_end_dt ) ;
LOOP
-- delete the collection for every cycle
lr_com_shphdr.DELETE;
lr_orchid_shphdr.DELETE;
lr_com_shpadr.DELETE;
lr_orchid_shpadr.DELETE;
lr_com_shpdtl.DELETE;
lr_orchid_shpdtl.DELETE;
-- fetch the order header records to collection
FETCH c_com_shphdr BULK COLLECT INTO lr_com_shphdr LIMIT 500;
-- where there is no record in the collection the exit from the loop
EXIT WHEN lr_com_shphdr.COUNT = 0;
-- build your logic there to populate the data into order header collection.
FOR i IN 1..lr_com_shphdr.COUNT
LOOP
-- accumulate header running sequence number
ln_hdr_running_seq := ln_hdr_running_seq + 1;
ln_shphdr_seq := ln_hdr_running_seq;
-- Get the business unit for the customer from com_customer
BEGIN
SELECT business_unit
INTO lv_company_code
FROM com_customer@com_pricing.world
WHERE custno = lr_com_shphdr(i).del_custno;
EXCEPTION
WHEN OTHERS THEN
lv_company_code := NULL;
END;
-- Get the ordno, confirm_date from COM_PLLINE
BEGIN
SELECT ordno
, confirm_date
INTO lv_erp_ord_no
, lv_actual_ship_date
FROM com_plline@com_pricing.world cpl
WHERE cpl.plheadno = lr_com_shphdr(i).plheadno
AND ROWNUM = 1;
EXCEPTION
WHEN OTHERS THEN
lv_erp_ord_no := NULL;
lv_actual_ship_date := NULL;
END;
-- Get the po_no, Entry_date from COM_OLINE
BEGIN
SELECT po_no
, entrydate
INTO lv_po_no
, lv_ord_date
FROM com_oline@com_pricing.world col
WHERE col.ordno = lv_erp_ord_no
AND ROWNUM = 1;
EXCEPTION
WHEN OTHERS THEN
lv_po_no := NULL;
lv_ord_date := NULL;
END;
-- To assign the Bol Number from Lading Number
IF lr_com_shphdr(i).carr_no NOT IN ('FEDX','UPS') THEN
lr_orchid_shphdr(i).bol_no := lr_com_shphdr(i).lading_no;
ELSE
lr_orchid_shphdr(i).bol_no := NULL;
END IF;
-- For each order header get the Shipment Delivery Adderss
OPEN c_com_shpadr ( lr_com_shphdr(i).custaddr);
FETCH c_com_shpadr BULK COLLECT INTO lr_com_shpadr;
-- where there is no record in the collection the exit from the loop
EXIT WHEN lr_com_shpadr.COUNT = 0;
-- biuld your logic here to populate the del address collection.
FOR j IN 1..lr_com_shpadr.COUNT
LOOP
-- accumulate the loop count into temp variable, so that will through tell each set of order header.
cnt := cnt + 1;
-- accumolate the header running sequence number.
ln_adr_running_seg := ln_adr_running_seg + 1;
ln_shpadr_seg := ln_adr_running_seg;
-- move the order address data into collection.
lr_orchid_shpadr(cnt).client_id := lr_com_shphdr(i).del_custno;
lr_orchid_shpadr(cnt).ord_no := lr_com_shphdr(i).plheadno;
lr_orchid_shpadr(cnt).tracking_no := lr_com_shphdr(i).tracking_no;
lr_orchid_shpadr(cnt).addr_name := lr_com_shpadr(j).addr_name;
lr_orchid_shpadr(cnt).attn_line := lr_com_shphdr(i).attn_line;
lr_orchid_shpadr(cnt).addr_line1 := lr_com_shpadr(j).addr_line1;
lr_orchid_shpadr(cnt).addr_line2 := lr_com_shpadr(j).addr_line2;
lr_orchid_shpadr(cnt).addr_line3 := NULL;
lr_orchid_shpadr(cnt).addr_line4 := NULL;
lr_orchid_shpadr(cnt).addr_line5 := NULL;
lr_orchid_shpadr(cnt).city := lr_com_shpadr(j).city;
lr_orchid_shpadr(cnt).state_cd := lr_com_shpadr(j).state_cd;
lr_orchid_shpadr(cnt).zip := lr_com_shpadr(j).zip;
lr_orchid_shpadr(cnt).zip_ext := NULL;
lr_orchid_shpadr(cnt).country_cd := lr_com_shpadr(j).country_cd;
lr_orchid_shpadr(cnt).tax_geo_cd := NULL;
lr_orchid_shpadr(cnt).work_phone := lr_com_shpadr(j).work_phone;
lr_orchid_shpadr(cnt).email1 := lr_com_shpadr(j).email1;
lr_orchid_shpadr(cnt).cre_dat := SYSDATE;
lr_orchid_shpadr(cnt).cre_usr := USER;
lr_orchid_shpadr(cnt).batch_ctrl_no := lv_adr_batch_ctrl_no;
END LOOP;
CLOSE c_com_shpadr;
-- For each order header get the order detail/delivery segment data
OPEN c_com_shpdtl ( lr_com_shphdr(i).plheadno );
FETCH c_com_shpdtl BULK COLLECT INTO lr_com_shpdtl;
-- where there is no record in the collection the exit from the loop
EXIT WHEN lr_com_shpdtl.COUNT = 0;
-- build your logic here to populate the order detail collection
FOR k IN 1..lr_com_shpdtl.COUNT
LOOP
-- accumulate the loop count into a temp variable, so that will through till each set of Order Header.
cnt1 := cnt1 + 1;
-- accumulate header running sequence number
ln_dtl_running_seq := ln_dtl_running_seq + 1;
ln_shpdtl_seq := ln_dtl_running_seq;
-- Get Quantity for the delvery from delevery segment table.
BEGIN
SELECT NVL(Qty,0)
INTO lv_ord_qty
FROM com_oldelseg@com_pricing.world cds
WHERE cds.ordno = lr_com_shpdtl(k).erp_ord_no
AND cds.ol_no = lr_com_shpdtl(k).erp_line_no
AND cds.ol_segno = lr_com_shpdtl(k).ol_segno;
EXCEPTION
WHEN OTHERS THEN
lv_ord_qty := NULL;
END;
-- Get Title for the salesitem from the salesitem table.
BEGIN
SELECT Title
INTO lv_sku_desc
FROM com_salesitem@com_pricing.world cs
WHERE cs.fg_id = lr_com_shpdtl(k).sku;
EXCEPTION
WHEN OTHERS THEN
lv_sku_desc := NULL;
END;
-- move the Order detail data into collection
lr_orchid_shpdtl(cnt1).client_id := lr_com_shphdr(i).client_id;
lr_orchid_shpdtl(cnt1).ord_no := lr_com_shphdr(i).plheadno;
lr_orchid_shpdtl(cnt1).ord_line_no := lr_com_shpdtl(k).ord_line_no;
lr_orchid_shpdtl(cnt1).erp_line_no := lr_com_shpdtl(k).erp_line_no;
lr_orchid_shpdtl(cnt1).sku := lr_com_shpdtl(k).sku;
lr_orchid_shpdtl(cnt1).tracking_no := lr_com_shphdr(i).tracking_no;
lr_orchid_shpdtl(cnt1).container_no := NULL;
lr_orchid_shpdtl(cnt1).ord_qty := lv_ord_qty;
lr_orchid_shpdtl(cnt1).ship_qty := lr_com_shpdtl(k).ship_qty;
lr_orchid_shpdtl(cnt1).price_point := NULL;
lr_orchid_shpdtl(cnt1).pick_invoice_no := NULL;
lr_orchid_shpdtl(cnt1).cancel_qty := NULL;
lr_orchid_shpdtl(cnt1).bldg_id := NULL; --lr_com_shpdtl(k).bldg_id;
lr_orchid_shpdtl(cnt1).sku_company := NULL; --lr_com_shpdtl(k).sku_company;
lr_orchid_shpdtl(cnt1).sku_desc := lv_sku_desc;
lr_orchid_shpdtl(cnt1).icc_cd1 := NULL; --lr_com_shpdtl(k).icc_cd1;
lr_orchid_shpdtl(cnt1).erp_ord_no := lr_com_shpdtl(k).erp_ord_no;
lr_orchid_shpdtl(cnt1).cre_dat := SYSDATE;
lr_orchid_shpdtl(cnt1).cre_usr := USER;
lr_orchid_shpdtl(cnt1).batch_ctrl_no := lv_dtl_batch_ctrl_no;
END LOOP;
CLOSE c_com_shpdtl;
-- build the logic to populate Order Header
lr_orchid_shphdr(i).client_id := lr_com_shphdr(i).client_id;
lr_orchid_shphdr(i).ord_no := lr_com_shphdr(i).plheadno;
lr_orchid_shphdr(i).tracking_no := lr_com_shphdr(i).tracking_no;
lr_orchid_shphdr(i).container_no := NULL; -- container number is not maintained in COM
lr_orchid_shphdr(i).carrier_id := lr_com_shphdr(i).carrier_id;
lr_orchid_shphdr(i).plant_id := lr_com_shphdr(i).plant_id;
lr_orchid_shphdr(i).erp_ord_no := lv_erp_ord_no;
lr_orchid_shphdr(i).erp_ord_no2 := NULL;
lr_orchid_shphdr(i).po_no := lv_po_no;
lr_orchid_shphdr(i).ship_to_id := lr_com_shphdr(i).ship_to_id;
lr_orchid_shphdr(i).ship_to_addr_id := lr_com_shphdr(i).custaddr;
lr_orchid_shphdr(i).scac := NULL; --lr_com_shphdr(i).scac;
lr_orchid_shphdr(i).actual_ship_date := lv_actual_ship_date;
lr_orchid_shphdr(i).cfm_order_type := lr_com_shphdr(i).cfm_order_type;
lr_orchid_shphdr(i).company_code := lv_company_code;
lr_orchid_shphdr(i).no_of_order_lines := NULL; --lr_com_shphdr(i).no_of_order_lines;
lr_orchid_shphdr(i).pick_invoice_no := NULL;
lr_orchid_shphdr(i).ord_date := lv_ord_date;
lr_orchid_shphdr(i).orig_tender_date := NULL;
lr_orchid_shphdr(i).orig_delv_date := NULL;
lr_orchid_shphdr(i).delivery_flag := NULL;
lr_orchid_shphdr(i).delv_date_from := NULL;
lr_orchid_shphdr(i).delv_date_to := NULL;
lr_orchid_shphdr(i).orig_carr_cd := NULL;
lr_orchid_shphdr(i).routing_comment := NULL;
lr_orchid_shphdr(i).segment_type := NULL;
lr_orchid_shphdr(i).back_order_flag := NULL;
lr_orchid_shphdr(i).addr_override_flag := NULL;
lr_orchid_shphdr(i).fmx_assigned_carr := NULL;
lr_orchid_shphdr(i).fmx_assigned_ship_date := NULL;
lr_orchid_shphdr(i).fmx_assigned_delv_date := NULL;
lr_orchid_shphdr(i).freight_terms := lr_com_shphdr(i).freight_terms;
lr_orchid_shphdr(i).fmx_load_id := NULL;
lr_orchid_shphdr(i).asn_type := NULL;
lr_orchid_shphdr(i).icc_cd1 := NULL; --lr_com_shphdr(i).icc_cd1;
lr_orchid_shphdr(i).trans_type := NULL;
lr_orchid_shphdr(i).ref_no1 := NULL;
lr_orchid_shphdr(i).ref_no2 := NULL;
lr_orchid_shphdr(i).ref_no3 := NULL;
lr_orchid_shphdr(i).ref_no4 := NULL;
lr_orchid_shphdr(i).cre_dat := SYSDATE;
lr_orchid_shphdr(i).cre_usr := USER;
lr_orchid_shphdr(i).batch_ctrl_no := lv_hdr_batch_ctrl_no;
-- logic to get total boxes and weight.
BEGIN
SELECT SUM(no_cartons), SUM(weight)
INTO lr_orchid_shphdr(i).total_boxes
, lr_orchid_shphdr(i).weight
FROM com_plline@com_pricing.world pll
WHERE pll.plheadno = lr_com_shphdr(i).plheadno;
EXCEPTION
WHEN OTHERS THEN
lr_orchid_shphdr(i).total_boxes := NULL;
lr_orchid_shphdr(i).weight := NULL;
END;
END LOOP;
-- initialize the variables for next loop cycle.
cnt := 0;
cnt1 := 0;
-- populate the shipment header interface table.
FOR x IN 1..lr_orchid_shphdr.COUNT
LOOP
ld_hdr_download_end_tstamp := lr_orchid_shphdr(x).cre_dat;
INSERT INTO orchid_shipment_hdr_intf
(record_qualifier
,client_id
,ord_no
,tracking_no
,container_no
,bol_no
,carrier_id
,plant_id
,erp_ord_no
,erp_ord_no2
,po_no
,ship_to_id
,ship_to_addr_id
,scac
,actual_ship_date
,cfm_order_type
,company_code
,no_of_order_lines
,pick_invoice_no
,total_boxes
,weight
,ord_date
,orig_tender_date
,orig_delv_date
,delivery_flag
,delv_date_from
,delv_date_to
,orig_carr_cd
,routing_comment
,segment_type
,back_order_flag
,addr_override_flag
,fmx_assigned_carr
,fmx_assigned_ship_date
,fmx_assigned_delv_date
,freight_terms
,fmx_load_id
,asn_type
,upl_status
,icc_cd1
,trans_type
,ref_no1
,ref_no2
,ref_no3
,ref_no4
,cre_dat
,cre_usr
,batch_ctrl_no)
VALUES
( 10
,lr_orchid_shphdr(x).client_id
,lr_orchid_shphdr(x).ord_no
,lr_orchid_shphdr(x).tracking_no
,lr_orchid_shphdr(x).container_no
,lr_orchid_shphdr(x).bol_no
,lr_orchid_shphdr(x).carrier_id
,lr_orchid_shphdr(x).plant_id
,lr_orchid_shphdr(x).erp_ord_no
,lr_orchid_shphdr(x).erp_ord_no2
,lr_orchid_shphdr(x).po_no
,lr_orchid_shphdr(x).ship_to_id
,lr_orchid_shphdr(x).ship_to_addr_id
,lr_orchid_shphdr(x).scac
,lr_orchid_shphdr(x).actual_ship_date
,lr_orchid_shphdr(x).cfm_order_type
,lr_orchid_shphdr(x).company_code
,lr_orchid_shphdr(x).no_of_order_lines
,lr_orchid_shphdr(x).pick_invoice_no
,lr_orchid_shphdr(x).total_boxes
,lr_orchid_shphdr(x).weight
,lr_orchid_shphdr(x).ord_date
,lr_orchid_shphdr(x).orig_tender_date
,lr_orchid_shphdr(x).orig_delv_date
,lr_orchid_shphdr(x).delivery_flag
,lr_orchid_shphdr(x).delv_date_from
,lr_orchid_shphdr(x).delv_date_to
,lr_orchid_shphdr(x).orig_carr_cd
,lr_orchid_shphdr(x).routing_comment
,lr_orchid_shphdr(x).segment_type
,lr_orchid_shphdr(x).back_order_flag
,lr_orchid_shphdr(x).addr_override_flag
,lr_orchid_shphdr(x).fmx_assigned_carr
,lr_orchid_shphdr(x).fmx_assigned_ship_date
,lr_orchid_shphdr(x).fmx_assigned_delv_date
,lr_orchid_shphdr(x).freight_terms
,lr_orchid_shphdr(x).fmx_load_id
,lr_orchid_shphdr(x).asn_type
,00
,lr_orchid_shphdr(x).icc_cd1
,lr_orchid_shphdr(x).trans_type
,lr_orchid_shphdr(x).ref_no1
,lr_orchid_shphdr(x).ref_no2
,lr_orchid_shphdr(x).ref_no3
,lr_orchid_shphdr(x).ref_no4
,lr_orchid_shphdr(x).cre_dat
,lr_orchid_shphdr(x).cre_usr
,lr_orchid_shphdr(x).batch_ctrl_no);
END LOOP;
-- populate the shipment address interface table.
FOR y IN 1..lr_orchid_shpadr.COUNT
LOOP
ld_adr_download_end_tstamp := lr_orchid_shpadr(y).cre_dat;
INSERT INTO orchid_shipment_address_intf
( record_qualifier
, client_id
, ord_no
, tracking_no
, addr_name
, attn_line
, addr_line1
, addr_line2
, addr_line3
, addr_line4
, addr_line5
, city
, state_cd
, zip
, zip_ext
, country_cd
, tax_geo_cd
, work_phone
, email1
, cre_dat
, cre_usr
, batch_ctrl_no)
VALUES ( 14
, lr_orchid_shpadr(y).client_id
, lr_orchid_shpadr(y).ord_no
, lr_orchid_shpadr(y).tracking_no
, lr_orchid_shpadr(y).addr_name
, lr_orchid_shpadr(y).attn_line
, lr_orchid_shpadr(y).addr_line1
, lr_orchid_shpadr(y).addr_line2
, lr_orchid_shpadr(y).addr_line3
, lr_orchid_shpadr(y).addr_line4
, lr_orchid_shpadr(y).addr_line5
, lr_orchid_shpadr(y).city
, lr_orchid_shpadr(y).state_cd
, lr_orchid_shpadr(y).zip
, lr_orchid_shpadr(y).zip_ext
, lr_orchid_shpadr(y).country_cd
, lr_orchid_shpadr(y).tax_geo_cd
, lr_orchid_shpadr(y).work_phone
, lr_orchid_shpadr(y).email1
, lr_orchid_shpadr(y).cre_dat
, lr_orchid_shpadr(y).cre_usr
, lr_orchid_shpadr(y).batch_ctrl_no);
END LOOP;
-- populate the shipment detail interface table.
FOR z IN 1..lr_orchid_shpdtl.COUNT
LOOP
ld_dtl_download_end_tstamp := lr_orchid_shpdtl(z).cre_dat;
INSERT INTO orchid_shipment_dtl_intf
( record_qualifier
, client_id
, ord_no
, ord_line_no
, erp_line_no
, sku
, tracking_no
, container_no
, ord_qty
, ship_qty
, price_point
, pick_invoice_no
, cancel_qty
, bldg_id
, sku_company
, sku_desc
, icc_cd1
, erp_ord_no
, cre_dat
, cre_usr
, batch_ctrl_no)
VALUES ( 20
, lr_orchid_shpdtl(z).client_id
, lr_orchid_shpdtl(z).ord_no
, lr_orchid_shpdtl(z).ord_line_no
, lr_orchid_shpdtl(z).erp_line_no
, lr_orchid_shpdtl(z).sku
, lr_orchid_shpdtl(z).tracking_no
, lr_orchid_shpdtl(z).container_no
, lr_orchid_shpdtl(z).ord_qty
, lr_orchid_shpdtl(z).ship_qty
, lr_orchid_shpdtl(z).price_point
, lr_orchid_shpdtl(z).pick_invoice_no
, lr_orchid_shpdtl(z).cancel_qty
, lr_orchid_shpdtl(z).bldg_id
, lr_orchid_shpdtl(z).sku_company
, lr_orchid_shpdtl(z).sku_desc
, lr_orchid_shpdtl(z).icc_cd1
, lr_orchid_shpdtl(z).erp_ord_no
, lr_orchid_shpdtl(z).cre_dat
, lr_orchid_shpdtl(z).cre_usr
, lr_orchid_shpdtl(z).batch_ctrl_no);
END LOOP;
COMMIT;
END LOOP;
CLOSE c_com_shphdr;
-- set the status to success
UPDATE comoes.download_batch_info
SET batch_ctrl_no = orchid_plhead_btch_ctrl_seq.NEXTVAL
, dwn_status = '90'
, download_end_tstamp = NVL(ld_hdr_download_end_tstamp,SYSDATE)
WHERE download_id = 'ORCHID_SHIPMENT_HDR_INTF'
AND batch_ctrl_no = lv_hdr_batch_ctrl_no;
UPDATE comoes.download_batch_info
SET batch_ctrl_no = orchid_address_btch_ctrl_seq.NEXTVAL
, dwn_status = '90'
, download_end_tstamp = NVL(ld_hdr_download_end_tstamp,SYSDATE)
WHERE download_id = 'ORCHID_SHIPMENT_ADDRESS_INTF'
AND batch_ctrl_no = lv_adr_batch_ctrl_no;
UPDATE comoes.download_batch_info
SET batch_ctrl_no = orchid_plline_btch_ctrl_seq.NEXTVAL
, dwn_status = '90'
, download_end_tstamp = NVL(ld_dtl_download_end_tstamp,SYSDATE)
WHERE download_id = 'ORCHID_SHIPMENT_DTL_INTF'
AND batch_ctrl_no = lv_dtl_batch_ctrl_no;
-- Update the download status to success in the interface table.
-- Shipment Header
COMMIT;
EXCEPTION
WHEN OTHERS THEN
-- load is not sucess then set the status to fail
UPDATE comoes.download_batch_info
SET dwn_status = '99'
WHERE download_id = 'ORCHID_SHIPMENT_HDR_INTF'
AND batch_ctrl_no = lv_hdr_batch_ctrl_no;
UPDATE comoes.download_batch_info
SET dwn_status = '99'
WHERE download_id = 'ORCHID_SHIPMENT_ADDRESS_INTF'
AND batch_ctrl_no = lv_adr_batch_ctrl_no;
UPDATE comoes.download_batch_info
SET dwn_status = '99'
WHERE download_id = 'ORCHID_SHIPMENT_DTL_INTF'
AND batch_ctrl_no = lv_dtl_batch_ctrl_no;
COMMIT;
DBMS_OUTPUT.PUT_LINE('Following error occured while executing ORCHID_SHIPMENT_INTF procedure...!!!'||SQLERRM);
RAISE;
END orchid_shipment_interface;Edited by: BluShadow on 03-Aug-2011 13:28
added {noformat}{noformat} tags. Please read {message:id=9360002} to learn to do this yourself. &nbPlease read the Forum FAQ on how to ask a question, particularly how to format code
SQL and PL/SQL FAQ
SQL and PL/SQL FAQ
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE (' Following error occured while getting batch control number for ORCHID_SHIPMENT_HDR_INTF in Download Batch Info table...!!!'||SQLERRM);
RAISE;http://tkyte.blogspot.com/2008/01/why-do-people-do-this.html -
For loop- seems to be just going to last value
Hi guys, carrying on from the thread I created yesterday I have managed to get the socket working between my server and my client, but I am having an issue when re-constructing a string that is being sent from the client to the server. I am talking about the for loop in line 151, which seems to just going straight to the last value of the for loop and thus the board isn't being reconstructed properly.
I'm including both the server and client code which just needs to compiled (host is set to localhost on port 4500) and you will see what I mean after inputting a move from the client. Can anyone spot the problem?
Server code
import java.io.*;
import java.net.*;
import javax.swing.JOptionPane;
class Server
public static void main (String []args) throws IOException
try
Server();
catch (IOException ex)
public static void Server () throws IOException
ServerSocket serverSocket=null;
int portNo=4500;
System.out.println("Starting");
try
serverSocket=new ServerSocket(portNo);
catch (IOException ex)
System.err.println("Could not create socket on port" +portNo);
System.exit(1);
System.out.println("Socket listening");
Socket clientSocket=null;
try
clientSocket=serverSocket.accept();
catch (IOException ex)
System.out.println("Accept failed");
System.exit(1);
PrintWriter out= new PrintWriter(clientSocket.getOutputStream(), true);
BufferedReader in=new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
//coordinates
String coordinates[] [] = new String [8] [8];
for (int i=0;i<8;i++)
for (int j=0;j<8;j++)
if ((i%2!=0)&&(j%2!=0))
coordinates[i] [j]="#";
else if ((i%2!=0)&&(j%2==0))
coordinates[i] [j]=" ";
else if ((i%2==0)&&(j%2!=0))
coordinates[i] [j]=" ";
else
coordinates[i] [j]="#";
coordinates[0][0]="R";
coordinates[0][1]="N";
coordinates[0][2]="B";
coordinates[0][3]="Q";
coordinates[0][4]="K";
coordinates[0][5]="B";
coordinates[0][6]="N";
coordinates[0][7]="R";
for (int i=0;i<8;i++)
coordinates[1]="P";
coordinates[7][0]="r";
coordinates[7][1]="n";
coordinates[7][2]="b";
coordinates[7][3]="q";
coordinates[7][4]="k";
coordinates[7][5]="b";
coordinates[7][6]="n";
coordinates[7][7]="r";
for (int i=0;i<8;i++)
coordinates[6][i]="p";
Board board1=new Board(coordinates);
boolean gameStart=true;
String coord="";
String originX="";
String originY="";
String destinationX="";
String destinationY;
while (gameStart)
System.out.println("trying to read from client");
String input="";
try
input=in.readLine();
System.out.println(input);
catch (IOException ex)
System.out.println("Read failed");
System.exit(1);
originX=input.substring(65);
originY=input.substring(66);
destinationX=input.substring(67);
destinationY=input.substring(68);
coord=input.substring(0,64);
System.out.println(coord);
for (int p=0;p<64;p++)
System.out.println(p);
for (int i=0;i<8;i++)
for (int j=0;j<8;j++)
coordinates [i] [j]=coord.substring(p);
if (i==(Integer.parseInt(originX))&&(j==(Integer.parseInt(originY))))
String piece="";
piece=coordinates [i] [j];
if ((i%2!=0)&&(j%2!=0))
coordinates[i] [j]="#";
else if ((i%2!=0)&&(j%2==0))
coordinates[i] [j]=" ";
else if ((i%2==0)&&(j%2!=0))
coordinates[i] [j]=" ";
else
coordinates[i] [j]="#";
for (int s=0;s<8;s++)
for (int t=0;t<8;t++)
if (s==(Integer.parseInt(destinationX))&&(t==(Integer.parseInt(destinationY))))
coordinates [s] [t]=piece;
board1.printBoard(coordinates);
out.close();
in.close();
clientSocket.close();
serverSocket.close();
class Board
boolean gameStart=true;
public Board()
public Board(String [] [] coordinates)
printBoard(coordinates);
String [] [] getCoOrdinates(String [] [] coordinates)
return coordinates;
public static void update (String coordinates [] [])
printBoard(coordinates);
public static void printBoard(String coordinates[] [])
for (int i=0;i<8;i++)
for (int j=0;j<8;j++)
System.out.print(coordinates[i][j]);
System.out.println();
}Client code:import java.io.*;
import java.net.*;
import javax.swing.JOptionPane;
class Client
public static void main (String [] args) throws IOException
Socket socket=null;
PrintWriter out=null;
BufferedReader in=null;
String serverLocation="localhost";
int portNo=4500;
System.out.println("Starting");
try
socket= new Socket (serverLocation,portNo);
out= new PrintWriter(socket.getOutputStream(),true);
in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
catch (UnknownHostException ex)
System.out.println("Cannot find" + serverLocation);
System.exit(1);
catch (IOException ex1)
System.out.println("IO problem");
System.exit(1);
System.out.println("Connected");
//coordinates
String coordinates[] [] = new String [8] [8];
for (int i=0;i<8;i++)
for (int j=0;j<8;j++)
if ((i%2!=0)&&(j%2!=0))
coordinates[i] [j]="#";
else if ((i%2!=0)&&(j%2==0))
coordinates[i] [j]=" ";
else if ((i%2==0)&&(j%2!=0))
coordinates[i] [j]=" ";
else
coordinates[i] [j]="#";
coordinates[0][0]="R";
coordinates[0][1]="N";
coordinates[0][2]="B";
coordinates[0][3]="Q";
coordinates[0][4]="K";
coordinates[0][5]="B";
coordinates[0][6]="N";
coordinates[0][7]="R";
for (int i=0;i<8;i++)
coordinates[1][i]="P";
coordinates[7][0]="r";
coordinates[7][1]="n";
coordinates[7][2]="b";
coordinates[7][3]="q";
coordinates[7][4]="k";
coordinates[7][5]="b";
coordinates[7][6]="n";
coordinates[7][7]="r";
for (int i=0;i<8;i++)
coordinates[6][i]="p";
Board board1=new Board(coordinates);
boolean gameStart=true;
String coord="";
while (gameStart)
String originMove=JOptionPane.showInputDialog(null,"Client Origin Move","Enter in origin of piece",JOptionPane.QUESTION_MESSAGE);
String destinationMove=JOptionPane.showInputDialog(null,"Client Destination Move","Enter in destination of piece",JOptionPane.QUESTION_MESSAGE);
for (int i=0;i<8;i++)
for (int j=0;j<8;j++)
coord=coord+coordinates[i][j];
System.out.println(coord);
out.println(coord+originMove+destinationMove);
System.out.println("passed");
out.close();
in.close();
socket.close();
class Board
boolean gameStart=true;
public Board()
public Board(String [] [] coordinates)
printBoard(coordinates);
String [] [] getCoOrdinates(String [] [] coordinates)
return coordinates;
public static void update (String coordinates [] [])
printBoard(coordinates);
public static void printBoard(String coordinates[] [])
for (int i=0;i<8;i++)
for (int j=0;j<8;j++)
System.out.print(coordinates[i][j]);
System.out.println();
}Cheers,
Benjverd wrote:
p595659 wrote:
1) I don't think that even compiles. Since you're catching IOException, your throws clause is bogus--that method can never throw IOE.I have removed the try and catch statements in the main method. I cannot, however get rid of the throws IOException in the main method other my program won't compile.Right. Don't catch it, since you're not handling it. Just declare that it throws it.
Indeed, this is what I have done :)
>
3) Don't name methods the same as your class name.See answer to 4.
4) Start method names with lowercase letters.
try
serverSocket=new ServerSocket(portNo);
catch (IOException ex)
System.err.println("Could not create socket on port" +portNo);
System.exit(1);
ServerSocket is a part of the java.net package. I am just creating an instance of it. http://java.sun.com/j2se/1.4.2/docs/api/java/net/ServerSocket.html
I don't know what you're talking about. You had a class named Server and a method named Server. That's confusing.Changed- I didn't spot it, so I have named it startServer now.
>
5) There's almost no point to ever calling System.exit. Here, again, since you're not
actually handling the exception, don't bother catcing it.Sorry, but this was how I was taught when I started java. My understanding is that System.exit properly terminated applications so this freed up memory so it's abit of a habit of mine, is this wrong to do in this instance?Calling it in response to an exception is wrong. It's not that method's job to decide to shut down the VM. Just let the exception bubble up (or else handle it properly). You do not need to call System.exit to free up memory. It's freed up automatically when the VM exits. The OS takes care of that, without any help from you.Removed- thanks for clearing that up for me :)
JacobsB wrote:
line 151 of the server code or client code?Line 151 of my server code. My client is working fine up to this step of the programming I have done- it's just the server part I'm having issues with. You can compile and run the client fine- you can compile the server but as explained in the original post, I'm having a logical error when redrawing the board when it gets the 68 charecter string from the client (first 64 charecters are for the board, then the original position (x and y respectively), followed up the new position (x and y respectively again).
I'm including an updated version of the code, after all the comments above so we have an updated version for trying to solve the problem I'm having. The client code does not need to be updated as it has not changed yet, so you can use the code in the original post.
import java.io.*;
import java.net.*;
import javax.swing.JOptionPane;
class Server
public static void main (String []args) throws IOException
startServer();
public static void startServer () throws IOException
ServerSocket serverSocket=null;
int portNo=4500;
System.out.println("Starting");
try
serverSocket=new ServerSocket(portNo);
catch (IOException ex)
System.err.println("Could not create socket on port" +portNo);
ex.printStackTrace();
System.out.println("Socket listening");
Socket clientSocket=null;
try
clientSocket=serverSocket.accept();
catch (IOException ex)
System.out.println("Accept failed");
ex.printStackTrace();
PrintWriter out= new PrintWriter(clientSocket.getOutputStream(), true);
BufferedReader in=new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
//coordinates
String coordinates[] [] = new String [8] [8];
for (int i=0;i<8;i++)
for (int j=0;j<8;j++)
if ((i%2!=0)&&(j%2!=0))
coordinates[i] [j]="#";
else if ((i%2!=0)&&(j%2==0))
coordinates[i] [j]=" ";
else if ((i%2==0)&&(j%2!=0))
coordinates[i] [j]=" ";
else
coordinates[i] [j]="#";
coordinates[0][0]="R";
coordinates[0][1]="N";
coordinates[0][2]="B";
coordinates[0][3]="Q";
coordinates[0][4]="K";
coordinates[0][5]="B";
coordinates[0][6]="N";
coordinates[0][7]="R";
for (int i=0;i<8;i++)
coordinates[1]="P";
coordinates[7][0]="r";
coordinates[7][1]="n";
coordinates[7][2]="b";
coordinates[7][3]="q";
coordinates[7][4]="k";
coordinates[7][5]="b";
coordinates[7][6]="n";
coordinates[7][7]="r";
for (int i=0;i<8;i++)
coordinates[6][i]="p";
Board board1=new Board(coordinates);
boolean gameStart=true;
String coord="";
String originX="";
String originY="";
String destinationX="";
String destinationY;
while (gameStart)
System.out.println("trying to read from client");
String input="";
try
input=in.readLine();
System.out.println(input);
catch (IOException ex)
System.out.println("Read failed");
ex.printStackTrace();
coord=input.substring(0,64);
originX=input.substring(64,65);
originY=input.substring(65,66);
destinationX=input.substring(66,67);
destinationY=input.substring(67,68);
System.out.println(coord);
for (int p=0;p<64;p++)
System.out.println(p);
for (int i=0;i<8;i++)
for (int j=0;j<8;j++)
coordinates [i] [j]=coord.substring(p);
if (i==Integer.parseInt(originX)&&(j==(Integer.parseInt(originY))))
String piece="";
piece=coordinates [i] [j];
if ((i%2!=0)&&(j%2!=0))
coordinates[i] [j]="#";
else if ((i%2!=0)&&(j%2==0))
coordinates[i] [j]=" ";
else if ((i%2==0)&&(j%2!=0))
coordinates[i] [j]=" ";
else
coordinates[i] [j]="#";
for (int s=0;s<8;s++)
for (int t=0;t<8;t++)
if (s==(Integer.parseInt(destinationX))&&(t==(Integer.parseInt(destinationY))))
coordinates [s] [t]=piece;
board1.printBoard(coordinates);
out.close();
in.close();
clientSocket.close();
serverSocket.close();
class Board
boolean gameStart=true;
public Board()
public Board(String [] [] coordinates)
printBoard(coordinates);
String [] [] getCoOrdinates(String [] [] coordinates)
return coordinates;
public static void update (String coordinates [] [])
printBoard(coordinates);
public static void printBoard(String coordinates[] [])
for (int i=0;i<8;i++)
for (int j=0;j<8;j++)
System.out.print(coordinates[i][j]);
System.out.println();
}Ben -
I need help with my for loop in this array
Ok well, I can't get my code to work. Also, please remember that this is just my draft so it isnt pretty. I will fix it up later so please look at it. The thing I want to do is look into the array for a time that matches what the user entered and return the toString() of that one. I know there is something wrong with my for loop but I cant figure how to fix it. please help. here is what i have so far:
import javax.swing.JOptionPane;
public class Runner
public static void main (String[] args)
String timeStr;
int time, again, optiStr;
Inbound[] in = new Inbound[25];
in[0]=new Inbound ("",0,"On Time num0");
in[1]=new Inbound ("",2,"On Time num1");
in[2]=new Inbound ("",3,"Delayed num2");
in[3]=new Inbound ("",4,"On Time");
in[4]=new Inbound ("",5,"On Time");
in[5]=new Inbound ("",6,"Canceled");
in[6]=new Inbound ("",1,"Canceled num6");
in[7]=new Inbound ("",8,"On Time");
in[8]=new Inbound ("",9,"Delayed");
in[9]=new Inbound ("",10,"On Time");
in[10]=new Inbound ("",11,"Delayed");
in[11]=new Inbound ("",12,"On Time");
in[12]=new Inbound ("",13,"Delayed");
in[13]=new Inbound ("",14,"On Time");
in[14]=new Inbound ("",15,"On Time");
in[15]=new Inbound ("",16,"On Time");
in[16]=new Inbound ("",17,"Canceled");
in[17]=new Inbound ("",18,"On Time");
in[18]=new Inbound ("",19,"On Time");
in[19]=new Inbound ("",20,"Canceled");
in[20]=new Inbound ("",21,"On Time");
in[21]=new Inbound ("",22,"Delayed");
in[22]=new Inbound ("",23,"On Time");
in[23]=new Inbound ("",24,"Cancled");
in[24]=new Inbound ("",7,"On Time num24");
do{
timeStr = JOptionPane.showInputDialog ("In military time, what hour do you want?");
time = Integer.parseInt(timeStr);
if (time<=0 || time>24)
JOptionPane.showMessageDialog (null, "Error");
optiStr = JOptionPane.showConfirmDialog (null, "If you want Incoming flights click Yes, but if not click No");
if (optiStr==JOptionPane.YES_OPTION)
//(ok this is the for loop i am talking about )
for (int index = 0; index < in.length; index++)
if ( time == Inbound.getTime())
JOptionPane.showMessageDialog (null, Inbound.tostring()); //return the time asked for
// else JOptionPane.showMessageDialog (null, "else");
}//temp return else if failed to find time asked for
// else
// if (optiStr==JOptionPane.CANCEL_OPTION)
// JOptionPane.showMessageDialog(null,"Canceled");
// else
// {Outbound.run();
// JOptionPane.showMessageDialog (null, "outbound");}//temp
again=JOptionPane.showConfirmDialog(null, "Try again?");
while (again==JOptionPane.YES_OPTION);
}any help would be greatly appriciated.rumble14 wrote:
Ok well, I can't get my code to work. Also, please remember that this is just my draft so it isnt pretty. I will fix it up later so please look at it. The thing I want to do is look into the array for a time that matches what the user entered and return the toString() of that one. I know there is something wrong with my for loop but I cant figure how to fix it. please help. here is what i have so far:
>//(ok this is the for loop i am talking about )
for (int index = 0; index < in.length; index++)
if ( time == Inbound.getTime())
JOptionPane.showMessageDialog (null, Inbound.tostring()); //return the time asked for
Inbound.getTime() is a static method of your Inbound class, that always returns the same value, I presume? As opposed to each of the 25 members of your array in, which have individual values?
Edited by: darb on Mar 26, 2008 11:12 AM -
How do i sweep two voltage at the same time by using for loop ?
Hello, Can anyone help me on this topic ?
My problem is to sweep Vds and Vgs as same time vs Id in MOSFET by using for loop. I also use the Agilent power supply source. Let me tell a litle bit about what i'm doing. For different value of Vds, i will get Vgs vs Id curve. (The x axis is Vgs, the y-axis is Id).
I started to create two for-loop, the inner to sweep Vgs, and the outer one to sweep Vds. My problem is don't know how to connect all the wire in the for loop.
In the for loop i saw N, i icon. Suppose I have the two variable for Vgs such as Vgs start and Vgs_stop. Should the Vgs_start( or Vgs_stop) be connected to N or leave it in the for_loop ?
for example: I want to sweep Vgs from 0(for Vgs_start) to 5(Vgs_strop) V, and the step increment is .5V how do i connect these variables in the for loop ?
Thank you for your time
Ti NguyenIt is easier to use a while loop. Dennis beat me to the punch. Here is my solution:
You can remove the flat sequence structure if you use Error In and Error Out to ensure the execution flow will occur in the proper order. Be sure to include the delay time in the loop so that your vi doesn't hog all the CPU time.
Message Edited by tbob on 10-17-2005 01:00 PM
- tbob
Inventor of the WORM Global
Attachments:
RampVoltage.PNG 8 KB -
How can I move a loop in Mac version. It's easy on iPad
Hi,
I just want to move a loop back and forth on the track. I can do it easily on an iPad but every time I try to move it in the Mac version it shortens or lenghthens the loop but it will not let me move the position. Tearing hair out after trying for hours to grab the loop somehow. What is the secret?
I'm using Mavericks with the latest Garageband.
DaveDave,
you have to hold down on the loop right on the center of the loop, not close to the ends. Then drag and hold the loop to move it.The cursor should remain an arrow and not turn into a bracket. If you see a bracket-shaped cursor, you will trim the loop instead of moving it.
Léonie -
Using a For loop to call one array element at a time
I have been working on a VI that reads a GPS unit, parses the data, outputs what I need, compares the actual GPS location to the desired location, determines a desired heading and moves on from there. My question pertains to the number of desired locations I can input right now. I need to be able to input a predtermined number of locations (not just the one that I can input right now). I was told that it is possible to use a For Loop with an array and have the first set of Lat and Long values run through the VI and when everything is complete that the next set of values will be chosen. Does this mean that I need to put the entire VI inside a For Loop and have the array update as soon as the VI has completed its first mission? I understand the concept of how this work from other programming languages but I'm not sure how to implement the solution in LabVIEW. Any help would be appreciated.
Adamadamoutlaw wrote:
Here is a portion of the VI. I need two separate arrays, one for Latitude and one for Longitude, of the same size.
I don't see any arrays in your code. Do you want to generate arrays form individual data points or do you want to process arrays, one element at a time? Both can take advantage of autoindexing. Here's a simple picture.
Your VI contains a weird mix of DBL and EXT precision. Most likely all you need is DBL. Keep your representations consistent!
Message Edited by altenbach on 08-02-2007 07:14 AM
LabVIEW Champion . Do more with less code and in less time .
Attachments:
Indexing.png 4 KB -
How can I make a Java program pyramid using for loops??
Hi guys, so I'm stuck with my program here... I don't know how to make it work, and i've been trying really hard.. So now i give up and need some guidance.. Please help me here.
Your job in this assignment is to write programs to solve each of these six problems.
1. Write a GraphicsProgram subclass that draws a pyramid consisting of bricks
arranged in horizontal rows, so that the number of bricks in each row decreases by
one as you move up the pyramid, as shown in the following sample run:
The pyramid should be centered at the bottom of the window and should use
constants for the following parameters:
BRICK_WIDTH The width of each brick (30 pixels)
BRICK_HEIGHT The height of each brick (12 pixels)
BRICKS_IN_BASE The number of bricks in the base (14)
The numbers in parentheses show the values for this diagram, but you must be able
to change those values in your program.
* File: Pyramid.java
* Name:
* Section Leader:
* This file is the starter file for the Pyramid problem.
* It includes definitions of the constants that match the
* sample run in the assignment, but you should make sure
* that changing these values causes the generated display
* to change accordingly.
import acm.graphics.*;
import acm.program.*;
import java.awt.*;
public class Pyramid extends GraphicsProgram {
/** Width of each brick in pixels */
private static final int BRICK_WIDTH = 30;
/** Width of each brick in pixels */
private static final int BRICK_HEIGHT = 12;
/** Number of bricks in the base of the pyramid */
private static final int BRICKS_IN_BASE = 14;
public void run() {
}That's my problem.yo, so i figure out my for loop. my code is very very very very ugly, so dont laugh i know its ugly! just wanna ask for some tips
public void run() {
int initBrick = 30;
int initPlacement = (getWidth() - BRICK_WIDTH) / 2;
for (int i = 0; i < initBrick; i += 30)
int initX = i;
int x = initX + initPlacement;
GRect brick = new GRect(x, 0, BRICK_WIDTH, BRICK_HEIGHT);
add(brick);
for (int i = 0; i < 60; i += 30)
int initX = i;
int x = (initX + initPlacement) - 15;
int y = 12;
GRect brick = new GRect(x, y, BRICK_WIDTH, BRICK_HEIGHT);
add(brick);
for (int i = 0; i < 90; i += 30)
int initX = i;
int x = (initX + initPlacement) - 30;
int y = 24;
GRect brick = new GRect(x, y, BRICK_WIDTH, BRICK_HEIGHT);
add(brick);
for (int i = 0; i < 120; i += 30)
int initX = i;
int x = (initX + initPlacement) - 45;
int y = 36;
GRect brick = new GRect(x, y, BRICK_WIDTH, BRICK_HEIGHT);
add(brick);
for (int i = 0; i < 150; i += 30)
int initX = i;
int x = (initX + initPlacement) - 60;
int y = 48;
GRect brick = new GRect(x, y, BRICK_WIDTH, BRICK_HEIGHT);
add(brick);
for (int i = 0; i < 180; i += 30)
int initX = i;
int x = (initX + initPlacement) - 75;
int y = 60;
GRect brick = new GRect(x, y, BRICK_WIDTH, BRICK_HEIGHT);
add(brick);
for (int i = 0; i < 210; i += 30)
int initX = i;
int x = (initX + initPlacement) - 90;
int y = 72;
GRect brick = new GRect(x, y, BRICK_WIDTH, BRICK_HEIGHT);
add(brick);
for (int i = 0; i < 240; i += 30)
int initX = i;
int x = (initX + initPlacement) - 105;
int y = 84;
GRect brick = new GRect(x, y, BRICK_WIDTH, BRICK_HEIGHT);
add(brick);
for (int i = 0; i < 270; i += 30)
int initX = i;
int x = (initX + initPlacement) - 120;
int y = 96;
GRect brick = new GRect(x, y, BRICK_WIDTH, BRICK_HEIGHT);
add(brick);
for (int i = 0; i < 300; i += 30)
int initX = i;
int x = (initX + initPlacement) - 135;
int y = 108;
GRect brick = new GRect(x, y, BRICK_WIDTH, BRICK_HEIGHT);
add(brick);
for (int i = 0; i < 330; i += 30)
int initX = i;
int x = (initX + initPlacement) - 150;
int y = 120;
GRect brick = new GRect(x, y, BRICK_WIDTH, BRICK_HEIGHT);
add(brick);
for (int i = 0; i < 360; i += 30)
int initX = i;
int x = (initX + initPlacement) - 165;
int y = 132;
GRect brick = new GRect(x, y, BRICK_WIDTH, BRICK_HEIGHT);
add(brick);
for (int i = 0; i < 390; i += 30)
int initX = i;
int x = (initX + initPlacement) - 180;
int y = 144;
GRect brick = new GRect(x, y, BRICK_WIDTH, BRICK_HEIGHT);
add(brick);
for (int i = 0; i < 420; i += 30)
int initX = i;
int x = (initX + initPlacement) - 195;
int y = 156;
GRect brick = new GRect(x, y, BRICK_WIDTH, BRICK_HEIGHT);
add(brick);
}So yeah, it's very ugly. not general. BUT now; I know the logic of the program..
I need to change 3 variables here.
the Y var, the X variable, and the size of the loop test..
so I need to make a one compact for loop that will change those 3 for every time the loop finish, or for every row the variable will change...
Ill try to think again, ill head to the balcony, and squeeze my brain. YEAH it took me this long to figure this out, anyway im a noob YET. But i was working a while ago.
ANYWAY, leave some tips please.. I NEED TIPS NOT SOLUTION -
Resetting a for loop counter and restarting the computation
I have a while loop nested inside a for loop to do a calculation of a model.
Lets say I am on the for loop counter 4. Suppose I wanted to keep track of the number of iterations on one the while loop, and if it exceeded a certain number say 100, exit the while loop. I am doing this to avoid my model calculation being stuck at a spot due to optimization issues. I now want to restart the calculations of for loop counter 4.
Is there a way to do this in labview?
Solved!
Go to Solution.Well first of all, if you are going to restart the loop with the same program inside it after it got stuck is it not just going to get stuck again creating a permanent loop in the code? Would you not just want to move on and have some sort of identifier that one of the for-loops got stuck?
But I would recommend simply nesting your while-loop inside of another while loop, then connect the exit for the out while-loop to some variable from the inner while-loop, so if the optimization did not occur properly then it simply repeats the inner while-loop.
Although I stick by my thoughts that you will just end up in a permanent loop if the optimization fails the first time. -
Remove text field from Array via for loop
Hi,
i have a problem to remove text fields added via for loop.
That im doing is, via for loop im dynamically creating menu with 10 buttons.
Each button contain, dynamically created, background (shape) and text field.
And everything is fine.
But when im try to remove text fields then i got this error:
- Im using button to remove text fields - lang_btn.addEventListener(MouseEvent.CLICK, clickHandler);
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/removeChild()
at Loading_Img_fla::MainTimeline/xmlLoaded()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
In the script bellow marked with red is what should remove text fields from an Array, instead giving me error.
Here is my script
// Create for loop
for (var i:int = 0; i < 10; i++)
for each (xml in listItems)
if (i == xml.attribute("Id"))
// Add MovieClip to stage to hold the data
addChild(lmHolder);
lmHolder.x = 0;
lmHolder.y = 0;
// Create new MovieClip to hold buttons
lmButtonsMCArray[i] = new MovieClip();
lmButtonsMCArray[i].buttonMode = true;
lmButtonsMCArray[i].mouseChildren = false;
lmButtonsMCArray[i].x = 20;
lmButtonsMCArray[i].y = 20 + btCount * buttonSpace;
// Add each button MovieClip to lmHolder MovieClip
lmHolder.addChild(lmButtonsMCArray[i]);
// Create Background to buttons
lmButtonsArray[i] = new Shape();
lmButtonsArray[i].graphics.beginFill(lmBgColor0, 1);
lmButtonsArray[i].graphics.drawRect(0, 0, 230, 85);
lmButtonsArray[i].x = 0;
lmButtonsArray[i].y = 0;
// <<-- Add Background shape to the buttons MovieClips
lmButtonsMCArray[i].addChild(lmButtonsArray[i]);
// Create a new array to preserve data from XML List
lmNameArrayEG = new Array();
lmNameArrayUS = new Array();
// Create local variable to hold
var lmTxtFieldContentUS:String;
var lmTxtFieldContentEG:String;
var lmTxtContent:String;
// If clicked button is EG then make array with Arabic text
// If clicked button is US then make array with English text
if (footer.lang_btn.langState == "EG")
for each (var leftMenuName:XML in egLanguageList)
lmNameArrayEG.push(leftMenuName);
lmTxtFieldContentEG = lmNameArrayEG[i];
lmTxtContent = lmTxtFieldContentEG;
else
for each (var leftMenuNameUS:XML in usLanguageList)
lmNameArrayUS.push(leftMenuNameUS);
lmTxtFieldContentUS = lmNameArrayUS[i];
lmTxtContent = lmTxtFieldContentUS;
// Setup new text field each time script is executed
lmTxtFieldsArray[i] = new TextField();
lmTxtFieldsArray[i].width = 110;
lmTxtFieldsArray[i].border = false;
lmTxtFieldsArray[i].wordWrap = true;
lmTxtFieldsArray[i].multiline = true;
lmTxtFieldsArray[i].selectable = false;
lmTxtFieldsArray[i].embedFonts = true;
lmTxtFieldsArray[i].antiAliasType = AntiAliasType.ADVANCED;
lmTxtFieldsArray[i].autoSize = TextFieldAutoSize.CENTER;
lmTxtFieldsArray[i].text = lmTxtContent.toUpperCase();
lmTxtFieldsArray[i].x = 10;
lmTxtFieldsArray[i].name = "lmTxtFieldName" + i;
// <<-- Add Text fields to the Movie Clip
lmButtonsMCArray[i].addChild(lmTxtFieldsArray[i]);
// If clicked button is EG then set Arabic text format, and make array with Arabic text fields
// If clicked button is US then set English text format, and make array with Egnlish text fields
if (footer.lang_btn.langState == "EG")
lmTxtFieldsArray[i].setTextFormat(txtFormat_lm_eg);
// Make array from text fields;
pushEgTFintoArray.push(lmTxtFieldsArray[i]);
else
lmTxtFieldsArray[i].setTextFormat(txtFormat_lm_us);
// Make array from text fields;
pushUsTFintoArray.push(lmTxtFieldsArray[i]);
// If clicked button is EG then loop thrue the for loop and remove English text fields from array
// If clicked button is EG then loop thrue the for loop and remove Arabic text fields from array
if (footer.lang_btn.langState == "EG")
for (var rNr_us:Number = 0; rNr_us < pushUsTFintoArray.length; rNr_us++)
//remove the text field array from the display
removeChild(pushUsTFintoArray[rNr_us]);
//clear the array
pushUsTFintoArray = [];
else
for (var rNr_eg:Number = 0; rNr_eg < pushEgTFintoArray.length; rNr_eg++)
//remove the text field array from the display
removeChild(pushEgTFintoArray[rNr_eg]);
//clear the array
pushEgTFintoArray = [];
btCount++;it looks like those tf's are children of lmButtonsMCArray[i], not the current scope. use:
if (footer.lang_btn.langState == "EG")
for (var rNr_us:Number = 0; rNr_us < pushUsTFintoArray.length; rNr_us++)
//remove the text field array from the display
lmButtonsMCArray[rNr_us].removeChild(pushUsTFintoArray[rNr_us]);
//clear the array
pushUsTFintoArray = [];
else
for (var rNr_eg:Number = 0; rNr_eg < pushEgTFintoArray.length; rNr_eg++)
//remove the text field array from the display
lmButtonsMCArray[rNr_eg].removeChild(pushEgTFintoArray[rNr_eg]);
//clear the array
pushEgTFintoArray = []; -
Help me move my loops to external drive
I want to move my loops to an external drive to free up space on my laptop drive. Can someone offer a clear, understandable tutorial on how to do this?
I've got my head spinning after spending the last couple days trying to figure this out, as I keep getting widely different responses, plus I've heard that jampack4 puts the loops into a different folder than earlier jampacks.
Is there a simple, understandable way to do this? I didn't think it would be so confusing to just move a folder, but which folder or folders is it.
Thanks,
RandallThis might help you out...
http://logic-users.org/forums/LUG/thread/93444
Although.....Simply creating a alias has worked for me.
Ezzzzz
PowerMac G5 Dual 2.5 Mac OS X (10.4.7) -
Is it possible to use a "for loop" structure to represent DAQ of 16 channels?
Hi,
I tried to search but I failed to find a similar problem so I am posting this problem here.
I have a temperature DAQ board which has 16 channels, and I am using all 16 channels to record and monitor temperature data.
When I writed blocks for all 16 channels, a mess was created (as you can see in my attached program). I have noticed that all the VIs for the 16 channels have similar structure, so I was thinking whether we can represent all 16 channels with a "for loop" strucutre with a pointer i scanning from i=1 to 16 as we usually do in Matlab or Fortran.
For instance, we may try to simplify the code like:
for i=1:1:16
acquire data from channel i
show data from channel i in X-Y graph
write data from channel i to excel in every 10 seconds
end
I could not do it myself because I cannot find a "pointer" to represent each channel.
Does anyone know how to do this in LabVIEW? Thank you.
It is said that it is best if we can put all of our code within the screen of a monitor we use by using subVIs to divide the code into many subroutines. But I found it quite difficult to do so as I have too many controls as inputs and indicators as outputs. Also, I use property node to read and write frequently, which make things harder....
Attached code does not work as it requires the 9213 hardware, and for simplicity I deleted irrelavent modules. But if you need I can upload one that may work by modifying the read VI.
Thank you.
Attachments:
ask for help.vi 132 KBYup, instead of all these 1D arrays, use a single 2D array. Your code could be reduce to <10% of the current size. I am sure it would fit easily on a single screen.
Also try to do some tutorial or take some courses. I realy don't think you are ready to tackle a system of this magnitude at this time.
Your code is just peppered with very poor choices. Some things you apparently haven't figured out:
index array is resizable. There is no need to create dozens of parallel instances, all wired to the same array and all with a unique index diagram constant. If you want all elements in order, the indices don't need to be wired at all.
Replace all your value property nodes with local variables. Much more efficient. Then redesign the code so you don't even need most of the local variables.
You can use built array to append elements to an existing array. Using "insert into array" is much more complicated an error prone.
It is not a good idea to have deeply stacked while loops with the innermost loop having long delays and indeterminate stop conditions. That just gums up the gears.
Learn about proper code architectures, state machines, etc.
Get rid of that gigantic, all encompassing stacked sequence. I am sure you can find a better way to reset three booleans when the code is about to stop. In fact it is typically more reasonable to set things to a defined state when the program starts to avoid problems due to accidental value changes at edit time.
Don't use hidden control/indicators as data storage and interloop communication via local variables. There are better ways.
You can wire the reminder or Q&R directly to a case structure. No need for e.g. "=0".
Don't use ambiguous labels, e.g.a boolean labeled "Dampers on or off". Nobody will be able to later figure out if TRUE corresponds to ON or OFF. Could it be that TRUE mean it is either ON or OFF and FALSE that it is in some imternediate position?
LabVIEW Champion . Do more with less code and in less time .
Maybe you are looking for
-
Unable to load Facebook, Skype, etc. after the upd...
After software update of my my phone Lumia 535.Cant able to load any apps like facebook,skype ect.These apps were installed before upgrade. once trying to install manually from store its saying "We're having trouble installing this app.If this is the
-
Can't print from Mac to epson nx300 on Win7, even with networkmagic
I've spent days going over forums and can't seem to get this working. My main computer runs Win7 Home Premium x64 with an epson NX300 printer attached to it by USB. I have been able to print to it from another windows xp laptop. I recently bought an
-
HP Pavilion 15t Issues with Limited Internet Connectivity on Windows 8
So, I just received my new HP Pavilion 15t-e000 CTO Notebook PC last week, it runs Windows 8, & it's a 64 bit. The only problem I've had is staying connected to my wireless Internet. The connection will cut out at random intervals saying "Limited" in
-
I tried to update my Apple TV (per message displayed). The system began an update 1 of 2. I didn't see if it completed both updates, but now all I can see is a large iTunes icon displayed with an image of a wire with a USB connection. The Apple TV
-
SELECT name,telephone FROM Customer where cid IN (SELECT cid FROM Order where oid IN (SELECT oid FROM OrderDetal where icode IN (SELECT icode FROM item where itemName='Dry Fish 200g'))); How can I convert this query to Natural join? Thanks in Advance