Controlling 2 "for" loops
Hi,
I need a particular control of 2 "for" loops. It goes like this:
for(int j=1;j<5;j+3){
for(int i=0;i<20;i++){
//do something
}However, when the for loop for "i" ends it is coming out of both the for loops. I don't want this. But what I want is:
The loop for i should go on till all the 20 iterations of i and then it must go out of the loop and then only j should be incremented.
[Actually I want all possible combinations of i with a single j. ]
Thanks
kooldba wrote:
Hi,
I need a particular control of 2 "for" loops. It goes like this:
for(int j=1;j<5;j+3){
for(int i=0;i<20;i++){
//do something
}However, when the for loop for "i" ends it is coming out of both the for loops. I don't want this. It is only doing this if "do something" includes one of the following:
- labeled break to a label outside of both loops.
- labeled continue to a label outside of both loops.
- return
- an exception being thrown
- j being set to some value >= 5
But what I want is:
The loop for i should go on till all the 20 iterations of i and then it must go out of the loopThat is exactly what is happening, unless "do something" includes one of the following
- break
- continue
- return
- exception being thrown
- i being given other values
and then only j should be incremented.The above code does not have an increment statement for j, so unless j is incremented in "do something", it will never be incremented, and the inner for loop will repeat endlessly.
[Actually I want all possible combinations of i with a single j. ]This is exactly what a properly written nested for loop gives.
Note the difference in the following compared to your j control.
for(int j=1;j<5;j+=3){
for(int i=0;i<20;i++){
System.out.println("j=" + j + ", i=" + i);
System.out.println("incrementing j");
}
Similar Messages
-
I have a while loop (outside) and a for loop (inside) and a control button within the for loop. I want to stop the program by click the botton without finishing the for loop. How can I do that?
Thank you in advance.HI Please find attached snapshot Regards, Santosh
Message Edited by SanRac on 12-17-2009 05:12 AM
Message Edited by SanRac on 12-17-2009 05:13 AM
Attachments:
Snap1.png 4 KB -
How to control the looping time of the for loop in 10 microseconds in labview?
I need to create a +/- 9 volt square wave with period of 20us using a D/A card (Not NI card). I can write command to the card using outport provide by Labview. Right now, I can generate square wave with 4ms period which is limited by the resolution of the wait until next ms icon I used inside the for loop. Could anyone tell me how to control the execution time of the for loop to about 10 us? Your help would be much appreciated.
I'm not sure if this will hep, but this answer seems to answer this question
http://exchange.ni.com/servlet/ProcessRequest?RHIVEID=101&RPAGEID=135&HOID=50650000000800000029410000&UCATEGORY_0=_30_%24_12_&UCATEGORY_S=0&USEARCHCONTEXT_QUESTION_0=microsecond+resolution+1ms&USEARCHCONTEXT_QUESTION_S=0 -
Dual loop control for positioning system.-- motion ocntrol
I am currently doing a dual loop control for a positioning system, i use the tachometer to read the velocity and the position encoder about the position of the platform.
the problem i am currently encounter is that i am not sure weather the computer have the PID toolkit, because i can not find them under the control design and simulation module. so i did a PID use the basic labview functions, related information is in the attached documents.
i am not sure about the dt part, did the labview have this kind of function like to calculate the simpling time??
do i have to install the labview real_time potion? i am right using the labview 8.5
another question is that, how i am going to let the system remember the position instead of return to 0 every time i restarted the program? otherwise is there any other way that i can command the motor to move to the target position which is initially defined?
the last question is that that is it possible for me to generate a profile regarding the current and the desired position? to set a maximum velocity and acceleration.
i do not have a motion controller, so i did not install the motion and version module.
can some one suggest me a way to do this?
Solved!
Go to Solution.attached is the files.
Attachments:
Integral.vi 8 KB
Dt.vi 7 KB
A CLOSED-LOOP TEMPERATURE CONTROL SYSTEM.pdf 886 KB -
If statement doesn't affect for loop
I wrote a function within a function to control 2 Tweens.
(the 2nd one isnt in the function, it's called)
My problem is... is that it works for the first time.. the button is hovered over and all the other buttons show themselves and then disappear again, except the one you're over. Then I do it a 2nd time and it doesn't work. why is it only working right one time? and why isn't the if statement I put in the local function affecting the for loop? The 2nd time it takes the button you're hovering over with it and fades it out. (even though the if statement registers according to trace)
this is the code
import fl.transitions.Tween;
import fl.transitions.easing.*;
var shortInst:Array = [btn1, btn2, btn3, exit];
var objTween:Tween;
function mouseOff(e:Event):void {
if (e.currentTarget.alpha !== 0) {
objTween = new Tween(e.currentTarget, "alpha", None.easeOut, 1, 0, 0.25, true);
var eTimer:Timer = new Timer(3000, 1); //timer that only runs once (in ms)
function navFX(e:Event):void {
for (var i:Number = 0; i < shortInst.length; i++) {
objTween = new Tween(shortInst[i], "alpha", None.easeOut, 0, 1, 0.25, true);
eTimer.addEventListener(TimerEvent.TIMER, local);
eTimer.start();
function local(t:TimerEvent):void {
trace("e.target in local func: " + e.target);
for (var i:Number = 0; i < shortInst.length; i++) {
if (shortInst[i] !== e.target) {
shortInst[i].dispatchEvent(new Event(MouseEvent.MOUSE_OUT));is this what you want?
import fl.transitions.Tween;
import fl.transitions.easing.*;
var shortInst:Array = [btn1,btn2,btn3,exit];
var objTween:Tween;
function mouseOff(e:Event):void
if (e.currentTarget.alpha !== 0)
objTween = new Tween(e.currentTarget,"alpha",None.easeOut,1,0,0.25,true);
function navFX(e:Event):void
var eTimer:Timer = new Timer(3000,1); // <- moved that line here
for (var i:Number = 0; i < shortInst.length; i++)
objTween = new Tween(shortInst[i],"alpha",None.easeOut,0,1,0.25,true);
eTimer.addEventListener(TimerEvent.TIMER, local);
eTimer.start();
function local(t:TimerEvent):void
trace("e.target in local func: " + e.target);
for (var i:Number = 0; i < shortInst.length; i++)
if (shortInst[i] !== e.target)
shortInst[i].dispatchEvent(new Event(MouseEvent.MOUSE_OUT));
for (var i:Number = 0; i < shortInst.length; i++)
shortInst[i].alpha = 0;
shortInst[i].addEventListener(MouseEvent.MOUSE_OVER, navFX);
shortInst[i].addEventListener(MouseEvent.MOUSE_OUT, mouseOff); -
For loop stop in sub vi from main vi?
Hi! I want to control from my main vi a sub vi consisting of a stepped sine function generator. This sub vi has a for loop. The problem is that I want to have the option of terminating the loop in the sub vi from the main vi. I tryed using global variables or an event stucture. The problem is that, in both cases, the "stop" variable in my main vi is only updated after the loop terminates in the sub vi. Can anyone please help me? Thank you very much.
Best regards,
Diogo Montalvão (Lisbon, Portugal)hong2011 wrote:
I found this thread very helpful. May I ask one thing - what is the purpose of the Occurrence?? If I try it without implementing the Occurrence (neither in main VI or subVI), labview crashes when the subVI completes its task or is stopped from the mainVI.
A lot of things changed in the last 6 years, so this thread is a bit stale and there are a few other ways to do it. (For example we can have a FOR loop with a conditional terminal).
You don't provide enough information to answer your question why it crashes. It would be more interesting to know what you are "using" and not what you are "not using". This is not something we can guess by elimination.
LabVIEW should never crash, so please show us the code that crashes so NI can fix it. What LabVIEW version are you using?
LabVIEW Champion . Do more with less code and in less time . -
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 -
Display value in MATLAB For loop on LabView
Hi guys,
I have a MATLAB script in my VI. The MATLAB script runs a For Loop. For each iteration of the For Loop, a variable say, count is incremented by 1.
From what I am experiencing, the MATLAB script only outputs the final value of count when the script is done running.
Is it possible to capture the value of count as each iteration is performed?
PS : Using a LabView For loop is not possible for my case. Running the MATLAB code is mandatory.
Thank you in advance!When the Matlab script gets called, it's actually passing control over to the Matlab ActiveX server. Thus, LabVIEW has to wait until that's done before it can proceed. What you're asking for is interprocess communication. That doesn't come provided "out of the box". You have to create it yourself. Some ideas were suggested here: http://forums.ni.com/t5/LabVIEW/Labview-Matlab-Exchange-Data/td-p/1408054
-
In my program I would like to run a For loop inside of a While loop, and have them run independently, at their own execution rates. As a test, I wrote a simple VI with a While loop with 1 second timing, and into this I inserted a For loop with 3 second timing. I created indicators for both iteration terminals. Upon running the VI, I found the While loop waits for the For loop to run N times before the While loop executes again. I also found that sometimes the first iteration of the For loop will end at 1 second rather than 3 seconds, and the STOP button to terminate execution of the While loop does not always work.
Solved!
Go to Solution.ksinks wrote:
Thanks, how would you synchronize the loops? I have gone through the Getting Started exercises and manual.
Why would synchronization matter? Did you want them to run independantly at their own speed or not?
Regardless, there's a synchronization pallette with functions for this, as Occurance.
Other solutions include a common loop counter and a case structure executing every X'th iteration, or having the faster loop send a queue or event every X'th loop that controls the slower loop.
/Y
LabVIEW 8.2 - 2014
"Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
G# - Free award winning reference based OOP for LV -
How to use no of iteration of for loop as the input for the for loop
hi all,
i wanna need some help here..
i'm using for loop to iterate to ceratin no of iteration.. then, i would like to use back the no of iteration as the input of 'N' for the next iteration..
in other word, eg:
1st run:
i insert a control to 'N', let say 80
then the iteration run until 80-1 = 79..
2nd run:
i need to insert the no of "N", let say a control of 120.. i want the loop run for "120 - 79", where the 79 is the no of previous run..
easy to say,
how can i connect the "i' as a control to ''N''
n how to make a "run' or ' GO' and ''stop'' button in the front panel and block diagram after the first run without using the stop and run from the labview window
thanks..Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
Attachments:
Untitled 2.vi 9 KB -
How do I use For loop to check each node and import them to a new document?
In my function I would like to use a For loop to get all the statutes (xml) inside the object
objXmlBcaResponseDoc. In my case there are 2 statutes. I would like the output to look like the one I have posted here below. I am not sure how to do the For loop. The commented For loop is from another function but it is not working inside
this function.
The output is added into the **objXmlResponseMessageDoc** object and should look like this with 2 statutes (ns1:Statute) and a totalCount=2
<BasicSearchQueryResponse xmlns="http://crimnet.state.mn.us/mnjustice/statute/service/4.0">
<StatutesXml>
<Statutes runType="Request" runDateTime="2015-03-17T10:23:04" totalCount="2">
<ns1:Statute xmlns:ns1="http://crimnet.state.mn.us/mnjustice/statute/messages/4.0">
<StatuteId xmlns="http://crimnet.state.mn.us/mnjustice/statute/4.0">8471</StatuteId>
<Chapter xmlns="http://crimnet.state.mn.us/mnjustice/statute/4.0">60</Chapter>
<Section xmlns="http://crimnet.state.mn.us/mnjustice/statute/4.0">55</Section>
<Subdivision xmlns="http://crimnet.state.mn.us/mnjustice/statute/4.0"/>
</ns1:Statute>
<ns1:Statute>
<StatuteId xmlns="http://crimnet.state.mn.us/mnjustice/statute/4.0">9722</StatuteId>
<Chapter xmlns="http://crimnet.state.mn.us/mnjustice/statute/4.0">90</Chapter>
<Section xmlns="http://crimnet.state.mn.us/mnjustice/statute/4.0">25</Section>
<Subdivision xsi:nil="true" xmlns="http://crimnet.state.mn.us/mnjustice/statute/4.0"/>
</ns1:Statute>
</Statutes>
</StatutesXml>
</BasicSearchQueryResponse>
My xml doc is found inside objXmlBcaResponseDoc Here is xml inside
objXmlBcaResponseDoc object
<BasicSearchQueryResponse xmlns="http://crimnet.state.mn.us/mnjustice/statute/service/4.0">
<ns1:Statutes xmlns:ns1="http://crimnet.state.mn.us/mnjustice/statute/messages/4.0">
<ns1:Statute>
<StatuteId xmlns="http://crimnet.state.mn.us/mnjustice/statute/4.0">8471</StatuteId>
<Chapter xmlns="http://crimnet.state.mn.us/mnjustice/statute/4.0">60</Chapter>
<Section xmlns="http://crimnet.state.mn.us/mnjustice/statute/4.0">55</Section>
<Subdivision xsi:nil="true" xmlns="http://crimnet.state.mn.us/mnjustice/statute/4.0"/>
</ns1:Statute>
<ns1:Statute>
<StatuteId xmlns="http://crimnet.state.mn.us/mnjustice/statute/4.0">9722</StatuteId>
<Chapter xmlns="http://crimnet.state.mn.us/mnjustice/statute/4.0">90</Chapter>
<Section xmlns="http://crimnet.state.mn.us/mnjustice/statute/4.0">25</Section>
<Subdivision xsi:nil="true" xmlns="http://crimnet.state.mn.us/mnjustice/statute/4.0"/>
</ns1:Statute>
</BasicSearchQueryResponse>
Here is my function
Function GetStatutesByChapter(ByVal aobjXmlGetStatuteRequestNode As XmlNode, ByVal aobjXMLNameSpaceManager As XmlNamespaceManager, ByVal aobjBroker As ServiceCatalog.Library.v4.Broker) As XmlDocument
Dim objXmlRequestMessageDoc As XmlDocument
Dim objXmlResponseMessageDoc As XmlDocument
Dim intCount As Integer
aobjBroker.PostMessageWarehouseInformationalMessage("Chapter found.", 1)
objXmlResponseMessageDoc = New XmlDocument
'Add the first element into the document GetStatuteByChapter with its namespace
objXmlResponseMessageDoc.AppendChild(objXmlResponseMessageDoc.CreateElement("BasicSearchQueryResponse", "http://crimnet.state.mn.us/mnjustice/statute/service/4.0"))
'Build the initial response document
objXmlResponseMessageDoc = New XmlDocument
'Add the first element into the document GetStatutesResponse with its namespace
objXmlResponseMessageDoc.AppendChild(objXmlResponseMessageDoc.CreateElement("GetStatutesResponse", "http://www.courts.state.mn.us/StatuteService/1.0"))
'Add a child node to the GetStatutesResponse node
objXmlResponseMessageDoc.SelectSingleNode("ss:GetStatutesResponse", aobjXMLNameSpaceManager).AppendChild(objXmlResponseMessageDoc.CreateElement("StatutesXml", "http://www.courts.state.mn.us/StatuteService/1.0"))
objXmlResponseMessageDoc.SelectSingleNode("ss:GetStatutesResponse/ss:StatutesXml", aobjXMLNameSpaceManager).AppendChild(objXmlResponseMessageDoc.CreateElement("Statutes", "http://www.courts.state.mn.us/StatuteService/1.0"))
'Convert the node Statutes into an element and set the runType attribute (runType="Request") by adding it's value Request
CType(objXmlResponseMessageDoc.SelectSingleNode("ss:GetStatutesResponse/ss:StatutesXml/ss:Statutes", aobjXMLNameSpaceManager), System.Xml.XmlElement).SetAttribute("runType", "Request")
'Convert the node Statutes into an element and set the attribute (runDateTime="2015-03-05T10:29:40") by adding it
CType(objXmlResponseMessageDoc.SelectSingleNode("ss:GetStatutesResponse/ss:StatutesXml/ss:Statutes", aobjXMLNameSpaceManager), System.Xml.XmlElement).SetAttribute("runDateTime", Format(Now, "yyyy-MM-ddTHH:mm:ss"))
'Create the BCA request message
objXmlRequestMessageDoc = New XmlDocument
objXmlRequestMessageDoc.AppendChild(objXmlRequestMessageDoc.CreateElement("ns:BasicSearchQueryRequest", aobjXMLNameSpaceManager.LookupNamespace("ns")))
objXmlRequestMessageDoc.SelectSingleNode("ns:BasicSearchQueryRequest", aobjXMLNameSpaceManager).AppendChild(objXmlRequestMessageDoc.CreateElement("ns1:BasicSearchCriteria", aobjXMLNameSpaceManager.LookupNamespace("ns1")))
objXmlRequestMessageDoc.SelectSingleNode("ns:BasicSearchQueryRequest/ns1:BasicSearchCriteria", aobjXMLNameSpaceManager).AppendChild(objXmlRequestMessageDoc.CreateElement("ns2:Chapter", aobjXMLNameSpaceManager.LookupNamespace("st")))
objXmlRequestMessageDoc.SelectSingleNode("ns:BasicSearchQueryRequest/ns1:BasicSearchCriteria", aobjXMLNameSpaceManager).AppendChild(objXmlRequestMessageDoc.CreateElement("ns2:Section", aobjXMLNameSpaceManager.LookupNamespace("st")))
objXmlRequestMessageDoc.SelectSingleNode("ns:BasicSearchQueryRequest/ns1:BasicSearchCriteria", aobjXMLNameSpaceManager).AppendChild(objXmlRequestMessageDoc.CreateElement("ns2:Subdivision", aobjXMLNameSpaceManager.LookupNamespace("st")))
'Uncomment last working section below
objXmlRequestMessageDoc.DocumentElement.SelectSingleNode("ns1:BasicSearchCriteria/st:Chapter", aobjXMLNameSpaceManager).InnerText = aobjXmlGetStatuteRequestNode.SelectSingleNode("ss:Statute/ss:Chapter", aobjXMLNameSpaceManager).InnerText
'check if there is a section and or subdivision if it is there then set the value
If Not (aobjXmlGetStatuteRequestNode.SelectSingleNode("ss:Statute/ss:Section", aobjXMLNameSpaceManager) Is Nothing) Then
objXmlRequestMessageDoc.DocumentElement.SelectSingleNode("ns1:BasicSearchCriteria/st:Section", aobjXMLNameSpaceManager).InnerText = aobjXmlGetStatuteRequestNode.SelectSingleNode("ss:Statute/ss:Section", aobjXMLNameSpaceManager).InnerText
End If
If Not (aobjXmlGetStatuteRequestNode.SelectSingleNode("ss:Statute/ss:Subdivision", aobjXMLNameSpaceManager) Is Nothing) Then
objXmlRequestMessageDoc.DocumentElement.SelectSingleNode("ns1:BasicSearchCriteria/st:Subdivision", aobjXMLNameSpaceManager).InnerText = aobjXmlGetStatuteRequestNode.SelectSingleNode("ss:Statute/ss:Subdivision", aobjXMLNameSpaceManager).InnerText
End If
'check if there is a section and or subdivision if it is there then set the value
aobjBroker.PostMessageWarehouseSnapshot(objXmlRequestMessageDoc.OuterXml, "Request Message", 1)
'Call the BCA service
intCount = 0
'This is where I want to use a For loop to check for the statutes found using the Chapter
'Loop through each Id
'For Each objXmlStatuteIdNode In aobjXmlGetStatuteRequestNode.SelectNodes("ss:Statute/ss:StatuteId/ss:Id[string-length(.)>0]", aobjXMLNameSpaceManager)
'Create the BCA request message
'objXmlRequestMessageDoc = New XmlDocument
'objXmlRequestMessageDoc.AppendChild(objXmlRequestMessageDoc.CreateElement("ns:SingleStatuteRequest", aobjXMLNameSpaceManager.LookupNamespace("ns")))
'objXmlRequestMessageDoc.SelectSingleNode("ns:SingleStatuteRequest", aobjXMLNameSpaceManager).AppendChild(objXmlRequestMessageDoc.CreateElement("ns:statuteId", aobjXMLNameSpaceManager.LookupNamespace("ns")))
'objXmlRequestMessageDoc.DocumentElement.SelectSingleNode("ns:statuteId", aobjXMLNameSpaceManager).InnerText = objXmlStatuteIdNode.InnerText aobjBroker.PostMessageWarehouseSnapshot(objXmlRequestMessageDoc.OuterXml, "Request Message", 1)
'intCount = intCount + 1
'objXmlBcaResponseDoc = New XmlDocument
'File name is BCASearchQueryResponse.xml
'objXmlBcaResponseDoc.Load("\\j00000swebint\mscapps\deve\appfiles\temp\BCASearchQueryResponse.xml")
'objXmlResponseMessageDoc.DocumentElement.SelectSingleNode("ss:StatutesXml/ss:Statutes", aobjXMLNameSpaceManager).AppendChild(objXmlResponseMessageDoc.ImportNode(objXmlBcaResponseDoc.DocumentElement.SelectSingleNode("ns1:Statute", aobjXMLNameSpaceManager), True))
'Next
'Count how many Statute nodes found
CType(objXmlResponseMessageDoc.SelectSingleNode("ss:BasicSearchQueryResponse/ss:StatutesXml/ss:Statutes", aobjXMLNameSpaceManager), System.Xml.XmlElement).SetAttribute("totalCount", CStr(intCount))
Return objXmlResponseMessageDoc
End FunctionWhat is XPath and what does it do that you're impressed with?
Yes, I see your link, but give me the abbreviated elevator speech on what it is please. It has me curious.
http://searchsoa.techtarget.com/definition/XPath
http://www.techrepublic.com/article/easily-navigate-xml-with-vbnet-and-xpath/
http://www.techrepublic.com/article/using-xpath-string-functions-in-xslt-templates/
The way that all this is being used by me now on a project is the HTML controls on the screen are built by XML not only about what the controls are and their attributes, but the data from from the database is XML too with both going through transfermations
vis XSLT as the HTML controls are built dynamically by XML data for the controls and the XML database data with decision being made in the transfermation on the fly.
There are many usages with Xpath not just this one I am talking about with Xpath. You can do the same kind of thing with XAML and WPF forms as they are dynamically built. But it goes well beyond what I am talking about and the usage of Xpath. Xpath 3.0
is the latest version.
http://www.balisage.net/Proceedings/vol10/html/Novatchev01/BalisageVol10-Novatchev01.html
Thanks - I'll look into that at some point.
Still lost in code, just at a little higher level. -
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 . -
How to get the elements out of a for loop simultaneously during the loop execution
Hi,
I am student. I would like to know how to get the counter values outside the For loop parallely while the loop runs rather that getting the finally value outside the For loop. Looking forward for answers.
Thanks,
Athira
Solved!
Go to Solution.You could use a notifier (since it is a single value) or a reference (with a property node) to a control that gets the value elsewhere in another VI.
If it is within the same VI, you could use a property node (right click > create > property node > value) from the control within the same VI located outside the loop.
If you promiss NOT to abuse the use of Local Variables, you could use that to only write from ONE location within the For Loop to a control outside the loop, similar to the property node mentionned earlier. (Of course, I will be struct by lightening for mentionning that and scolded by other LabVIEW coders for having a change of heart on the use of Locals.... Shivers are already crawling up my spine).
You could use a queue, but that might be an overkill, unless: the count is generated faster than it is being read elsewhere...
As crossrulz mentionned, can you describe what you will be doing with the count? Because synchronizing data (fresh / stale / etc) is very important within LabVIEW as it executes based on dataflow rather than a sequential order.
Hope this helps.
EDIT:
You have not fully provided the answer. We figured that much of your code from your description, but what is reading the value of the count? Is it in a separate loop? If not, it may only deal with the first value, which is likely 0. The proper advice depends on how you process the received data (count). -
Need help with a For loop that uses a Break statement
I need to create a for loop which counts down from 100-50 and divides the number being counted down by a counter. Can anyone help me?
public class Break
public static void main ( String args []) (;
int total = 0
int counter = 0
for { (int number = 100; total >=50; total --)
if (counter == 0)
break;
} // end of for loop
int output = number/counter
system.out.printf("The number is" %d output/n)
}// end of method main
}// end of class BreakIm sorry I didnt explain myself very well i do not need the break statement at all.
I now have this code:
public class BreakTest
public static void main( String args[] )
int count; // control variable also used after loop terminates
for (int i = 100; i >= 50; i = ++count)
if (i >= 50) {
continue;
System.out.printf( "\nBroke out of loop at count = %d\n", count );
} // end main
} // end class BreakTest
/code]
and i get these error messages:
F:\csc148>javac BreakTest.java
BreakTest.java:9: variable count might not have been initialized
for (int i = 100; i >= 50; i = ++count)
^
BreakTest.java:15: variable count might not have been initialized
System.out.printf( "\nBroke out of loop at count = %d\n", count );
^
2 errors -
Hi all,
Is it possible in a for loop to iterate with steps ? For example :
for i in 1..500 loop , but I want the index i to grow five by five ! Is it possible ? Is there a keyword to use to accomplish this ? My database is Oracle10g !
Thank you !Directly you can't control the iterator of FOR LOOP (no change possible, no INCREMENT clause).
You can use another index to control iterations::
SQL> declare
2 j integer := 1;
3 begin
4 for i in 1..5 loop
5 j := i*5;
6 dbms_output.put_line('i=' || i || ', j=' ||j);
7 end loop;
8 end;
9 /
i=1, j=5
i=2, j=10
i=3, j=15
i=4, j=20
i=5, j=25
PL/SQL procedure successfully completed.
SQL> declare
2 i integer := 1;
3 begin
4 while ( i < 25 ) loop
5 dbms_output.put_line('i=' || i );
6 i := i + 5;
7 end loop;
8 end;
9 /
i=1
i=6
i=11
i=16
i=21
PL/SQL procedure successfully completed.
SQL>/* Just for fun */
SQL> begin
2 for v in (select rownum*5 as i from (select 1 from dual connect by level<6)) loop
3 dbms_output.put_line('i=' || v.i );
4 end loop;
5 end;
6 /
i=5
i=10
i=15
i=20
i=25
PL/SQL procedure successfully completed.Rgds.
Maybe you are looking for
-
Previewing views in BSP WD Component Workbench
I am developing a component with many views in the BSP WD Component Workbench (BSP_WD_CMPWB). In order to test each individual view or window, it would be helpful to test it in isolation, but I can only seem to test the application as a whole. Are th
-
When I log on the internet my home page is frontier.my.yahoo.com/?bc1 The screen dims and I get the message We noticed you may have signed in or signed out in another window, click ok to reload your page How can I get rid of this message?
-
Row level security with session variables, not a best practice?
Hello, We are about to implement row level security in our BI project using OBIEE, and the solution we found most convenient for our requirement was to use session variables with initalization blocks. The problem is that this method is listed as a "n
-
Hi Gurus, Need a little suggestion for a doubt - I accidently changed Material Masters data of some items, after running a faulty LSMW When I look at the change document for some of those articles it says - Change Tax classification article
-
BAPI to change components data of planned orders?
Hi, Currently we are using BDC to change components at planned orders. Due to big data volume, we have performance issue now. Just checked if there is any BAPI to replace BDC. But can't find proper one. Anyone has any expeerience about changing compo