Question to modify a for loop to put a counter and parametrize it
I have a FOR loop which is part of a PROCEDURE, the loop currently commits records for a large group of network providers. I need to modify it put a counter and commit for every 100 rows and make the number of rows of 100 parametrized. Any idea how this can be accomplished?
FOR cur_netrec IN cur_network_mc (curproc.mpicontractid)
LOOP
v_effectivedate := NULL;
v_terminationdate := NULL;
v_delegated := 'N';
v_individual := 'N';
v_credential := NULL;
FOR cur_conrec
IN cur_cont (cur_netrec.providerid, cur_netrec.mpinetworkcode)
LOOP
IF cur_conrec.effdate IS NOT NULL
THEN
v_effectivedate :=
LEAST (cur_conrec.effdate,
NVL (v_effectivedate, '31-DEC-9999'));
END IF;
END LOOP;
IF cur_netrec.mpinetworkproviderid IS NULL
THEN
INSERT INTO mpi_provider.mpinetworkprovider (
mpinetworkproviderid,
providerid,
mpinetworkcode,
providernetworkcode,
effectivedate,
terminationdate,
credentialingtypecode,
createdby,
creationdate,
modifiedby,
modificationdate
VALUES (
seq_mpinetworkprovider.NEXTVAL,
cur_netrec.providerid,
cur_netrec.mpinetworkcode,
(SELECT otherid
FROM mpi_provider.mpiprovider
WHERE providerid = cur_netrec.providerid),
NVL (cur_netrec.effectivedateoverride,
v_effectivedate),
NVL (cur_netrec.terminationdateoverride,
v_terminationdate),
v_credential,
USER,
TRUNC (SYSDATE),
USER,
TRUNC (SYSDATE)
ELSE
UPDATE mpinetworkprovider
SET effectivedate =
NVL (cur_netrec.effectivedateoverride,
v_effectivedate),
terminationdate =
NVL (cur_netrec.terminationdateoverride,
v_terminationdate),
credentialingtypecode = v_credential,
modificationdate = TRUNC (SYSDATE),
modifiedby = USER
WHERE providerid = cur_netrec.providerid
AND mpinetworkcode = cur_netrec.mpinetworkcode;
END IF;
--update when contract credential type code change
UPDATE mpi_provider.person prs
SET prs.credentialingtypecode =
(SELECT DECODE (MIN (credtype),
1, 'DELEGNCQA',
2, 'DELEGNETEX',
3, 'DELEGATED',
4, 'NONDELEG',
5, 'INDIVIDUAL',
6, 'NONDENETEX',
'NONE')
AS personcredentialingtypecode
FROM (SELECT DECODE (
c.credentialingtypecode,
'DELEGNCQA',
1,
'DELEGNETEX',
2,
'DELEGATED',
3,
'NONDELEG',
4,
'INDIVIDUAL',
5,
'NONDENETEX',
6,
7
AS credtype
FROM mpi_provider.mpicontractprovider cp,
mpi_provider.mpicontract c
WHERE c.mpicontractid =
cp.mpicontractid
AND cp.providerid =
cur_netrec.providerid
AND cp.terminationdate >
SYSDATE))
WHERE prs.providerid = cur_netrec.providerid;
COMMIT;
END LOOP;
This piece could be accomplished with a MERGE, too
IF cur_netrec.mpinetworkproviderid IS NULL
THEN
INSERT INTO mpi_provider.mpinetworkprovider (
mpinetworkproviderid,
providerid,
mpinetworkcode,
providernetworkcode,
effectivedate,
terminationdate,
credentialingtypecode,
createdby,
creationdate,
modifiedby,
modificationdate
VALUES (
seq_mpinetworkprovider.NEXTVAL,
cur_netrec.providerid,
cur_netrec.mpinetworkcode,
(SELECT otherid
FROM mpi_provider.mpiprovider
WHERE providerid = cur_netrec.providerid),
NVL (cur_netrec.effectivedateoverride,
v_effectivedate),
NVL (cur_netrec.terminationdateoverride,
v_terminationdate),
v_credential,
USER,
TRUNC (SYSDATE),
USER,
TRUNC (SYSDATE)
ELSE
UPDATE mpinetworkprovider
SET effectivedate =
NVL (cur_netrec.effectivedateoverride,
v_effectivedate),
terminationdate =
NVL (cur_netrec.terminationdateoverride,
v_terminationdate),
credentialingtypecode = v_credential,
modificationdate = TRUNC (SYSDATE),
modifiedby = USER
WHERE providerid = cur_netrec.providerid
AND mpinetworkcode = cur_netrec.mpinetworkcode;
END IF;
--update when contract credential type code change
UPDATE mpi_provider.person prs
SET prs.credentialingtypecode =
(SELECT DECODE (MIN (credtype),
1, 'DELEGNCQA',
2, 'DELEGNETEX',
3, 'DELEGATED',
4, 'NONDELEG',
5, 'INDIVIDUAL',
6, 'NONDENETEX',
'NONE')
AS personcredentialingtypecode
FROM (SELECT DECODE (
c.credentialingtypecode,
'DELEGNCQA',
1,
'DELEGNETEX',
2,
'DELEGATED',
3,
'NONDELEG',
4,
'INDIVIDUAL',
5,
'NONDENETEX',
6,
7
AS credtype
FROM mpi_provider.mpicontractprovider cp,
mpi_provider.mpicontract c
WHERE c.mpicontractid =
cp.mpicontractid
AND cp.providerid =
cur_netrec.providerid
AND cp.terminationdate >
SYSDATE))
WHERE prs.providerid = cur_netrec.providerid;
Similar Messages
-
Brought iPod 4 for Daughter, she put on Passcode and she can't remember it, the ipod is saying "ipod is disabled" connect to itunes. Connented to iTunes come up with need to put passcode. The on/off button does not work, can't turn off and hold home button to reset please help.
Place the iPod in recovery mode using one of these programs and then restore via iTunes:
For PC
RecBoot: Easy Way to Put iPhone into Recovery Mode
If necessary:
Download QTMLClient.dll & iTunesMobileDevice.dll for RecBoot
and
RecBoot tip
For MAC or PC
The Firmware Umbrella - TinyUmbrella
For how to restore:
iTunes: Restoring iOS software
To restore from backup see:
iOS: How to back up
If you restore from iCloud backup the apps will be automatically downloaded. If you restore from iTunes backup the apps and music have to be in the iTunes library since synced media like apps and music are not included in the backup of the iOS device that iTunes makes.
You can redownload most iTunes purchases by:
Downloading past purchases from the App Store, iBookstore, and iTunes Store -
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. -
For Loop exits prematurel​y - Arrays and Shift Registers
I have attached some preliminary code (work in progress) for the RC4 encryption algorithm. For some reason the middle for loop exits prematurely. In other words it exits after 2 iterations instead of the 256 iterations that N is set to.
I thought this was not possible and therefore I am presuming I have made some not so obvious error in attempting to use a shift register with an array.
Please have a look. Thanks.
Attachments:
RC4 Encryption beta.vi 78 KBYou misunderstand how a for loop operates. You can either wire a number to the N terminal or you can wire an array into it with auto-indexing turned on. With an array input, the for loop will iterate equal to the size of the array. When you wire both (a practice I do not recomend), the for loop will iterate to whichever is smaller - the array size or the N terminal. Both of your for loops on the left side is creating arrays with only two elements. I suspect that what you need in both of them is a shift register instead of exiting the for loop with auto-indexing turned off.
-
For loop, possible to increment counter/exit loop?
I would like to know if it is possible to exit a For loop. I know
I can use a while loop but it would be nice to be able to
increment the loop counter in a for loop. Is this possible?
Thanks,
MikeJim,
OK, that clears it up. Coming from VB I'm still figuring out the
differences.
Thanks,
Mike
James Morrison/Joan Lester wrote:
>
> Also remember you can make while loops auto index. Right pop on the tunnel
> and enable this and the loop will then act more like a for loop.
>
> Jim
>
> "Kevin B. Kent" wrote:
>
> > Mike Scirocco wrote:
> >
> > > I would like to know if it is possible to exit a For loop. I know
> > > I can use a while loop but it would be nice to be able to
> > > increment the loop counter in a for loop. Is this possible?
> > >
> > > Thanks,
> > > Mike
> >
> > No sorry it is not possible.
> > If you need this kind of functionality you will have to use a while loop.
> > You can then setup all manner of conditions to exit the lo
op.
> > Be aware that the loop will always run at least ONCE.
> >
> > A for loop will run X number of times. This is determined either
> > at compile time (if the count is hard coded) or at run time
> > (if you use auto-indexing, or the count is a variable).
> >
> > Kevin Kent -
HELP! FOR LOOP TO SCROLL THROUGH TABLE AND CREATE DATABASE LINK
Hi,
Here's the scenario, not much of a PL programmer, just basic SQL so really need some help people!
I have 2 tables. 1 contains list of DB's and the other contains rules to follow.
I need to create a loop that goes through the table containing the DB's and on each row a DB link is created (Only 1 link allowed!)
Once created, the schema currently logged in with also has an account on the linked DB in order to run scripts- The scripts are stored centrally hence the requirement for the link to the target DB.
There are numerous scripts that need to be executed and can all be called from 1 script, once executed the loop exists and the database link needs to be dropped.
Once dropped, the first loop continues, creating a DB link for the next DB listed in the table (and all the scripts are fired again)
This continues against all the DB's listed in the table.Hi BlueShadow,
Thanks again for the response, you've hit the nail on the head. SQL scripts on a unix server, a loop goes through a table 1 at a time. Each row gets a link created and then all the scripts stored on the server are executed against the db linked to. So I'm assuming this is a loop within a loop.
1 loop to go through the table to create the link and then another loop within once connected to execute all the scripts against the connected DB. Once the scripts are run, the loop exits and moves onto the next server and so on until all the servers have the scripts are run.
It's PL/SQL scripts we're after and not shell scripts as this would free us from the OS constraints.
We have to drop the links due to security. Any idea on o -
I like it, but I can't figure out how to use it for the following situation (printing contents of two arrays using one iterator):
old way:
System.out.println(menuTitle + "/n");
for (int e ; e < length.menuChoices ; e++)
System.out.print(menuChoices[e] + " - " + menuLabels[e]);
}new?
System.out.println(menuTitle + "/n");
for (String e : menuChoices)
System.out.print(e + " - " + menuLabels[????]);
}Is there a nice way to do this or should I just use the old for loop and hope my teacher doesn't think that I just don't know about the new loop? Thanks.Is there a nice way to do this or should I just use
the old for loop and hope my teacher doesn't think
that I just don't know about the new loop?No there isn't. In the new for-loop the loop counter has been abstracted away. You'll have to either use the old for-loop, or introduce a counter in the new.
Another way could be to change the design a little.
class MenueItem {
Type1 choice();
Type2 label();
for (String e : menuItems) { // all MenuItems
System.out.print(e.choise() + " - " + e.label());
} -
How to stop and start a for loop
I've got code and a for loop running in a while loop. What I need to do is simply pause the operation of the for loop until an requirement is met, and but maintain its iteration position throughout each pause interval (not necessarily timed, just paused until the next requirement is met). I've tried wiring a boolean to the "continue if true" terminal of the for loop, but the iteration count restarts to 0 when the loop is started again. Is there a way to stop the for loop, and continue at the particular iteration it is at?
Solved!
Go to Solution.Breakpoints, whether normal or conditional, are just meant for debugging of your code. I had the sense from your question that the pausing you want to do is a part of normal operation of your code. I would NOT recommend using a breakpoint for that situation. It would bring up the block diagram showing the breakpoint when it occurs. A user besides the programmer would not know what to do in that case.
Yes, both the inner and outer loops would have shift registers.
Putting a case structure with a small while loop inside the "Pausing Case" is doable. It just depends on what you are doing or waiting for while the program operation is "paused". -
How to pass the sequence number of current loop in a for loop in FPGA vi to the host
PCI-7830R
LV 8.2
What I was trying to do is to use multiple DIO to generate pulse at different sequence. Mode one is to automatically sweep from DIO1 to DIO20; mode 2 is several DIOs generate pulse simoutaneously. So I use a case structure to make the selection, in the mean time, I set up two for loop in each case so that I can use multiple pulse generations. For example, in scanning mode, if I set 2 exposures, it sweeps from 1 to 20 then do it again.
Then I need to get the loop sequence number, i of each scenario. So I put an indicator within the first loop, and create a local variable of it and put in the second one. Running the FPGA vi alone, I can see the indicator change in each case from 0 to N-1, N being the for loop time.But in the host vi, I tried to add this indicator as an element in the read/write invoke method, in the debugging mode, I could only see it directly jump to N-1 without all the changes I saw in FPGA vi.
Is it possible to get this number passed correctly from FPGA vi to the host vi? ThanksThanks for the reply Jared.
Excuse me if it looks incorrect, but I'm new to FPGA programming, so I would have to look into the FIFO you referred to. I used local variables because for one thing I have several different cases containing for loop in each of them, and I only want one indicator for the "i". If I put the indicator out of any for loop, it's only gonna show the last number which is N-1. For the other thing, it seems like property nodes are not allowed in FPGA vi. And by doing this, I can see the i number changing from 0 to N-1 in each case, well, in FPGA vi's front panel. But while I ran the host vi with everything, the indicator in host vi's front panel only showed the last number N-1. It may be the reason you said, it happened too fast before the indicator in host vi can catch it.
What I want to realize is to group the data I collect in host vi, for example, when I choose multiple exposure in each mode, and the FPGA runs 1 through 20 then do it again, I want the data stored in two groups using the loop sequence number as the seperator in file name. So it goes like 1-1, 2-1.......20-1; then 1-2, 2-2,.....20-2. -
Visa open and close with "for loops"
Hello everyone
In my program I used two "for loops" which include visa write and read for a RS32 port. it is not possible to close a devise with visa close as the out put is changed to 2D array!!! would you please help me with this error
Attachments:
ACU_232.png 108 KBsam009 wrote:
Thanks for reply,
It works for "for loop" but what about "event structure loop" still is error for that.
Right-click on the output tunnel and uncheck "Use Default if Unwired". You will now be forced to wire the VISA Resource through each case.
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines -
PNA Guided Calibration: GPIB write error in for loop
Hi,
I have a LabVIEW program that creates a Guided Power Calibration on a PNA.
After initializing everything properly, I have a for loop that loops through all the manual steps that the user must go through (ex: Connect Channel A of Power meter to Port 1" "Connect male Short to port 1" etc).
The problem is, the program displays an error at the first command: sens:corr:coll:guid:acq STAN1
I says there is an error with the GPIB Write function.
Here are the commands I send:
SYSTRES
DISPlay:WINDow2TATE ON
CALCulate2ARameterEFine:EXT 'MyMeas',S21
DISPlay:WINDow2:TRACe1:FEED 'MyMeas'
CALC1AREL 'CH1_S11_1'
SENS:FREQTAR 2e9
SENS:FREQTOP 4e9
SENSWEOINTS 3
SENS:CORR:COLL:GUID:CONNORT1 'APC 2.4 male'
SENS:CORR:COLL:GUID:CONNORT2 'APC 2.4 male'
SENS:CORR:COLL:GUID:CKITORT1 '85056D'
SENS:CORR:COLL:GUID:CKITORT2 '85056D'
SENSe:CORRection:COLLect:GUIDedSENsor1 ON
SYSTem:COMMunicateSENsor gpib, "13"
SENSe:CORRection:COLLect:GUIDedSENsor1OWer:LEVel -20
sens:corr:coll:guid:init
sens:corr:coll:guid:steps?
//for loop from 1 to total_number_of_steps
sens:corr:coll:guid:desc? <step#>
sens:corr:coll:guid:acq STAN<step#>
The program quits right at the first step, when I send "sens:corr:coll:guid:acq STAN1", although the command is executed.
Also, the VBScript with the same commands works fine.
Can anybody help me? I've been stuck for a while now.
I attached the block diagram of the for loop.
Thanks in advance,
Nicolas
Attachments:
Guided cal for loop.vi 27 KBSending SENS:corr:coll:guid:acq STAN1 \n gives me a different error: -101 "Invalid Character".
From my different attempts at figuring this out, I thought the problem would come from LabVIEW, since the vbscript with the same commands works on the PNA.
I also modified the for loop because I thought each iteration should be linked to the previous one with the error wire (see attached).
I still have the same issue, only the first iteration is executed, then the program quits.
Attachments:
Guided cal for loop.vi 28 KB -
Hi to all!
I have this sample data:
CREATE TABLE person(id NUMBER PRIMARY KEY,
first_name VARCHAR2(30),
father_id NUMBER REFERENCES person(id),
mother_id NUMBER REFERENCES person(id));
INSERT INTO person
VALUES (1, 'John', NULL, NULL);
INSERT INTO person
VALUES (10, 'John''s son Bill', 1, NULL);
INSERT INTO person
VALUES (20, 'John''s daughter Briana', 1, NULL);
INSERT INTO person
VALUES (100, 'Bill''s son George', 10, NULL);
INSERT INTO person
VALUES (101, 'Bill''s son Matthew', 10, NULL);
INSERT INTO person
VALUES (200, 'Briana''s son Greg', 20, NULL);
INSERT INTO person
VALUES (201, 'Briana''s son Fred', 20, NULL);
/Then I execute this PL/SQL anonymous block:
SET SERVEROUTPUT ON
DECLARE
CURSOR children IS
SELECT s.first_name name
FROM person s, person p
WHERE (s.father_id = p.id OR s.mother_id = p.id)
AND p.id = 1;
CURSOR g_children IS
SELECT s.first_name gc_name
FROM person s, person p
WHERE (s.father_id = p.id OR s.mother_id = p.id)
AND p.id IN (SELECT gs.id FROM person gs, person gp
WHERE (gs.father_id = gp.id OR gs.mother_id = gp.id)
AND gp.id = 1);
BEGIN
FOR c_rec IN children LOOP
DBMS_OUTPUT.PUT_LINE(c_rec.name);
FOR g_rec IN g_children LOOP
DBMS_OUTPUT.PUT_LINE(g_rec.gc_name);
END LOOP;
END LOOP;
END;I have this result:
John's son Bill
Bill's son George
Bill's son Matthew
Briana's son Greg
Briana's son Fred
John's daughter Briana
Bill's son George
Bill's son Matthew
Briana's son Greg
Briana's son FredHow could I modify nested for loop, so that I have output like this:
John's son Bill
Bill's son George
Bill's son Matthew
John's daughter Briana
Briana's son Greg
Briana's son FredSo that I have one child and then his children, and then second child and his/her children, and so on.
Thanks!
Edited by: Spooky on 2013.02.06 12:54Suri wrote:
BluShadow wrote:
You would need to parameterize your children query to it only get's the children of that parent.Hi Blu,
I understood that it can be easily solved by CONNECT BY PRIOR clause.
Just for curisosity I am asking you, Assume that if we dont know till what level children details exist in person table (for eg: John's son is Bill , Bill's son is XYZ , XYZ son is ABC etc), is there any better way to acheive this using parameter cursor. Oh yeah, sure... use recursion...
SQL> CREATE TABLE person(id NUMBER PRIMARY KEY,
2 first_name VARCHAR2(30),
3 father_id NUMBER REFERENCES person(id),
4 mother_id NUMBER REFERENCES person(id)
5 )
6 /
Table created.
SQL>
SQL> INSERT INTO person VALUES (1, 'John', NULL, NULL);
1 row created.
SQL> INSERT INTO person VALUES (10, 'John''s son Bill', 1, NULL);
1 row created.
SQL> INSERT INTO person VALUES (20, 'John''s daughter Briana', 1, NULL);
1 row created.
SQL> INSERT INTO person VALUES (100, 'Bill''s son George', 10, NULL);
1 row created.
SQL> INSERT INTO person VALUES (101, 'Bill''s son Matthew', 10, NULL);
1 row created.
SQL> INSERT INTO person VALUES (200, 'Briana''s son Greg', 20, NULL);
1 row created.
SQL> INSERT INTO person VALUES (201, 'Briana''s son Fred', 20, NULL);
1 row created.
SQL>
SQL> set serverout on
SQL>
SQL> declare
2 procedure recurse_persons(father_id in number, lvl number := 0) as
3 cursor cur_person is
4 select *
5 from person
6 where nvl(father_id,0) = nvl(recurse_persons.father_id,0);
7 begin
8 for p in cur_person
9 loop
10 dbms_output.put_line('['||to_char(lvl+1)||']'||lpad(' ',lvl*2,' ')||p.first_name);
11 recurse_persons(p.id, lvl+1);
12 end loop;
13 end;
14 begin
15 recurse_persons(null);
16 end;
17 /
[1]John
[2] John's son Bill
[3] Bill's son George
[3] Bill's son Matthew
[2] John's daughter Briana
[3] Briana's son Greg
[3] Briana's son Fred
PL/SQL procedure successfully completed.With that, we're just using one cursor definition that suits all, and using recursion to go down each branch of the hierarchy, regardless of how deep. Of course you then run the risk (if it's a very deep hierarchy) of getting a "too many open cursors" error. -
Hi all...
I using for loop to display student information and i want to sort the information (e.g. module code, name, admin no and etc) given in ascending and descending order. I use combo box to list and select the (information) to be sorted in either in ascending or decending order.
But, how sld i code in the way that the result will change instance whenever i click the combo box ( e.g name) to be sorted in ascending order. Cos now, it only sort the last index, last student information and not all the student.
Below is what i have done:
String [] headerString = {"Module Group", "Tutorial Group", "Admin No", "Name"};
//Create combo box
JComboBox header = new JComboBox(headerString);
header.setSelectedIndex(3);
header.addActionListener(this);
//Create the radio buttons
ascendButton = new JRadioButton("Ascending", true);
ascendButton.setMnemonic(KeyEvent.VK_UP);
ascendButton.setSelected(true);
descendButton = new JRadioButton("Descending", false);
descendButton.setMnemonic(KeyEvent.VK_DOWN);
//Register a listener for the radio buttons.
ascendButton.addActionListener(this);
descendButton.addActionListener(this);
//Group the radio buttons
group = new ButtonGroup();
group.add(ascendButton);
group.add(descendButton);
buttonPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
buttonPanel.add(header);
buttonPanel.add(ascendButton);
buttonPanel.add(descendButton);
class nameComparator implements Comparator
public int compare(Object o1, Object o2)
Vector one = (Vector)o1;
Vector two = (Vector)o2;
//the following line will return a negative value
//if one is smaller in size than two
// return one - two;
public boolean equals(Object obj)
//don't know what to put it
public void actionPerformed(ActionEvent event)
System.out.println("Before" + v);
if (ascendButton.isSelected())
//Sort by natural order
//Case-insensitive sort, ie. a, C, z
Collections.sort(v, String.CASE_INSENSITIVE_ORDER);
else
//Reverse-order sort
Collections.sort(v, Collections.reverseOrder());
list.setListData(v);
//Reset the model used by the JComboBox after sorting the vector
DefaultComboBoxModel model = new DefaultComboBoxModel(headerString);
header.setModel(model);
System.out.println("After" + v);
//reconstruct the vector and repaint again
repaint();
}Hi all, below is my coding. I still don't know how to start to sort my jlist. hope guys out there can give me some idea. Thanks.
import java.awt.*;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
import javax.swing.text.*;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import java.util.*;
import java.util.Vector.*;
public class Display extends JFrame implements ActionListener{
JButton editButton;
JButton setButton;
JComboBox header;
JLabel imageLabel;
JLabel acadYrLabel;
JLabel semseterLabel;
JLabel moduleCodeLabel;
JLabel moduleGroupLabel;
JLabel tutorialGroupLabel;
JLabel admNoLabel;
JLabel nameLabel;
JPanel aPanel;
JPanel imagePanel;
JPanel soloPanel;
JPanel buttonPanel;
JPanel contentPanel;
JPanel textFieldPanel;
JRadioButton ascendButton;
JRadioButton descendButton;
JScrollPane infoPane;
JScrollPane scrollPane;
JTextField textField;
JTextField moduleGroupField;
JTextField tutorialGroup;
JTextField adminNo;
JTextField nameField;
JTextField acadYrField;
String[] headerString = {
"Module Group", "Tutorial Group", "Admin No", "Name"};
public Display()
//Create combo box
header = new JComboBox(headerString);
header.setSelectedIndex(3);
header.addActionListener(this);
//Create the radio buttons
ascendButton = new JRadioButton("Ascending", true);
ascendButton.setMnemonic(KeyEvent.VK_UP);
ascendButton.setSelected(true);
descendButton = new JRadioButton("Descending", false);
descendButton.setMnemonic(KeyEvent.VK_DOWN);
//Register a listener for the radio buttons.
ascendButton.addActionListener(this);
descendButton.addActionListener(this);
//Group the radio buttons
ButtonGroup group = new ButtonGroup();
group.add(ascendButton);
group.add(descendButton);
buttonPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
//buttonPanel.setAlwaysOnTop(true);
buttonPanel.add(header);
buttonPanel.add(ascendButton);
buttonPanel.add(descendButton);
imagePanel = new JPanel(new GridLayout(10, 3));
imagePanel.addComponentListener(new ComponentAdapter()
public void componentResized(ComponentEvent e)
JPanel p = (JPanel) e.getComponent();
populate(50,60);
public void populate(int length, int height)
for (int i = 0; i <30; i++)
soloPanel = new JPanel(new BorderLayout(0, 20)); //Specified gaps between components
soloPanel.setPreferredSize(new Dimension(length, height+150));
soloPanel.setBackground(Color.GRAY);
//Create the text field and set it up
acadYrField = new JTextField();
acadYrField.setBackground(Color.GRAY);
acadYrField.setColumns(20);
acadYrField.setEditable(false);
acadYrField.setText("2004");
tutorialGroup = new JTextField();
tutorialGroup.setBackground(Color.GRAY);
tutorialGroup.setColumns(20);
tutorialGroup.setEditable(false);
tutorialGroup.setText("BM0539"+i+i);
adminNo = new JTextField();
adminNo.setBackground(Color.GRAY);
adminNo.setColumns(20);
adminNo.setEditable(false);
adminNo.setText("012345X" + i);
moduleGroupField = new JTextField();
moduleGroupField.setBackground(Color.GRAY);
moduleGroupField.setColumns(20);
moduleGroupField.setEditable(false);
moduleGroupField.setText("IT12345");
nameField = new JTextField();
nameField.setBackground(Color.GRAY);
nameField.setColumns(20);
nameField.setEditable(false);
nameField.setText("Alex" + i);
textFieldPanel = new JPanel(new FlowLayout(FlowLayout.TRAILING));
textFieldPanel.setBackground(Color.GRAY);
textFieldPanel.setPreferredSize(new Dimension(235, 180));
textFieldPanel.add(acadYrField);
textFieldPanel.add(tutorialGroup);
textFieldPanel.add(adminNo);
textFieldPanel.add(moduleGroupField);
textFieldPanel.add(nameField);
infoPane = new JScrollPane(textFieldPanel,
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
editButton = new JButton("Edit");
editButton.addActionListener(this);
//Create panel and add edit button to panel
JPanel editPanel = new JPanel();
editPanel.add(editButton);
editPanel.setBackground(Color.GRAY);
soloPanel.add(infoPane, BorderLayout.CENTER);
soloPanel.add(editPanel, BorderLayout.SOUTH);
imagePanel.add(soloPanel);
public static void main(String[] args)
Display d = new Display();
d.createAndShowGUI();
public void createAndShowGUI()
//Make sure we have nice window decorations
JFrame.setDefaultLookAndFeelDecorated(true);
JDialog.setDefaultLookAndFeelDecorated(true);
//Create and set up the window
JFrame frame = new JFrame("IABC");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
contentPanel = new JPanel(new BorderLayout());
contentPanel.add(buttonPanel, BorderLayout.NORTH);
contentPanel.add(imagePanel, BorderLayout.SOUTH);
scrollPane = new JScrollPane(contentPanel);
frame.setContentPane(scrollPane);
frame.pack();
frame.setSize(500, 300);
frame.setLocation(350, 250);
frame.setVisible(true);
frame.setLocationRelativeTo(null);
public void actionPerformed(ActionEvent event)
if (ascendButton.isSelected())
//Sort by natural order
//Case-insensitive sort, ie. a, C, z
if (header.getSelectedIndex() == 0)
Collections.sort(v, new myComparator());
else
//Reverse-order sort
Collections.sort(v, Collections.reverseOrder());
list.setListData(v);
//Reset the model used by the JComboBox after sorting the vector
DefaultComboBoxModel model = new DefaultComboBoxModel(headerString);
header.setModel(model);
System.out.println("After" + v);
//reconstruct the vector n repaint again
repaint();
class myComparator implements Comparator
public int compare(Object o1, Object o2)
String one = (String)o1;
String two = (String)o2;
return one.compareTo(two);
} -
I know this question has probably been asked and answered before, but after searching/reading in the forums, I'm still confused.
So I would like my VI to effectively move a stage a given distance with incremental sizes with pauses of between each step.
Effectively: "Go To" _____ With X step size: causes the VI to: move, pause, move pause...etc until the stage has reached the end.
To accomplish this I set up a for loop inside a case structure, and took the "Go To" / by Step Size to get the number of iterations the loop aught to run (labview apparently rounds the double result to the integer form), and then I send the "Step Size" to the MoveAbs VI.
I am not sure if my logic is terribly off, but when I perform the command, the stage at least moves, but not to the correct location.When I inserted probes, they list the correct values being sent to the subvi's etc...
Does anyone have an idea why this would not work? Any better ideas to institute this type of motion?
Thanks
Attachments:
delayedmotiontrial2.vi 85 KBHey Tim,
I've got another question for you--I've been working on the program and I think I finally understand the basic outline. I've been trying to add other subvi's to increase functionality and I came across a problem:
The error list says that the selector values of the case structure are not unique--which is true of the program I am sending you. So naturally I deleted the extra "VI INI" which was tagged onto the default case. However doing so caused my program to crash--or more accurately cycle in an infinite loop. The program initializes over and over again. The "INI VI" sends another "INI VI" to the array and gets stuck.
I am not quite sure what is wrong, because when I looked at the original program you had sent to me, and earlier versions I had edited, I noticed that they have the same code within the "INI VI" case...in addition, now when I open previous programs--that were functioning perfectly well before--I get the same error message complaining about "not unique selector values". I honestly don't recall ever adding "INI VI" to the default case...
I am attaching the program and was wondering your thoughts, especially given the retrospective error...
Let me know if I was unclear in explaining the problem etc...and thanks again for your help. Others' input welcomed too!
Nathan
Attachments:
DelayedMotionTrial7c.vi 85 KB
State Machine States.ctl 5 KB -
For loop wont loop through array built from spread sheet
im probably doing sonthing really silly but........
first i build and array out of data from a spreadsheet (RefLookup)
the spreadsheet contains 3 rows the top row is my label (to be returned later)
the second row it my maxmum value
the third row is my minimum value.
Ref in is my live feed of data to be looked up.
i then put this into a for loop, to loop through the array untill it finds which range of data the Ref in lies.....
then i simply stop the loop and output the index value.
this index value is the used to look up the spreadsheet data again and return the label for that index.
from what i can gather the code should.... work. but it doesnt seem to go passed the first itteration of the for loop
any ideas?
please and thanks
John
Solved!
Go to Solution.
Attachments:
jmRange.vi 13 KB
RefLookup.csv 1 KB
InRange.PNG 34 KBYou need to set the delimiter to comma, else you don't get all data. (read from spreadsheet file)
You are doing this way too complicated. Here's equivalent code. I am sure it can be simplified much more!
You don't need the outer while loop. finding it once is sufficient.
You probably want to add a "select" after the loop that selects NaN instead of the last value if nothing is found, based on the boolean.
Message Edited by altenbach on 03-30-2010 02:55 PM
LabVIEW Champion . Do more with less code and in less time .
Attachments:
finder.png 8 KB
Maybe you are looking for
-
Error in installing oracle 9ids
hi, i try installing oracle 9ids this error occured "Invalid staging area. There are no top level components for windows 98 available for installation in this staging area." please help
-
I bought an IPhone 3gs and tried to reset the APN through Strait Talk Wireless but when I click on settings then "General" tab they tell me to click on the "Network" tab but there is not a "Network" tab? After Network, I was supposed to go to Cellula
-
Import Excel File Data into oracle database table.
HI, i want to insert data into a specific table from a excel file. please help me.. for example emp.xls file's data need to be import in emp database table. thanks in advance...
-
Regarding Po output messages in edi medium
Hi dears, can u please post me the answers for following questions.. 1. what type output messages used for PO? 2. How to trigger neu type output message for particular PO? 3. How to delete neu type output message for particular PO? 4.which program o
-
Content Mirroring with WebDynpro ESS
Hi, I created the ECC5 ESS package in my clients namespace. using Content Mirroring (this works nicely). BUT the ESS role's Area/Group Area pages configed in the IMG still point to the standard installed ESS package. ie I nav to my ESS role click I