How to let " i " of a for loop to start from a "X"
Hi,
how to let " i " of a for loop to start from a value "x" where x is a variable?
Thx
Message Edited by starfish on 10-19-2007 06:00 AM
Hi starfish,
use it like this:
If this doesn't fit your needs you should attach an example of what you really need!
Message Edited by GerdW on 10-19-2007 01:15 PM
Best regards,
GerdW
CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
Kudos are welcome
Attachments:
I.png 2 KB
Similar Messages
-
How to let add external apps for simple users?
How to let add external apps for simple users? Simple users don't have login server administer rights, so how can they add external apps for their use?
...Edit External applications portlet sais:
Error: An unexpected error occurred: User-Defined Exception (WWC-43000)
:((( -
Please help me.. how to rewrite the following java- for loop code in ada
int i, j, n = 100;
for (i = 0, j = 17; i < n; i++, j-- )
sum += i * j + 3;how to rewrite the following java- for loop code in ada
You should have a programming manual for Ada first. If you mean it the other way round, I think you subject line confused me. -
Customize for loop to run from x value to y value
How can you customize a for loop to run from a specified i-value.
Basically how can I do this c code in Labview:
for(i=2; i<10; i++)Guy04,
you cannot influence the iterator of any loops in LabVIEW. So there is (sadly) no way to initialize the iterator to a value != 0.
Nevertheless, you can "emulate" this by doing what i did in the screenshot. Just remember that "N" has to be the difference between end- and startvalue of your iterator (in your example 10 - 2 = 8 ).
hope this helps,
Norbert B.
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Attachments:
ForLoop.jpg 7 KB -
How can I get "library components" for Encore? download from Adobe site is corrupted/missing files. I have tried 3 times to d/l and each time problems. HELP please!
I just want the DVD templates and buttons that would come with actual purchase of Encore. Having creative cloud subscription should not limit this for me, right?
BTW I have CC subscription, Windows 7,Thanks very much I have contacted them via this. Just hope they respond quickly- rather annoing! Greatly appreciated though
-
How do I use an enhanced for loop / for each on my ViewObjectImpl ?
Guys and Gals,
With all of my newly acquired Java knowledge in tow, I spent this weekend cleaning up all of my code, dealing mainly with for loops. I converted them from a huge mess to a for each type loop using language such as ...
RowSet priceUpdateRows = (RowSet)((PriceUpdatesViewRowImpl) priceUpdate).getPriceUpdateRowsView();
for (Row priceUpdateRow: priceUpdateRows)
{ // do operations on row... which makes perfect sense to me. For each Row in the RowSet, do something. It doesn't, however, makes sense to the compiler. It pouts and gives me a "foreach not applicable to expression type" error. So I read up on iterators and such, messed with code examples, and still can't get the RowSet to iterate with the above code. Could I make RowSet implement Iterable? How would I do that? I tried to create a class called RowSetExt which extended RowSet and implemented Iterable, but then I got a class cast exception.
I know I could implement something like the following or a while(hasNext()) but they're really not what I'm looking for.
ViewObject vo = … < Get ViewObject > …
RowSetIterator rsi = vo.createRowSetIterator("rowsRSI");
while (rsi.hasNext())
Row row = rsi.next();
row.setAttribute("YourAttribute",your_value);
rsi.closeRowSetIterator();How do I make the for(Row row : <RowSet>) example work? Or could someone point me in a direction?
WillOne thing I tried was to make a framework extension class for my ViewObjectImpls
public class PcsViewObjectImpl
extends ViewObjectImpl
implements Iterable<Row>
Set<Row> set = new HashSet<Row>();
public Iterator<Row> getRows()
return set.iterator();
public Iterator<Row> iterator()
return getRows();
}AppModuleImpl
PriceUpdateRowsViewRowImpl priceUpdateRows = (PriceUpdateRowsViewRowImpl)((PriceUpdatesViewRowImpl) priceUpdate).getPriceUpdateRowsView();
for (Row priceUpdateRow: priceUpdateRows)
{However, this gives me a class cast exception at runtime. But I would think some kind of extension class would be the way to go ... ? -
How to pass parameter into cursor for loop ?
Hi Experts,
I want to pass parameter l_bom_header_tbl(i).assembly_item_name into the for statement below How to achieve this?
for j in 1 .. l_bom_components_tbl.COUNT LOOP
ThanksMaybe i failed to describe in detail,so here i go:
I have two for loops:
for i in 1 .. l_bom_header_tbl.COUNT LOOP --1st For Loop
V_bom_header_tbl.organization_code :='DSC';
V_bom_header_tbl.assembly_item_name:= l_bom_header_tbl(i).assembly_item_name ;
k:=1;
I want to pass parameter l_bom_header_tbl(i).assembly_item_name into the for statement below: How to achieve this?
for j in 1 .. l_bom_components_tbl.COUNT LOOP *2nd For Loop*
v_bom_components_tbl(k).Assembly_Item_name := l_bom_header_tbl(i).assembly_item_name ;
k := k + 1;
end LOOP;
end loop;
end;
I want to pass a paramter into second for loop in such a way that it accepts from the first for loop
for j in 1 .. l_bom_components_tbl.COUNT LOOP -2nd loop
Edited by: ILovePlSql on Mar 22, 2010 12:25 PM -
How to maintain counter in a for loop
Hi,
How do we track counter in a loop?Isn't it the way I implemented.? Please suggest.
Regards.
Solved!
Go to Solution.
Attachments:
for loop counter.jpg 219 KBBoth loops have errors, if you try to do for(i=60;i<120;i++) you're only running 60 loops, not 120.
You should also disable the autoindexing on incoming arrays as you want some split array indexes (actually you can optimize it by extracting the constant a[30] before the 1st loop and the opposite on the 2nd. Now you're extracting 2 numbers from a 1D array instead of 1 from a 2D array ...
The number on the select/sum function should be integers, no need to calculate doubles.
The small array to sum it up is only max 170 numbers, it's ok although a sum in a shift register would be better.
/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 check two contitions in for loop
Hello all
Here I am having a for loop where I am reading from a cursor and I want to run this loop
till the number in :P102_NO
FOR emp_rec in emp_cur and i in 1 to :P102_NO loop
insert into EMP(EMP_ID,DEATH_DATE) values(emp_rec.emp_id,:P102_DATE)
end loop;
but it is showing a error:
ORA-06550: line 5, column 24: PLS-00103: Encountered the symbol "AND" when expecting one of the following: . ( * @ % & - + / at loop mod remainder rem .. || multiset
do anybody have any idea about it?
Thanks
TauceefTauceef wrote:
Hello all
Here I am having a for loop where I am reading from a cursor and I want to run this loop
till the number in :P102_NO
FOR emp_rec in emp_cur and i in 1 to :P102_NO loop
insert into EMP(EMP_ID,DEATH_DATE) values(emp_rec.emp_id,:P102_DATE)
end loop;
but it is showing a error:
ORA-06550: line 5, column 24: PLS-00103: Encountered the symbol "AND" when expecting one of the following: . ( * @ % & - + / at loop mod remainder rem .. || multiset
do anybody have any idea about it?
Thanks
TauceefYou would need 2 loops, but the ideal way to do this would be in a single SQL statement... no loops, no cursors.
FOR emp_rec in emp_cur
LOOP
FOR i in 1 to :P102_NO
LOOP
<stuff and or things>
END LOOP;
END LOOP;However you aren't making reference to your variable (i) anywhere ... so what exactly are you trying to do?
How about you show us your cursor, the data you have ... and the data you want when whatever the heck you're trying to do 'works'. We'll be in a much better-er position to help you in that case. -
How to pass parameter to cursor for loop having table type?
Hi Friends,
I am wondering how to pass a parameter into second for loop in the example code below.Please see the bold statements and answer my queries.
Thanks a lot .Here is the code .
declare
l_bom_header_tbl BOM_BO_PUB.BOM_HEADER_TBL_TYPE ; ---TABLE TYPE
V_bom_header_tbl Bom_Bo_Pub.Bom_Head_Rec_Type := Bom_Bo_Pub.G_MISS_BOM_HEADER_REC; ---Record type
v_bom_components_tbl Bom_Bo_Pub.Bom_Comps_Tbl_Type := Bom_Bo_Pub.G_MISS_BOM_COMPONENT_TBL;---nested table type
c:=0 number ;
k:=1 number ;
begin
BOMPXINQ.Export_BOM(
P_org_hierarchy_name => l_org_hierarchy_name,
P_assembly_item_name => l_assembly_item_name,
P_organization_code => l_organization_code,
P_alternate_bm_designator => '1Test',
P_Costs => l_costs,
P_Cost_type_id => l_cost_type_id,
X_bom_header_tbl => l_bom_header_tbl,
X_bom_revisions_tbl => l_bom_revisions_tbl,
X_bom_components_tbl => l_bom_components_tbl,
X_bom_ref_designators_tbl => l_bom_ref_designators_tbl,
X_bom_sub_components_tbl => l_bom_sub_components_tbl,
X_bom_comp_ops_tbl => l_bom_comp_ops_tbl,
X_Err_Msg => l_Err_Msg,
X_Error_Code => l_Error_Code);
if l_Error_Code = 0 then
for i in 1 .. l_bom_header_tbl.COUNT LOOP
V_bom_header_tbl.organization_code :='DSC';
Can we assign a table type to record type like below statement?
V_bom_header_tbl.assembly_item_name:= l_bom_header_tbl(i).assembly_item_name ;
k:=1;
I want to pass parameter l_bom_header_tbl(i).assembly_item_name into the for statement below: How to achieve this?
for j in 1 .. l_bom_components_tbl.COUNT LOOP
Can we assign a table type to table type like below statement?
v_bom_components_tbl(k).Assembly_Item_name := l_bom_header_tbl(i).assembly_item_name ;
k := k + 1;
end LOOP;
end loop;
end;
Edited by: ILovePlSql on Mar 22, 2010 7:51 AM
Edited by: ILovePlSql on Mar 22, 2010 8:16 AMILovePlSql wrote:
V_bom_header_tbl.assembly_item_name:= l_bom_header_tbl(i).assembly_item_name ;
v_bom_header_tabl is a record type and l_bom_header_tbl is a table type .So is the above statement ok?I asked you for type definition. Please provide definition of BOM_BO_PUB.BOM_HEADER_TBL_TYPE and Bom_Bo_Pub.Bom_Head_Rec_Type. If BOM_BO_PUB.BOM_HEADER_TBL_TYPE is table of Bom_Bo_Pub.Bom_Head_Rec_Type then your statment is OK. For example:
SQL> declare
2 type BOM_HEADER_TBL_TYPE is table of emp%rowtype index by binary_integer;
3 l_bom_header_tbl BOM_HEADER_TBL_TYPE;
4 V_bom_header_tbl emp%rowtype;
5 begin
6 select * bulk collect into l_bom_header_tbl from emp;
7 for i in 1 .. l_bom_header_tbl.count loop
8 V_bom_header_tbl.ename := l_bom_header_tbl(i).ename;
9 end loop;
10 end;
11 /
PL/SQL procedure successfully completed.
SQL> SY. -
How to terminate or exit a for loop when the user clicks on stop button
Actually my problem is to stop a loop when i click on stop button.
example:i have two buttons 'start' and 'stop'
in start buttom i wrote a for loop as
dim i as integer
For i=1 To 100000
print i
Next
when i click on start buuton it prints 'i' value up tp 100000.
my question is when i click on 'Stop' button the for loop has to terminate or Exit from the loop and should stops the execution.
Is it possible to termianate or Exit the 'for loop'
PS.Shakeer Hussain
HyderabadI am unable to stop the loop and application not at all allowing to Press the Stop button.
It seems like Hung, any advise ?
Private Sub btnStart_Click(sender As Object, e As EventArgs) Handles btnStart.Click
btnStop.Enabled = True
btnSelectFile.Enabled = False
btnStart.Enabled = False
btnStop.Focus()
Dim strFileName As String = txtFileName.Text.ToString
Dim strLineText As String
If System.IO.File.Exists(strFileName) = True Then
Dim objReader As New System.IO.StreamReader(strFileName)
While objReader.Peek() <> -1 And stopclick = False
strLineText = objReader.ReadLine()
MsgBox(strLineText, MsgBoxStyle.Information)
Application.DoEvents()
Thread.Sleep(My.Settings("strDelay") * 1000)
'System.Diagnostics.Process.Start(My.Settings("strFireFoxLocation"), strLineText)
End While
End If
End Sub
Private Sub btnStop_Click(sender As Object, e As EventArgs) Handles btnStop.Click
stopclick = True
btnSelectFile.Enabled = True
btnStart.Enabled = True
btnStop.Enabled = False
End Sub
Raman Katwal
Please remember to mark the replies as answers if they help and unmark them if they provide no help -
How to use reverse function in FOR loop
Hi,
Can we use REVERSE function in for loop.
If so can u please give an explanation with some example.
Thanks in advance.
Satya.In SQL you could do this...
SQL> ed
Wrote file afiedt.buf
1 select empno, ename, replace(sys_connect_by_path(ch,'|'),'|') as rev_ename
2 from (
3 select empno, ename, case when rn <= length(ename) then substr(ename, length(ename)-rn+1, 1) else null end as ch, rn
4 from emp
5 ,(select rownum as rn from dual connect by rownum <= (select max(length(ename)) from emp))
6 where case when rn <= length(ename) then substr(ename, length(ename)-rn+1, 1) else null end is not null
7 )
8 where connect_by_isleaf = 1
9 connect by empno = prior empno and rn = prior rn + 1
10 start with rn = 1
11* order by empno
SQL> /
EMPNO ENAME REV_ENAME
7369 SMITH HTIMS
7499 ALLEN NELLA
7521 WARD DRAW
7566 JONES SENOJ
7654 MARTIN NITRAM
7698 BLAKE EKALB
7782 CLARK KRALC
7788 SCOTT TTOCS
7839 KING GNIK
7844 TURNER RENRUT
7876 ADAMS SMADA
7900 JAMES SEMAJ
7902 FORD DROF
7934 MILLER RELLIM
14 rows selected.
SQL> -
How to recover the for loop or seq() from a sequence result
assume generate a sequence with code
for i in 1..2 do
append 1 to a list to represent outer loop
for j in 1..3 do
append 2 to list to represent inner loop
result in [1,2,2,2,1,2,2,2]
is it possible to recover for loop code and seq() function code from [1,2,2,2,1,2,2,2] ?
with fold or unfold or other method?
computing nightmareYes; and in doing so, your program will converge towards being an exemplar of the generalization of
Greenspun's tenth rule to any arbitrary language (rather than just 'C' or Fortran). -
How to handle error within a FOR loop
Hi all,
For the code:
begin
for vc1 in (select *
from xx_primavera_invoices_detail
where transfered_to_ar = 0
and cust_trx_type_id not in (1000, 1003, 1016, 1023, 1040)
and act_end_date is not null) loop
insert_into_ar_interface(vc1.amount, vc1.uom_code, vc1.quantity, vc1.unit_standard_price, vc1.cust_trx_type_id
,vc1.description, vc1.interface_line_attribute1, vc1.interface_line_attribute2, vc1.interface_line_attribute3, vc1.service_code
,vc1.gl_date, vc1.orig_system_bill_address_id, vc1.orig_system_bill_customer_id, vc1.segment2, vc1.segment3,vc1.customer_name,vc1.payment_type,vc1.currency_code)
end loop;
update xx_primavera_invoices_detail
set transfered_to_ar = 1
where transfered_to_ar = 0
and cust_trx_type_id not in (1000, 1003, 1016, 1023, 1040)
end;I want to add an exception statement if there is no value returned in VC1. I guess i'll never go into the loop statement because no data found in VC1 but the UPDATE will be executed...
Any ideas?
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production
PL/SQL Release 11.1.0.7.0 - Production
"CORE 11.1.0.7.0 Production"
TNS for Linux: Version 11.1.0.7.0 - Production
NLSRTL Version 11.1.0.7.0 - ProductionThanks in advance,
Bahchevanov.Hi,
declare
v_i_was_in_loop boolean;
begin
v_i_was_in_loop ;= false;
for cur in (select ..)
loop
null;
v_i_was_in_loop := true;
end loop;
if v_i_was_in_loop = true
then
update...
end if;
end; -
How to pause and stop two "for loops" in an event
Hi
The main menu runs first and then goes to reading menu. After "Start Reading" button is pressed, the reading process will take readings.
1) During reading process, if the "Pause Reading" button is pressed, I want that the two "for loops" are stopped and the two "for loop" counters do not reset. After the "Start Reading" button is pressed, the two "for loops" will continue to run.
2) During reading process, if the "Stop Reading" button is pressed, I want that the two "for loops" are stopped and the two "for loop" counters are reset. After the "Start Reading" button is pressed, the two "for loops" will run again.
The attached two VIs are simplified my real application. Any help will be appreciated.
Thanks
Steve
Attachments:
Main Menu Test.vi 9 KB
Reading Menu Test.vi 23 KBYou can't have those loops inside of the event structure. Currently, when you press the start button, the reading has to finish before the event case finishes. This will prevent the stop can cancel buttons from being processed by the event structure.
You need another loop that can recieve commands from the event loop. Look up the Queued Message Handler. That should get you a good start on the command process.
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
Maybe you are looking for
-
Help with CSS browser issue... please!
I posted this issue on the Wordpress forums and am not having much luck. Since it seems to be a CSS issue, I thought I should post it here and see if any of you can help me out. I am having a problem with browser compatibility on my Wordpress powered
-
HT1222 Will it change my iPods data?
My iPod touch 4th gen 32GB got and available update for ios 5.1 and I am Scared about some things.. Will it erase any of my data Will it slow my iPod Will anything change/go away (FaceTime, iMessage,email, app store, ect.) Will it do ANYTHING bad or
-
Is transport route necessary to make tp show up at STMS buffer?
Good morning: We added a real extra system as this: dev->qa->prod->"extra system". There is a delivery route (NOT transport route) between prod->"extra system". However, the transport imported into prod 1) shows up in "extra system"'s buffer at OS
-
Once i hold down the power button, the power kicks on for about 3-5 seconds then the power automatically goes out, i cant even get to the menu or anything at all it just totally dies. I changed the battery, let it sit for a while with no battery, not
-
PowerPivot DAX support for Quantile (Percentile and Quartile)
Hello, I recently needed to use create a DAX Measure that would return the Percentile of my serie but hit a wall as the percentile function was nowhere to be seen. Thanks to Frankie Yuen post and Marco Russo's post about the MEDIAN, i found a way to