How to end loop when desired value is found.
Hi I have a loop below and I want the loop to end when the desired value is found.
<?php do { ?>
<?php $allvotedid = $row_VotedUsers['VotedID'] ?>
<?php } while ($row_VotedUsers = mysql_fetch_assoc($VotedUsers)); ?>
I want this loop to end when $row_VotedUsers['VotedID'] equals the URL variable ID. So lets say pagename.php?ID=1, I want the loop to go until it finds a value equal to ID which is 1. And then I want it to assign that value to $allvotedid. And if finds no value equal to it then I want it to stop looping.
Thanks for any help. I hope I made this clear.
cwhazzoo wrote:
Hi I have a loop below and I want the loop to end when the desired value is found.
The following will do what you have asked for:
<?php do { ?>
<?php
if (isset($_GET['ID']) && $_GET['ID'] == $row_VotedUsers['VotedID']) {
$allvotedid = $row_VotedUsers['VotedID'];
break;
} ?>
<?php } while ($row_VotedUsers = mysql_fetch_assoc($VotedUsers)); ?>
However, it's a very inefficient way of doing it. If what you're interested in is whether the ID passed through the URL is in the VotedID column, just create a recordset using the URL parameter ID ($_GET['ID']) as the filter. Then check the value of $totalRows_VotedUsers. If it's 1, the user has voted. If it's 0, the user hasn't voted.
Similar Messages
-
End Loop when value is not in Table
My tables:
Possible_Ids
2222
1111
3333
4444
Used_Ids
5555
6666
2222
7777
Code so far:
declare
type array_type is table of Possible_ids%rowtype;
id_array array_type;
v_id char(4);
v_counter number:=1;
v_found number:=0;
begin
select * bulk collect into id_array from Possible_ids;
loop
if id_array(v_counter).co1 IN Used_ids table* then <--- I need help here,
v_counter:= v_counter+1;
else
v_found:= 1;
v_id:= id_array(v_counter).co1
end if;
exit when v_found = 1;
end loop;
dbms_output.put_line(v_id);
end;
Help: I need to somehow write a statement to instruct the code to "stop" when a value is NOT found in a table. From my tables, the first valid Possible_id would be '1111' since '2222' is already used.
Edited by: Ludovick on Nov 2, 2010 10:25 AM
Edited by: Ludovick on Nov 2, 2010 10:28 AM
Edited by: Ludovick on Nov 2, 2010 10:29 AMWhy so complicated. If you simply want to retrieve the lowest possible id that is not used you could do it like this.
(I assume, your id column in both tables is named ID):
declare
v_id number;
begin
select min(id)
into v_id
from possible_ids
where ID not in (select ID from used_ids);
dbms_output.put_line('found id='||v_id);
exception
when no_data_found then
dbms_output.put_line('no data found'); -- or whatever you want.
end;If you don't need pl/sql you can do it with sql:
select min(id)
from possible_ids
where ID not in (select ID from used_ids); -
How to hide rows when no value entered automatically
is there a way in conditional formatting where i can hise a row of information when no value is entered against that row , simlar to a macro in excel?
thanks fred 69Fred,
Yes, you can use the Reorganize Panel to show only rows that meet certain criteria. I would think that you could find a way to use that feature to accomplish your goal.
Jerry -
How to show desired value in list item, when form starts?
Hello.
I have list item with values:
April 2006
May 2006
June 2006
July 2006
August 2006
September 2006
When the form starts, i want to show in my list item current month (August 2006). And when i open list item above list would appear with August 2006 selected.
How can i do that?
Thanks.Hi Dejan,
What you have to do is the following:
After populating your list, write some code similar to what I have given here.
FOR n IN 1..nCnt LOOP
IF Get_list_element_value('list', n) = To_char(sysdate, <date format for the current month n year> THEN
:list := To_char(sysdate, <date format for the current month n year>
RETURN;
END IF;
END LOOP;
:list := NULL; -- in case nothing matches
You can use this in WNFI trigger and wherever necessary.
Check whether this solves your problem
Warm Regards,
Raja. -
How do you start a loop with lets say an event of some sort, whether it be holding down a key or pressing the mouse click and then stopping the loop when you release that key or mouse button.?
double c = 1.8, i = 1, max = 90, exp = 0;
final double inc = 0.002; //speed at while it increases
boolean f = false, g = false;
while (true)
while (f == false && stopMeter == false) //increasing speed going up to 90
exp = Math.pow (c, i);
i += inc;
pAngle.setText (Math.round (exp) + "");
if (exp > max)
f = true;
g = false;
} //end if
} //end while
while (g == false && stopMeter == false) //decreasing speed going down from 90
exp = Math.pow (c, i);
i -= inc;
pAngle.setText (Math.round (exp) + "");
if (exp < 1)
g = true;
f = false;
} //end if
} //end while
} //end whilethis is a snippet of my increasing increments. Its for an angle meter. I can't get it to stop, when the user clicks or does something... the program just gets stuck in an infinite loop. I am still new to java and i do not know how to fix this.You are in the wrong forum. Try this one instead: http://forum.java.sun.com/forum.jspa?forumID=31
/M -
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 -
Hi all,
I have created a form with one data block MATURED_FD_DTL which looks like below:
ACCT_FD_NO
CUST_CODE
FD_AMT
FD_INT_BAL
TDS
CHQ_NO
ADD_FD_AMT
P_SAP_CODE
P_TYPE
CREATE TABLE MATURED_FD_DTL
ACCT_FD_NO VARCHAR2(17 BYTE) NOT NULL,
CUST_CODE NUMBER(9),
FD_AMT NUMBER(15),
FD_INT_BAL NUMBER(15),
TDS NUMBER(15),
CHQ_NO NUMBER(10),
ADD_FD_AMT NUMBER(15),
P_SAP_CODE NUMBER(10),
P_TYPE VARCHAR2(1 BYTE)
For MATURED_FD_DT.ACCT_FD_NO, Trigger: KEY_NEXT_ITEM, I have written the following code:
DECLARE
V1 NUMBER;
V2 NUMBER;
BEGIN
V1:=:MATURED_FD_DTL.ACCT_FD_NO;
MESSAGE('V1:'||V1);
MESSAGE(' ');
END;
GO_ITEM('MATURED_FD_DTL.CUST_CODE');
This is just a dummy code.
When ever i enter the value in the field of ACCT_FD_NO, it pops up a message saying "V1:Value of ACCT_FD_NO",
So i want to store that value .
Compare them & if it is egual, it should pop up a message saying duplicate value is entered and must not allow to enter, at form_level.
So how can I compare the ACCT_FD_NO value between FIRST_RECORD and NEXT_RECORD ??
Help Me .
Thank You.
Oracle Forms 6i.
Oracle 9i.Thank You HamidHelal.
Actually before posting the code, I went through the first link you have mentioned. I tried also, it is quite tedious procedure, however i dint get the proper result, may be i have done some mistake. Anyways , can you tell me how do i check in database table, if a value exists OR IF VALUE FOUND & then message and raise form trigger failure; something like below.
IF :MATURED_FD_DTL.ACCT_FD_NO EXISTS
THEN MESSAGE('YOU HAVE ENTERED AN EXISTING OR DUPLICATE VALUE');
MESSAGE(' ');
RAISE FORM_TRIGGER_FAILURE;
END;
OR
IF :MATURED_FD_DTL.ACCT_FD_NO FOUND
THEN MESSAGE('YOU HAVE ENTERED AN EXISTING OR DUPLICATE VALUE');
MESSAGE(' ');
RAISE FORM_TRIGGER_FAILURE;
END;
Is there any equivalent in the form in oracle forms 6i?? Please let me know how do i do this?? -
How to loop with varying values depending on where you are in the loop
Hi,
I have need of loops / nested loops that pick different figures depending on where you are in the loop.
The whole function needs to run through 'ml' times. 'ml' is a dynamic figure.
Loop 1 = While the loop is within the first 12 iterations, 'exconemp' must equal 100. For iterations 13 - 24, 'exconemp' must equal 102.5, for 25 - 36 it will be 105.06, for 37 - 48 it will be 107.69. This needs to change every 12th iteration until it has reached 'ml'. The calculation takes the value of the previous 'exconemp' and then multiplies that by 0.025.
Loop 2 = While the loop is within the first 120 iterations, 'abc' must equal 0.015 and any further iterations must use 0.01. This must also work in a way to figure out whether 'ml' is higher or lower than 120 and work accordingly.
My main issue is this - how do I get the loops to run through as this:
While the iteration is < 12, do this, THEN take the final figure (12th iteration) and start on 13 - 24, do this THEN etc etc.
How do I produce a THEN statement? I can get the code to pick up the final values, but not change along the way.
I think that I may be better creating an array for Loop 1, but I am not entirely convinced of this. I also think it would be better/tidier if I can get 'month 1 total' and 'month 2 total' into the loops, but am not sure on how to do this.
The values that I need to produce are (only first 36 shown):
1 - 12 = 125.55, 251.65, 378.31, 505.52, 633.29, 761.63, 890.53, 1019.99, 1150.03, 1280.63, 1411.81, 1543.57
13 - 24 = 1679.05, 1815.12, 1951.79, 2089.06, 2226.93, 2365.41, 2504.50, 2644.20, 2784.52, 2925.45, 3067.00, 3209.18
25 - 36 = 3355.19, 3501.85, 3649.15, 3797.11, 3945.71, 4094.96, 4244.87, 4395.44, 4546.68, 4698.57, 4851.14, 5004.38
var ml = 240 // dynamic figure, multiple of 12 up to 780
var exconemp;
var exconem = 100;
var inf = 0.025;
var tree;
var tec;
var power;
var fvis;
var abc;
var fvee;
var tfv;
function myfunction() {
//Loop 1
//while (ml <= 12) {
exconemp = exconem;
//while (ml > 12) {
// exconemp = exconem*inf;
//end Loop 1
trace("exconemp=", exconemp); // employees contribution
tree = exconemp/(1-0.2)-exconemp;
tec = exconemp + tree;
trace("tree", tree);
trace("tec", tec);
power = Math.pow(1+0.07, 1/12);
//Loop 2
//while (ml <= 120) {
abc = 0.015;
//while {
//abc = 0.01;
//end Loop 2
fvis = power*(1-abc/12);
trace("fvis=", fvis);
fvee = tec*fvis;
trace("fvee=", fvee); // month 1 total
tfv = (tec+fvee)*fvis;
trace("tfv=", tfv); // month 2 total
for (var i:Number = 0; i < ml; i++)
tfv = (tec+tfv)*fvis;
trace("tfvloop=", tfv);
I hope that I have explained this well enough.
Many thanks in advance.I think this will do it although I am not quite getting the numbers you posted.
stop();
var ml = 48; // dynamic figure, multiple of 12 up to 780
var exconemp;
var exconem = 100;
var inf = 0.025;
var tree;
var tec;
var power;
var fvis;
var abc = 0.15;
var fvee;
var tfv;
myfunction();
function myfunction()
exconemp = exconem;
for(var index:uint = 1; index <= ml; index++)
trace(index + "--------------------------------");
tree = exconemp/(1-0.2)-exconemp;
tec = exconemp + tree;
power = Math.pow(1+0.07, 1/12);
fvis = power*(1-abc/12);
fvee = tec*fvis;
if(index == 1)
trace("month 1 total=", fvee);
else if(index == 2)
tfv = (tec+fvee)*fvis;
trace("month 2 total=", tfv); // month 2 total
else
tfv = (tec+tfv)*fvis; //now that we are here the tfv self perpetuates on itself
trace("month " + index + " total=", tfv); // month n total
if(index % 12 == 0)
exconemp = exconemp*(1+inf);
trace("changed exconemp to: " + exconemp);
if(index % 120 == 0)
abc = .01;
trace("changed abc to: " + abc); -
How to stop while loop when a specified function is terminated?
I want to make a program which has 2 thread, one of which is to control some devices, and the other is to measure outputs of the devices.
To do that, I should make a 2 independent loops, but there comes a problem here.
I want to terminate 2 loops at the same time, but it's difficult for me to do that, because when I try to notify upper sequence's termination to lower loop by some value change, they have some dependency.
That's why I need your help. I want to know how to stop lower loop when the upper sequence's termination keeping their independency.
Please let me know. Thank you.
Attachments:
help.JPG 200 KBIs the upper loop commanding the lower loop at all? I would think you would have some type of communication between the loops. Just use that communication to send a stop command. Or the next best way is to just simply use a notifier.
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines -
How to Supply the form field values to a pdf form when loading it
I am working on a web site project using Asp.net where the user has to fill in a PDF eform in acrobat reader. Then when he clicks on submit it returns to my asp.net app and the PDF form supplies the values back to my asp.net app. So my asp.net app has the values that were filled in the PDF form and can save those values and work with them...
OK.
What I need to know is when I am in my asp.net app, and the user wants to go back and reopen the same form, from my asp.net app..... then how do I pass back the values that were saved back to the PDF form??
I know if I had a way to pass the values to the PDF form in some way then in the Doc.open or doc.load event of the form I could easily write a little javascript to plug in the values in the PDF form fields.
but how do I pass those values from my asp.net app to my PDF form???
thanksThanks bcweed for all the info. I fixed my problem, it had something to do with LiveCycle Designer. If I just use Acrobat to add the form fields, then the FDF works fine. As to your situation with the SavToBuf, that happens to be the method that I am using, so I will just post my code here, and maybe you can pick out what is different from yours. The Response.BinaryWrite(FDFin.FDFSaveToBuf)is at the bottom.
Sql = "SELECT * FROM Invoices" & WHERE
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open Db_Conn_Str
Set Rs = Server.CreateObject("ADODB.Recordset")
Rs.Open Sql, Conn, adOpenStatic, adLockReadOnly, adCmdText
If Not Rs.EOF Then
End If
Set FdfAcX = Server.CreateObject("FdfApp.FdfApp")
Set outputFDF = FdfAcX.FDFCreate
'VendorID = VendorName = VendorNum = InvoiceDate = PreparedBy = ""
Gross = 0
For I=0 To Rs.RecordCount-1
If InStr(VendorID,Rs.Fields("VendorID")) = 0 Then
VendorID = VendorID & Rs.Fields("VendorID") & ", "
End If
If InStr(VendorName,Rs.Fields("VendorName")) = 0 Then
VendorName = VendorName & Rs.Fields("VendorName") & ", "
End If
If InStr(InvoiceNum,Rs.Fields("InvoiceNumber")) = 0 Then
InvoiceNum = InvoiceNum & Rs.Fields("InvoiceNumber") & ", "
End If
If InStr(InvoiceDate,Rs.Fields("InvoiceDate")) = 0 Then
InvoiceDate = InvoiceDate & Rs.Fields("InvoiceDate") & ", "
End If
If InStr(PreparedBy,Rs.Fields("PreparedBy")) = 0 Then
PreparedBy = PreparedBy & Rs.Fields("PreparedBy") & ", "
End If
Rs.MoveNext
Next
Rs.MoveFirst
outputFDF.FDFSetValue "VendorID",VendorID,False
outputFDF.FDFSetValue "VendorName",VendorName,False
outputFDF.FDFSetValue "InvoiceNum",InvoiceNum,False
outputFDF.FDFSetValue "InvoiceDate",InvoiceDate,False
outputFDF.FDFSetValue "PreparedBy",PreparedBy,False
For I=0 To Rs.RecordCount-1
outputFDF.FDFSetValue ("Line."&I), Rs.Fields("Amount")&"", False
outputFDF.FDFSetValue ("Company."&I), Rs.Fields("Company")&"", False
outputFDF.FDFSetValue ("GL."&I), Rs.Fields("GL")&"", False
outputFDF.FDFSetValue ("CC."&I), Rs.Fields("CostCenter")&"", False
outputFDF.FDFSetValue ("DocNum."&I), Rs.Fields("DocNumber")&"", False
Gross = CCur(Gross) + CCur(Rs.Fields("Amount"))
Rs.MoveNext
Next
outputFDF.FDFSetValue "Gross", Gross, False
Rs.Close
Set Rs = Nothing
Sql = "UPDATE Invoices SET DatePrinted = '" & Now() & "'" & WHERE
Conn.Execute Sql
Conn.Close
Set Conn = Nothing
outputFDF.FDFSetValue "PrintDate", Date(), False
outputFDF.FDFSetFile "http://admin/invoices/pdf/InvoiceAuthorization.pdf"
Response.ContentType = "application/vnd.fdf"
Response.BinaryWrite outputFDF.FDFSaveToBuf
outputFDF.FDFClose
%> -
How to get a Tree Node Value when a Tree is Expanded
My reqiurement is when i Expand a Tree i need the Expanded tree Node Value. For Example Consider Parent as a Root Node of a Tree, and Consider its two Children Child1 and Child2.
When + Parent Expanded
I will Get the Output as --Parent
- Child1
- Child2
so As when i expand the Tree i must Get the String Value Parent.duplicate
How to get a Tree Node Value when a Tree is Expanded -
How do I get rid of "Your Free Trial Period has ended" Screen when trying to open pdf in the Reader
Hi
How do I get rid of the "Your Free Trial Period has ended" Screen when trying to open a pdf in Adobe Reader?
I had a trial of Dreamweaver but it was too complicated for me.
There was no where to cancell the free trail so I let it run its course and expire. It then deleted the programs which is fine (I didn't want to buy them) but it also deleted my Acrobat Reader.
I have re-installed that but when I try to open a pdf, all I get is the "Your Free Trial Period has ended" screen which only allows you to buy or exit and them exits all together.
Needless to say I am very UNIPRESEED with Adobe for messing up my programs and now they want to charge me $29 dollars to sort out a problem they created.
Can anyone help me to sort out this very anoying problem?
Regards
DavidHi
Thank you for the reply.
No I have not deleted anything, this all happened automatically when the trial period ended.
Other than an old version of Photoshop (version 7, for which I do have a serial number, I don't have any other Adobe software - just the reader which is now not working)
I was trialling Dreamwever but couldn't get started with it so am paying someone else to set up the website using Wordpress.
David -
i have a for loop inside of while loop.when i press stop for while loop, i also would like to stop for loop.how can i solve this problem?thanks
Hi fais,
Following through with what JB suggested. The steps involved in replacing the inner for loop with a while loop are outlined below.
You can replace the inner for loop with a while by doing the following.
1) Right-click of the for loop and select "Repalce" then navigate to the "while loop".
2) Make sure the tunnels you where indexing on with the for loop are still indexing.
3) Drop an "array size" node on your diagram. Wire the array that determines the number of iterations your for loop executes into this "array size".
4) Wire the output of the array size into the new while loop.
5) Set the condition terminal to "stop if true".
6)Drop an "OR" gate inside the while loop and wire its output to the while loops condition terminal.
7) C
reate a local of the boolean "stop" button, and wire it into one of the inputs of your OR gate. This will allow you to stop the inner loop.
8) Drop a "less than" node inside the inner while loop.
9) Wire your iteration count into the bottom input of the "less than".
10) Wire the count (see step 4 above) into the top input of the less than. This will stop the inner loop when ever the inner loop has processed the last element of your array.
Provided I have not mixed up my tops and bottoms this should accomplish the replacement.
I will let others explain how to takle this task using the "case solution".
Ben
Ben Rayner
I am currently active on.. MainStream Preppers
Rayner's Ridge is under construction -
How to write rfc when value change in the screen (browser) in webdynpro.
Hi,
I want to know how can i write an RFC when screen value change in webdynpro. I already designed a rfc where all the value can be seen in the webdypro screen. Now when user change the value how can i pick the changed value in R/3 so that i can save it into the respective database. Please send some code for understanding it easily as i am new to this field.
Regards
DeepHi Deepak,
Though I dint understand your requirment properly but as it is raised in Web Dynpro forum I considering that you want to send the data filled by the user to your backend using RFC calls. For this purpose you can refer to this two documents available on SDN.
<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webdynpro/creating%20a%20web%20dynpro%20application%20accessing%20abap%20functions.pdf">Tutorial 4</a>
<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/d352a790-0201-0010-5082-b1a608d22b6c">Tutorial 5</a>
Regards
Sid -
How to stop a while loop when using tab control
How do you use a tab contol to stop what is happening on one tab when you switch to another tab? In the test example I attached, I have a while loop nested inside a case structure controlled by the tab control. When I tab to page two the elapsed timer starts but when I switch to another tab it does not stop. I can't come up with an easy way to stop or exit the while loop when I change tabs.
Thank you
Danny
Attachments:
tab control.vi 24 KBI played with it a little more and came up with this fix. This fixes it but is not tied to the changing tabs as I was looking for. Is this just too many nested loops and a bad idea?
Danny
Attachments:
tab control fix maybe.vi 26 KB
Maybe you are looking for
-
Error in using System Variable
Dear all, I want to use System Variable 225 ( VAT percent (per VAT code) ) which is used in one of document i.e. "VAT Only Invoice". When I used it in my Invoice document the following error occurs: Printing Error : Invalid Variable number (
-
Is there a way of protecting PDF documents from printing and/or copying?
Does anybody know a way of protecting PDF documents from printing and/or copying? All this within the OS possibilities? Is there a way? know one can buy expensive programmes like from Adobe, but I use it so little that I would like a cheaper solution
-
If we have latest SAP R3 that works on WAS 640 can I deploy WebDynpro for ABAP and use this ABAP Engine to do all the development. That way all the regular R3 deveopment as well as Web Dynpro ABAP development will be in Development box. Is this ok to
-
SAP R/3 4.7E IDES Installation
Hi, I have NW 2004 and NW 2004s DVDs. Recently i downloaded R/3 4.7E IDES " .RAR" files from net. Can anyone help, how to install IDES system for R/3 4.7E. It is very urgent...please...if possible send screen shots Regards Ram
-
Object instance initialization code - constructor equivalent?
Hi, Is there an alternative in new javafx to using: trigger on new MyClass{ //run several initialization statements }Or simply put: how do I create a constructor (that will be invoked automatically after each instance has been created)? And no, using