Assigning element (node) to variable in a loop
Hello,
I will get below input as <Request> .<instance></instance>.... <instance><instance>.. </Request>(see below) to my soa composite process. I have an instance.xsd . I have created an variable Instancexml element of type instance.xsd ,so Instancexml variable can hold all the values in order to utilize attributes,elements in my process.
I have assigned a count for <instance> which is 2 in this case.
I am looping through count and trying to assign first instance xml to Instancexml variable , but when I use this xpath, both instances are getting copied instead of one (when count=1)
bpws:getVariableData('inputVariable','payload',concat('/ns1:Request/ns1:instance[',bpws:getVariableData('j'),']'))
What is the correct xpath?
<Request>
<instance>
<attribute name="abc" type="string"/>
<attribute name="def" type="string"/>
<element1 name="123" type="string">
<element2 name="456" type="string">
<element3 name="888" type="string">
</instance>
<instance>
<attribute name="xyz" type="string"/>
<attribute name="xxy" type="string"/>
<element1 name="223" type="string">
<element2 name="678" type="string">
<element3 name="333" type="string">
</instance>
</Request>
You shouldn't need to do a concat within the XQuery path parameter. Try the following:
bpws:getVariableData('inputVariable','payload','/ns1:Request/ns1:instance[bpws:getVariableData("j")]')
Similar Messages
-
Is an assigned value to an variable in the domain of the data element
Hi
how can I check if the value, which I want to assign to an variable is in the domain of the data element of that variable.
Example:
I defined a data element myDataElement. The Elementary Type of myDataElement is the Domain myDomain.
myDomain has the Format: Char with Length 1 and the fixed values 'A' and 'B'.
The following code works, but IMHO should not:
DATA testVar TYPE myDomain.
testVar = 'Foo'.
The value of testVar is now: 'F' .
As 'F' is not in the fixed values, this is a behaviour which I don't want. How can I prevent this from not happening (without using a bunch of IFs)?
In such a case, it were nice if an exception were raised.
Regards
GillesThanks Gungor.
I tried it with DDUT_DOMVALUES_GET. Works so far. I think I will write some FMs on my own, like this one:
FUNCTION z_valueisindomain.
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(IV_DOMAINNAME) TYPE DDOBJNAME
*" REFERENCE(IV_EVALUATING_VALUE) TYPE ANY
*" EXPORTING
*" REFERENCE(EV_DESTINATION) TYPE ANY
*" EXCEPTIONS
*" ILLEGAL_INPUT
*" NOT_IN_DOMAIN
DATA domainvalues TYPE TABLE OF dd07v.
CALL FUNCTION 'DDUT_DOMVALUES_GET'
EXPORTING
name = iv_domainname
TABLES
dd07v_tab = domainvalues
EXCEPTIONS
illegal_input = 1
OTHERS = 2.
IF sy-subrc <> 0.
RAISE illegal_input.
ENDIF.
DATA oneline TYPE dd07v.
LOOP AT domainvalues INTO oneline.
IF oneline-domvalue_l EQ iv_evaluating_value.
ev_destination = iv_evaluating_value.
EXIT.
ENDIF.
ENDLOOP.
IF ev_destination IS INITIAL.
RAISE not_in_domain.
ENDIF.
ENDFUNCTION.
I'm pretty new to ABAP, so this FM might not be very elegant.
Regards
Gilles -
Assigning a node value from an XML variable to a String type in Weblogic Process Integrator
Hi,
Is there any way to assign a node value from an XML variable to a String variable
in Weblogic Process Integrator...
Thanx.
Narendra.Nerendra
Are you talking about using Xpath on the XML document and assigning to a
variable, it is unclear what you are asking
Tony
"Narendra" <[email protected]> wrote in message
news:3bba1215$[email protected]..
>
Hi,
Is there any way to assign a node value from an XML variable to a Stringvariable
in Weblogic Process Integrator...
Thanx.
Narendra. -
Can we assign value to a variable in PL/SQL Loop
Hi
Can we assign value to a variable in PL/SQL Loops?
DECLARE
V_Num NUMBER;
BEGIN
LOOP
V_Num := 10;
DBMS_OUTPUT.put_line(V_num);
V_Num := V_Num - 1;
EXIT WHEN V_Num = 0;
END LOOP;
END;
In the above program, Can we assign V_num with a value 10????????
Thanks & Regards,
Hari Babu
Edited by: 1004977 on Jun 5, 2013 2:40 AMHi,
1004977 wrote:
Hi
Can we assign value to a variable in PL/SQL Loops?
DECLARE
V_Num NUMBER;
BEGIN
LOOP
V_Num := 10;
DBMS_OUTPUT.put_line(V_num);
V_Num := V_Num - 1;
EXIT WHEN V_Num = 0;
END LOOP;
END;
In the above program, Can we assign V_num with a value 10????????Yes; the example you posted does that.
When the loop starts, the value 10 is assigned to v_num. You should see that value displayed by the put_line statement.
After that, v_num is set to 10 - 1 = 9.
Next, the EXIT condition is evaluated. At this point, v_num is 9, not 0, so the loop runs again. V_num is set to 10 again, and the loop continues forever (or, in some versions, until the dbms_output buffer is filled and an error occurs.) -
Cannot assign value to a Variable of Complex Type beyond index 1
Hello:
I have a variable defined as a complex type as followed. I tried to assign a value to each of the two elements but it only allows me to assign to the 'element#1.
This statement that tries to assign a value into element#2 will not work, if I assign with '[1]' for the first element it will work:
<copy> <---- THIS WORKS
<from expression="'John'"/>
<to variable="My_Variable"
part="My_Collection"
query="/ns9:My_Collection/ns9:Collection/ns9:Collection_Item[1]/ns9:pname"/>
</copy>
<copy> <---- THIS DOES NOT WORK
<from expression="'John'"/>
<to variable="My_Variable"
part="My_Collection"
query="/ns9:My_Collection/ns9:Collection/ns9:Collection_Item[2]/ns9:pname"/>
</copy>
Is there something wrong with my definition below that allows only element#1 to be refererenced but not element#2???? Am I missing some kind of initialization that is needed to initialize both elements????
Here are my message and Complex Type definitions:
<variable name="My_Variable" messageType="ns8:args_out_msg"/>
<message name="args_out_msg">
<part name="My_Collection" element="db:My_Collection"/>
</message>
<element name="My_Collection">
<complexType>
<sequence>
<element name="Collection" type="db:Collection_Type" db:index="2" db:type="Array" minOccurs="0" nillable="true"/>
<element name="Ret" type="string" db:index="3" db:type="VARCHAR2" minOccurs="0" nillable="true"/>
</sequence>
</complexType>
</element>
<complexType name="Collection_Type">
<sequence>
<element name="Collection_Item" type="db:Collection_Type_Struct" db:type="Struct" minOccurs="0" maxOccurs="unbounded" nillable="true"/>
</sequence>
</complexType>
<complexType name="Collection_Type_Struct">
<sequence>
<element name="pname" db:type="VARCHAR2" minOccurs="0" nillable="true">
<simpleType>
<restriction base="string">
<maxLength value="25"/>
</restriction>
</simpleType>
</element>
</sequence>
</complexType>
The error msg it gives me is as followed:
[2010/09/04 00:47:59] Error in <assign> expression: <to> value is empty at line "254". The XPath expression : "" returns zero node, when applied to document shown below:less
oracle.xml.parser.v2.XMLElement@1fa7874
[2010/09/04 00:47:59] "{http://schemas.xmlsoap.org/ws/2003/03/business-process/}selectionFailure" has been thrown.less
-<selectionFailure xmlns="http://schemas.xmlsoap.org/ws/2003/03/business-process/">
-<part name="summary">
<summary>
XPath query string returns zero node.
According to BPEL4WS spec 1.1 section 14.3, The assign activity <to> part query should not return zero node.
Please check the BPEL source at line number "254" and verify the <to> part xpath query.
</summary>
</part>
</selectionFailure>
Thanks
NewbieHello:
Base on the suggestion to use 'append' instead of 'copy', I tried to define a 'singleNode' which is of type 'Collection_Type_Struct' so I can append this individual 'struct' into my array (i.e. as the 2nd. element of my array "/ns9:My_Collection/ns9:Collection/ns9:Collection_Item"), but I am getting an error in defining this variable as:
<variable name="singleNode" element="Collection_Type_Struct"/> <--- error
Can someone tell me how should I define "singleNode" so I can put a value in it and then append this 'singleNode' into the array:
<variable name="singleNode" element=" how to define this????"/>
<assign>
<copy>
<frem expression="'Element2Value'"/>
<to variable="singleNode"
part="My_Collection"
query="/ns9:My_Collection/ns9:Collection/ns9:Collection_Item/ns9:pname"/>
</copy>
</assign>
<bpelx:assign>
<bpelx:append>
<from variable="singleNode" query="/ns9:My_Collection/ns9:Collection/ns9:Collection_Item"/>
<to variable="My_Variable"
"part="My_Collection"
query="/ns9:My_Collection/ns9:Collection"/>
</bpelx:append>
</bpelx:assign>
Again here is my definition in my .xsd file:
<element name="My_Collection">
<complexType>
<sequence>
<element name="Collection" type="db:Collection_Type" db:index="2" db:type="Array" minOccurs="0" nillable="true"/>
<element name="Ret" type="string" db:index="3" db:type="VARCHAR2" minOccurs="0" nillable="true"/>
</sequence>
</complexType>
</element>
<complexType name="Collection_Type">
<sequence>
<element name="Collection_Item" type="db:Collection_Type_Struct" db:type="Struct" minOccurs="0" maxOccurs="unbounded" nillable="true"/>
</sequence>
</complexType>
<complexType name="Collection_Type_Struct">
<sequence>
<element name="pname" db:type="VARCHAR2" minOccurs="0" nillable="true">
<simpleType>
<restriction base="string">
<maxLength value="25"/>
</restriction>
</simpleType>
</element>
</sequence>
</complexType>
Thanks for any help!!!! -
OSB : BEA-382510: OSB Assign action failed updating variable
Hi all,
I just started learning OSB and created a simple process .
This is my request :
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
</soap:Header>
<soapenv:Body>
<hel:getGreeting xmlns:hel="http://hello.alsb.com/">
<!--Optional:-->
<arg0>string</arg0>
</hel:getGreeting>
</soapenv:Body>
</soapenv:Envelope>
im getting a error response in Assign:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:Server</faultcode>
<faultstring>
BEA-382510: OSB Assign action failed updating variable "Test": weblogic.xml.query.exceptions.XQueryTypeException: {err}XP0006: "element return { {http://www.w3.org/2004/07/xpath-datatypes}untypedAny }": bad value for type {http://www.w3.org/2001/XMLSchema}string
</faultstring>
<detail>
<con:fault xmlns:con="http://www.bea.com/wli/sb/context">
<con:errorCode>BEA-382510</con:errorCode>
<con:reason>
OSB Assign action failed updating variable "Test": weblogic.xml.query.exceptions.XQueryTypeException: {err}XP0006: "element return { {http://www.w3.org/2004/07/xpath-datatypes}untypedAny }": bad value for type {http://www.w3.org/2001/XMLSchema}string
</con:reason>
<con:location>
<con:node>RouteTo_HelloWorldBiz</con:node>
<con:path>response-pipeline</con:path>
</con:location>
</con:fault>
</detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
This is my Xquery:
xquery version "1.0" encoding "Cp1252";
declare namespace xf = "http://tempuri.org/GoodbyeWorld_SB/XQuery/Hello_to_GoodBye/";
declare function xf:Hello_to_GoodBye($helloStr as xs:string)
as xs:string {
replace($helloStr, 'HELLO', 'Goodbye')
declare variable $helloStr as xs:string external;
xf:Hello_to_GoodBye($helloStr)
in my message response pipeln of the proxy service:
i have added the assign and given the expression : $body/hel:getGreetingResponse/return
var :Test
After the assign: i have given a replace activity:
xpath: ./hel:getGreetingResponse/return
varabile : body
Expression : string($Test)
when i test in OSB console:
im getting this error:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:Server</faultcode>
<faultstring>
BEA-382510: OSB Assign action failed updating variable "Test": weblogic.xml.query.exceptions.XQueryTypeException: {err}XP0006: "element return { {http://www.w3.org/2004/07/xpath-datatypes}untypedAny }": bad value for type {http://www.w3.org/2001/XMLSchema}string
</faultstring>
<detail>
<con:fault xmlns:con="http://www.bea.com/wli/sb/context">
<con:errorCode>BEA-382510</con:errorCode>
<con:reason>
OSB Assign action failed updating variable "Test": weblogic.xml.query.exceptions.XQueryTypeException: {err}XP0006: "element return { {http://www.w3.org/2004/07/xpath-datatypes}untypedAny }": bad value for type {http://www.w3.org/2001/XMLSchema}string
</con:reason>
<con:location>
<con:node>RouteTo_HelloWorldBiz</con:node>
<con:path>response-pipeline</con:path>
</con:location>
</con:fault>
</detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
aany suggestions on where the issue is.
im totaly stuck here:
TIA,
karthikit is not clear at which point you are invoking Hello_to_GoodBye, and using which argument
anyway it's likely that you are passing an Xml element (a node, something like <hello>Charlie</hello>) instead of a simple type (a string, like "Charlie")
you should use the function data($body/bla) or text ($body/bla/text() ) to extract the value (Charlie) of your element -
How to rename element (node) names in an XMLType column?
I have a source table with a xml data stored in an XMLType column.
The xml contains elements/nodes identified by numbers. I need to replace the numbers with the appropriate names.
The plsql below does this, but has two issues:
i. It selects the data into a clob and does a text replace on the elements in a loop. This works, but is super slow for 3500+ xml rows (about 500 node pairs per row).
ii. Once the data has had the element numbers replaced with the names, it inserts the new xml (clob wrapped in xmltype function) into the table with the XMLType attribute.
The problem with the latter action is that it is failing due to nls client vs server settings, or so it appears from what I could dig up. The actual error message:
ORA-19202: Error occurred in XML processing
LPX-00242: invalid use of ampersand ('&') character (use &)
Error at line 3
There are come entities in the original xml like "" (the degree symbol).
My question is two-fold:
a). Can I replace the element names without straying from the xmltype datatype? If so, how?
b). If I cannot do "a.)", then what must I do ensure that the clob gets converted correctly to xmltype and inserted into the table?
SQL> select <some rows> from nls_database_parameters ;
PARAMETER VALUE
NLS_LANGUAGE AMERICAN
NLS_TERRITORY AMERICA
NLS_CHARACTERSET WE8ISO8859P1
NLS_NCHAR_CHARACTERSET AL16UTF16
NLS_RDBMS_VERSION 10.2.0.1.0
SQL> SELECT * FROM NLS_SESSION_PARAMETERS;
PARAMETER VALUE
NLS_LANGUAGE AMERICAN
NLS_TERRITORY AMERICA
----code below-----
(note, this is a stripped down version of the original, so there may be typos)
declare
l_xmlclob CLOB;
l_newxml XMLType;
v_record_uid NUMBER(20);
CURSOR my_cur IS
select a.elementname,b.tagname
from t_elements a, t_tags b
where (a.element_uid = b.element_uid)
begin
select br.xml_data.getClobVal() xml_data into l_xmlclob from t_elements;
FOR my_rec IN my_cur LOOP
l_xmlclob := replace(l_xmlclob,my_cur.elementname,my_cur.maptag_name);
END LOOP;
l_newxml := XMLType(l_xmlclob);
insert into test_translated_xml (xml_data) values (l_newxml);
end;
(hopefully I haven't missed anything)
Any tips or hints would be much appreciated.
Thanks!Hello again,
Take a look at html entity codes: http://www.w3schools.com/tags/ref_entities.asp.
You can use this:
insert into t values (xmltype('<test>'||dbms_xmlgen.convert('this is a test &')||'deg;</test>'));
or
insert into t values (xmltype('<test>'||dbms_xmlgen.convert('this is a test &')||'#176;</test>'));
see this: ° (& deg;) or this: ° (& #176;)
SQL*Plus will not display degree character. But this is valid enitity code, and when you generate HTML out of this, it should be displayed properly in web browser.
HTML is in fact XML, that is validated by specific DTD (Document Type Definition).
Paweł -
Assigning value to a variable.
i have one doubt.
we can assign value to a variable either in declaration section or in exectuion section.
so please explain when and wherer should we assign value to a variable.
thank you very much.I think the best way to look at it is...
If you don't want your variable(s) to have default values that are NULL, assign a value in the declaration section, otherwise assign it where you feel like.
If you take an example of:
declare
v_sum number := 0; -- default variable to 0
cursor cur_test is
begin
for i in cur_test
loop
v_sum := 0; -- set variable to 0 before the loop
loop
exit when .. some condition ..
v_sum := v_sum + ..
end loop;
end loop;
end;
/.. we have a need to set the variable v_sum to 0 before each iteration of the internal loop, so there's little point in having it defaulted to 0 in the declaration section, hence I wouldn't typically default it there and would typically have the code as..
declare
v_sum number; -- no point in defaulting it
cursor cur_test is
begin
for i in cur_test
loop
v_sum := 0; -- set variable to 0 before the loop
loop
exit when .. some condition ..
v_sum := v_sum + ..
end loop;
end loop;
end;
/It all depends on what you're doing and what seems the most logical or preferred option.
Defaulting values in the declaration section can let you see clearly what the starting values are for things, but only if you really need to do it. -
Assigning value to a variable in Script Component.
I'm pretty new to SSIS development and need to figure out a problem with assigning a value to a user defined variable. I created a pretty simple package. It reads a flat file, extracts date from a header record and subsequently uses derived column component
to reformat data to the desired output format. One of the columns (FileRunDate,
string, length 8) in the derived component is defined as a string and in the expression I'm assigning it to a variable I set earlier in the script component -
@[User::vRunTimeDate]. When the process runs, the output file gets generated, however FileRunDate reflects
originally set varible's value. It seems that the variable assignment in the script task does not work, even though in the debug mode, I do see how the value is being set. The variable has an attribute of ReadWrite. Is it due to the fact that the value is
being set in the same workflow?
Any feedback is greatly appriciated.Unfortunately I'm unable to add a screenshot of the process, for some reason I get an error message when I try to do that. In a nutshell the entire workflow consist of flat file source component, following by a script component (this is where I read and
assign the variable)
public override void PostExecute()
IDTSVariables100 vars;
base.PostExecute();
// Set run date
if (strRunDate != null)
VariableDispenser variableDispenser = (VariableDispenser)this.VariableDispenser;
variableDispenser.LockForWrite("User::vRunTimeDate");
variableDispenser.GetVariables(out vars);
// Set the variable
vars["User::vRunTimeDate"].Value = strRunDate;
//Unlock the variable
vars.Unlock();
//Variables.vRunTimeDate = strRunDate;
then goes conditional split ( filtering out unwanted records), which is connected to a derived column component (this is where one of the columns get assigned a variable's value), one more script component (this where I identify
specific data element and do a replace command) and finally flat file destination.
BTW, the article in the provided URL clearly states that variable won't reflect assigned value till the entire workflow has finished. If that's the case, then I think I know my
answer. Is there is such a thing as putting execution of different steps in a different step, so anything executed subsequently will see that value? -
MQ:OSB Assign action failed updating variable "ServiceRequest"
Hi
We have a problem with the MQ adapters in Oracle Service Bus.
If we (by accident/break testing) put messages on the queue that are invalid XML (such as "Banana" as plain text), the OSB goes into an infinte loop with this message, as it can never be dequeued due to:
<BEA-381901> <Exception in MQ Inbound Request: TransportException EndPoint: T20230_GoodsEvent/ProxyServices/T20230_G
oodsEvent, com.bea.wli.sb.transports.TransportException: OSB Assign action failed updating variable "ServiceRequest": com.bea.wli.common.xquery.XQueryException: Error parsing XML: {err}FORG0
005: expected exactly one item, got 0 items
com.bea.wli.sb.transports.TransportException: OSB Assign action failed updating variable "ServiceRequest": com.bea.wli.common.xquery.XQueryException: Error parsing XML: {err}FORG0005: expect
ed exactly one item, got 0 itemsThis even prevents the message from being put on the dead letter queue.
Any hints?Correct, but we have tried switching to Text to no avail.
-
Namespace Prefix in the Root Element of the variable
Hi Gurus,
We need to call a webservice which requires a namespace prefix at the root elemnt of the xml payload. But as we know that the default behaviour of BPEL removes the prefix so the invoke activity is failing and so we are stuck.
I found this thread Namespace prefix in Root element missing during variable assignment but i feel the solution specified in this link works only in SOA 10g environment Please let us know what needs to be done?
Appreciate a prompt response.
NOTE: SOA Suite Version- 11.1.1.4
Regards
AyushHi All,
we are also facing the same issue, Please provide the solution if anyone knows. We are also using the SOA Suite 11g Version. -
If i use two different formula nodes with the same output and input variable names will the variables (scope) be the same? In the first formula node i define a variabe "int32 first ==0" then in a seperate node embedded in a for loop structure I write " if(first==0) first = chan;". That way the variable "first" is set equal to "chan" only once through all acquisitions of the for loop b/c "first " only equals 0 at the beginning of the loop. My problem is that after running the program more then once the value of "first" remains the same regardless of the new value of "chan".
I believe that the variables are local to the formula nodes themselves.
Therefore, in your first formula node, first is set to 0. In the second, if you don't define an initial value, it is assumed zero. So the first time through, it will get set to the value of chan. But the second time through, it already equals chan in the second formula node (not reset by the first formula node--they are separate variables). Therefore, it will never go to a new value of chan until it is reset to 0.
Mark -
Node creation and addition to existing Element Node
Hi all,
I have a class that opens a xml file, loads the Document and then, from a method, I am trying to add sub nodes to one of the Element node from the XML document. It just doesn't work.
This is the method that is supposed to add the nodes:
public Node getSubNode( Node iCurrentNode )
// Method local variables
DocumentBuilder lBuilder = null;
Document lDocument = null;
DocumentBuilderFactory lFactory = DocumentBuilderFactory.newInstance();
// Prepare the document and final Node to return
lBuilder = lFactory.newDocumentBuilder();
lDocument = lBuilder.newDocument();
Element lSubMenu = lDocument.createElement("sub_menu");
lSubMenu.setAttribute("ID", "User20");
lSubMenu.setAttribute("label", "Montreal user 1");
iCurrentNode.appendChild( lSubMenu );
lSubMenu = lDocument.createElement("sub_menu");
lSubMenu2.setAttribute("ID", "User21");
lSubMenu2.setAttribute("label", "Montreal user 2");
lDocument.appendChild(lSubMenu2);*/
return iCurrentNode;
I always get a "org.apache.crimson.tree.DomEx: WRONG_DOCUMENT_ERR: That node doesn't belong in this document."
So I understand by this that I am working with a Document that I declared in this method and thus, for an unknown reason, seem unable to add this node to my existing Element node.
What should I do to be able to add these nodes to my input Node?
Dominique PaquinOk, to answer my own question, and for the benefit of future people searching here for an answer, I'd used 2 different Document instance for the creation of my 2 nodes, one for the creation of the basic Node structure and one for the creation of the node that would be added to the other one. Since the importNode (done on the first one ) removes the parent from the imported node, I was no longer in a position to access the parent reference.
I simply created a single Document in my class as a global variable and used this single entity to create all my nodes (the original and the one added to the original), It solved all my problems.
I don't know if I was clear anough but if you need further explanation drop me a line.
[email protected]
http://www.okiok.com -
Problem using local variable in event loop
I have a state machine from which I want to monitor various controls, including "Start" and "Stop" buttons. Not every state needs to monitor the controls. At present, most states run timed loops. In the first state that reads the front panel, I have an Event structure (inside a While loop) that monitors the various controls' Change Value events. For numeric controls, I update variables (in shift registers) as needed. The "Start" button is used to end the While loop controlling the Event structure, allowing the State to exit to the next state.
My problem comes in subsequent states that employ this same idea. Here, I put a Local Variable bound to the Start button and use the same code, but it frequently happens that when I enter this particular state, I cannot "turn on" the control -- I push the button, but it stays off. Curiously, if it was On when I enter, I can turn it off, but then I'm stuck not being able to turn it on.
I mocked up a very simply routine that illustrates this. There are two sequences (corresponding to the two states). Both use an Event loop with a local variable bound to my Stop button (really this is an LED control with custom colors). I've deliberately moved the "initialization" (the declaration of the control in the block diagram) out of the Event loops -- putting it inside the first loop modifies the behavior in another strange way.
Here's my thinking on how I would expect this to work: The code outside Event Loop 1 should have little effect. Assume the Stop button is initially Off. You will "sit" in Event Loop 1 until you push the Stop button, changing its value to True; this value will be passed out of the Event case and cause the first While loop to exit. You now enter the second sequence. As I understand the Exit tunnel, it defaults to "False", so I'd expect to stay in the second Event loop until I turn the Stop button from On to Off, which will pass out a False, and keep me in the While for one more button push. However, this doesn't happen -- I immediately exit, as though the "True" value of the Stop local variable is being seen and recognized by the Event loop (even though it hasn't changed, at least not in the context of this second loop).
An even more curious thing occurs if I start this routine with the Stop button turned on. Now I start in my Event loop waiting for a change, but this time the change will be from On to Off, which won't cause an exit from the frame. This will be reflected by having the While loop count increment. We should now be in the state of the example above, i.e. in an Event loop waiting for the control to be pushed again, and turned On. However, clicking the control has no effect -- I cannot get it to "turn on".
Where am I going astray in my thinking? What is it about this method of doing things that violates the Labview paradigm? As far as I can tell, what I'm doing is "legal", and I don't see the flaw in my reasoning, above (of course not -- otherwise I'd have fixed it myself!). Note that because I'm using local variables inside Event loops (and I'm doing this because there are two places in my code where I want to do such testing), the Stop control is not latching (as required). Is there something that gets triggered/set when one reads a latched control? Do I need to do this "manually" using my local variable?
I'll try to attach the simple VI that illustrates this behavior.
Bob Schor
Attachments:
Simple Stop Conundrum.vi 14 KBaltenbach wrote:
Ravens Fan wrote:
NEVER have multiple event structures that share the same events.
Actually, that's OK. NOT OK is having multiple event structures in the same sequence structure.
See also: http://forums.ni.com/ni/board/message?board.id=170&message.id=278981#M278981
That's interesting. I had always thought I read more messages discouraging such a thing rather than saying it was okay. Your link lead me to another thread with this message. http://forums.ni.com/ni/board/message?board.id=170&message.id=245793#M245793. Now that thread was mainly concentrating on registered user events which would be a different, but related animal.
So if you have 2 event structures they each have their own event queue? So if you have a common event, one structure pulls it off its event queue and it does not affect the other structure's event queue? I guess the inherent problem with this particular VI was that the second event structure locked the front panel. Since the code never got to that 2nd event structure because the first loop never stopped because the change was from true to false. After reading your post and the others, I did some experimentation and turned off the Lock front panel on the 2nd structure, and that prevented the lockup of the program.
Overall, the example VI still shows problems with the architecture and I think your answer should put the original poster on the right track. I think as a rule I would probably never put the same event in multiple structures, I feel there are better ways to communicate the same event between different parts of a program, but I learned something by reading your reply and about how the event structures work in the background. Thanks. -
Error while executing the Job:Cannot assign NULL to host variable 1
Hello!
I have the following issue:
Error while executing the Job:Cannot assign NULL to host variable 1. setNull() can only be used if the corresponding column is nullable. The statement is "INSERT INTO "VIRSA_... (see log for details)
Note 1362138 - Rule generation - null pointer exception virsa_cc_rtmap doesn't me. After uploading files of ZCC_DOWNLOAD_SAPOBJ and ZCC_DOWNLOAD_DESC I got the same problem during job running...
How can I find out where is the problem?Hi
That looks like your fields are disabled but they could still be causing the problem edited ( nah - talking rubbish as you've put dummy " " in there) edited - the 'null' error caused many background jobs to fail but, once we had the evidence to show the space (somebody had pressed enter instead of delete/backspace to clear the entry) it stopped the problem - just a bit of learning on the job which we all go through for the GRC chaps in KL.
A " " would be valid but a (I know you can't see it but it's there wouldn't be )
edited.When you did an edit/replace did it say it had replaced anything please?edited
The word doc option does sound good!
Cheers
David
Edited by: David Berry on Nov 4, 2010 7:33 PM
Maybe you are looking for
-
I need a 1TB SATA HD for my 2008 mac pro - recommendations?
I am running out of space on my mac pro and want to add in 1TB. There were apple 1TB HDs in the mac store that were compatable with my 2008 mac pro not so long ago, but in my lackluster approach I have returned to buy one and they are no longher lis
-
Note: I did try to install the plugin just to see what would happen. When I clicked on "Install Missing Plugin" the next page said plugin could not be found---install manually. I clicked on manual install button and was directed to Adobe Flash Player
-
How to create a playlist with podcasts AND music?
I created a playlist with both podcasts and music in it. The thing is when I try to shuffle it, only music plays. When I start playing podcasts, none of my music plays. How can I make them both play at the same time and shuffle on the same playlist?
-
Premier pro cs6 but not reconizing my aja kona Lhi capture card
tried different driver and plugins but still can't capture with card
-
Constant 'Media Error' message
I'm now having problems with burning single layer DVD's, which has not been a problem before. The discs I'm using are RiDisc+R's which have worked fine in the past. I have had problems with DL discs before, but SL discs never had a problem. Any ideas