Sorry posted this in wrong place...
maybe im missing something here. in s+ <person job="Actor" name="Brandon Lee" /> <person job="Actor" name="Rochelle Davis" /> <person job="Actor" name="Jon Thompson" />
im doing this:
IF(FIND("person job=\x22Actor\x22 name=\x22",sTemp)) {
sDump = remove("person job=\x22Actor\x22 name=\x22", sTemp);
Actor1$=left(sTemp, find("/>", sTemp)-3);
}
My output is always Jon Thompson. How can i get it to pull out 1 at a time and assign to Actor1$ Actor2$ etc.
Thanks
|
You're overwriting Actor1$ each time you parse a name. You need an integer variable to track how many names you've already parsed and use that as the index of the string output array you want to assign it to. -Neil Dorin On 2012-09-16, at 6:09 PM, "Chris" <chrmac68@...> wrote: Sorry posted this in wrong place...
maybe im missing something here. in s+ <person job="Actor" name="Brandon Lee" /> <person job="Actor" name="Rochelle Davis" /> <person job="Actor" name="Jon Thompson" />
im doing this:
IF(FIND("person job=\x22Actor\x22 name=\x22",sTemp)) {
sDump = remove("person job=\x22Actor\x22 name=\x22", sTemp);
Actor1$=left(sTemp, find("/>", sTemp)-3);
}
My output is always Jon Thompson. How can i get it to pull out 1 at a time and assign to Actor1$ Actor2$ etc.
Thanks
[Non-text portions of this message have been removed]
|
Can you possibly give me an example of how to do this. I have tried so many ways all without success.
Thanks
toggle quoted message
Show quoted text
--- In Crestron@..., Neil Dorin <neildorin@...> wrote: You're overwriting Actor1$ each time you parse a name. You need an integer variable to track how many names you've already parsed and use that as the index of the string output array you want to assign it to.
-Neil Dorin
Sent from my iPhone
On 2012-09-16, at 6:09 PM, "Chris" <chrmac68@...> wrote:
Sorry posted this in wrong place...
maybe im missing something here. in s+ <person job="Actor" name="Brandon Lee" /> <person job="Actor" name="Rochelle Davis" /> <person job="Actor" name="Jon Thompson" />
im doing this:
IF(FIND("person job=\x22Actor\x22 name=\x22",sTemp)) {
sDump = remove("person job=\x22Actor\x22 name=\x22", sTemp);
Actor1$=left(sTemp, find("/>", sTemp)-3);
}
My output is always Jon Thompson. How can i get it to pull out 1 at a time and assign to Actor1$ Actor2$ etc.
Thanks
[Non-text portions of this message have been removed]
|
Here: //Based on the sample data you've given I'm making the assumption that you'll get all the names you're after in a single query. This code will parse up to 10 names and those names would be overwritten with the next query. #DEFINE_CONSTANT maxnames 10 #DEFINE_CONSTANT maxlength 40 Digital_Input Get_Names; Buffer_Input RxData$[1000]; String_Output Actor$[maxnames][maxlength]; //Define an output array of 10 outputs, each up to 40 bytes in length Integer i; //Define a global integer as the index Push Get_Names { i = 1; //reset index to 1 when new request for name is sent. } Change RxData$ { Integer semaphore; //Define a semaphore to prevent re-entrancy String sTemp[100], sDump[50]; While(semaphore = 0) { Semaphore = 1; sTemp = Gather("/>", RxData$); //this will remove each line from the buffer to be parsed individually IF(FIND("person job=\x22Actor\x22 name=\x22",sTemp)) { IF(i >= 1 && < maxnames){i = i + 1}; //increment index value if between 2 and 9 //parse as usual: sDump = remove("person job=\x22Actor\x22 name=\x22", sTemp); Actor1[i]=left(sTemp, find("/>", sTemp)-3); //assign the parsed string to the output specified by the index [i] Semaphore = 0; } } } You'll have to pardon any syntax errors as my iPad email app is not the best S+ text editor environment. Hope that makes sense for you. This could also be done using a for loop but I thought you might understand this method more easily. You could also parse the name with a single mid statement and have no need to define sDump and save some memory but thats really irrelevant. Ex. Actor$[i] = mid(sTemp, find("name=",sTemp) + 7,Len(sTemp) - ((find("/>", sTemp)-3) - (find("name=",sTemp))); //I'm almost sure to have missed a parenthesis but you get the idea. -Neil Dorin On Sep 16, 2012, at 10:16 PM, "chrmac68" <chrmac68@...> wrote: Can you possibly give me an example of how to do this. I have tried so many ways all without success.
Thanks
--- In Crestron@..., Neil Dorin <neildorin@...> wrote:
You're overwriting Actor1$ each time you parse a name. You need an integer variable to track how many names you've already parsed and use that as the index of the string output array you want to assign it to.
-Neil Dorin
Sent from my iPhone
On 2012-09-16, at 6:09 PM, "Chris" <chrmac68@...> wrote:
Sorry posted this in wrong place...
maybe im missing something here. in s+ <person job="Actor" name="Brandon Lee" /> <person job="Actor" name="Rochelle Davis" /> <person job="Actor" name="Jon Thompson" />
im doing this:
IF(FIND("person job=\x22Actor\x22 name=\x22",sTemp)) {
sDump = remove("person job=\x22Actor\x22 name=\x22", sTemp);
Actor1$=left(sTemp, find("/>", sTemp)-3);
}
My output is always Jon Thompson. How can i get it to pull out 1 at a time and assign to Actor1$ Actor2$ etc.
Thanks
[Non-text portions of this message have been removed]
|
With all respect Neil, Don't use iPad to edit simpl+ code ;) The index counter must also be after the first occurance of "actor Name".
-Stig
#DEFINE_CONSTANT maxnames 10 #DEFINE_CONSTANT maxlength 40 #ENABLE_TRACE Digital_Input Get_Names; Buffer_Input RxData$[1000]; String_Output Actor$[maxnames];//[maxlength]; //Define an output array of 10 outputs, each up to 40 bytes in length
Integer i; //Define a global integer as the index Integer semaphore; //Define a semaphore to prevent re-entrancy String sTemp[100], sDump[50];
Push Get_Names { i = 1; //reset index to 1 when new request for name is sent. }
Change RxData$ { IF(semaphore = 0) { Semaphore = 1; while(len(RxData$)) {//assuming strings are like "<person job="Actor" name="Brandon Lee" />" sTemp = Gather("/>", RxData$); //this will remove each line from the buffer to be parsed individually IF(FIND("person job=\x22Actor\x22 name=\x22",sTemp)) { sDump = remove("person job=\x22Actor\x22 name=\x22", sTemp); IF(i>=1 && i <=maxnames && IsSignalDefined(Actor$[i]) ) // parse names if index <=10 and if signalout(i) is defined in simpl) { Actor$[i]=left(sTemp, find("/>", sTemp)-3); //assign the parsed string to the output specified by the index [i] IF(i >= 1 && i < maxnames) {i = i + 1;} //increment index value if between 2 and 9 } } Semaphore = 0; } } }
Function Main() { Semaphore = 0; }
toggle quoted message
Show quoted text
--- In Crestron@..., Neil Dorin <neildorin@...> wrote: Here: //Based on the sample data you've given I'm making the assumption that you'll get all the names you're after in a single query. This code will parse up to 10 names and those names would be overwritten with the next query.
#DEFINE_CONSTANT maxnames 10 #DEFINE_CONSTANT maxlength 40
Digital_Input Get_Names; Buffer_Input RxData$[1000]; String_Output Actor$[maxnames][maxlength]; //Define an output array of 10 outputs, each up to 40 bytes in length
Integer i; //Define a global integer as the index
Push Get_Names { i = 1; //reset index to 1 when new request for name is sent. }
Change RxData$ { Integer semaphore; //Define a semaphore to prevent re-entrancy String sTemp[100], sDump[50];
While(semaphore = 0) { Semaphore = 1;
sTemp = Gather("/>", RxData$); //this will remove each line from the buffer to be parsed individually
IF(FIND("person job=\x22Actor\x22 name=\x22",sTemp)) {
IF(i >= 1 && < maxnames){i = i + 1}; //increment index value if between 2 and 9
//parse as usual:
sDump = remove("person job=\x22Actor\x22 name=\x22", sTemp);
Actor1[i]=left(sTemp, find("/>", sTemp)-3); //assign the parsed string to the output specified by the index [i]
Semaphore = 0;
} } }
You'll have to pardon any syntax errors as my iPad email app is not the best S+ text editor environment.
Hope that makes sense for you. This could also be done using a for loop but I thought you might understand this method more easily. You could also parse the name with a single mid statement and have no need to define sDump and save some memory but thats really irrelevant.
Ex. Actor$[i] = mid(sTemp, find("name=",sTemp) + 7,Len(sTemp) - ((find("/>", sTemp)-3) - (find("name=",sTemp))); //I'm almost sure to have missed a parenthesis but you get the idea.
-Neil Dorin
Sent from my iPad
On Sep 16, 2012, at 10:16 PM, "chrmac68" <chrmac68@...> wrote:
Can you possibly give me an example of how to do this. I have tried so many ways all without success.
Thanks
--- In Crestron@..., Neil Dorin <neildorin@> wrote:
You're overwriting Actor1$ each time you parse a name. You need an integer variable to track how many names you've already parsed and use that as the index of the string output array you want to assign it to.
-Neil Dorin
Sent from my iPhone
On 2012-09-16, at 6:09 PM, "Chris" <chrmac68@> wrote:
Sorry posted this in wrong place...
maybe im missing something here. in s+ <person job="Actor" name="Brandon Lee" /> <person job="Actor" name="Rochelle Davis" /> <person job="Actor" name="Jon Thompson" />
im doing this:
IF(FIND("person job=\x22Actor\x22 name=\x22",sTemp)) {
sDump = remove("person job=\x22Actor\x22 name=\x22", sTemp);
Actor1$=left(sTemp, find("/>", sTemp)-3);
}
My output is always Jon Thompson. How can i get it to pull out 1 at a time and assign to Actor1$ Actor2$ etc.
Thanks
[Non-text portions of this message have been removed]
[Non-text portions of this message have been removed]
|
Thanks,
Ill give this a try and see if it does what im hoping.
toggle quoted message
Show quoted text
--- In Crestron@..., "Stig" <ska@...> wrote: With all respect Neil, Don't use iPad to edit simpl+ code ;) The index counter must also be after the first occurance of "actor Name".
-Stig
#DEFINE_CONSTANT maxnames 10 #DEFINE_CONSTANT maxlength 40 #ENABLE_TRACE Digital_Input Get_Names; Buffer_Input RxData$[1000]; String_Output Actor$[maxnames];//[maxlength]; //Define an output array of 10 outputs, each up to 40 bytes in length
Integer i; //Define a global integer as the index Integer semaphore; //Define a semaphore to prevent re-entrancy String sTemp[100], sDump[50];
Push Get_Names { i = 1; //reset index to 1 when new request for name is sent. }
Change RxData$ { IF(semaphore = 0) { Semaphore = 1; while(len(RxData$)) {//assuming strings are like "<person job="Actor" name="Brandon Lee" />" sTemp = Gather("/>", RxData$); //this will remove each line from the buffer to be parsed individually IF(FIND("person job=\x22Actor\x22 name=\x22",sTemp)) { sDump = remove("person job=\x22Actor\x22 name=\x22", sTemp); IF(i>=1 && i <=maxnames && IsSignalDefined(Actor$[i]) ) // parse names if index <=10 and if signalout(i) is defined in simpl) { Actor$[i]=left(sTemp, find("/>", sTemp)-3); //assign the parsed string to the output specified by the index [i] IF(i >= 1 && i < maxnames) {i = i + 1;} //increment index value if between 2 and 9 } } Semaphore = 0; } } }
Function Main() { Semaphore = 0; }
--- In Crestron@..., Neil Dorin <neildorin@> wrote:
Here: //Based on the sample data you've given I'm making the assumption that you'll get all the names you're after in a single query. This code will parse up to 10 names and those names would be overwritten with the next query.
#DEFINE_CONSTANT maxnames 10 #DEFINE_CONSTANT maxlength 40
Digital_Input Get_Names; Buffer_Input RxData$[1000]; String_Output Actor$[maxnames][maxlength]; //Define an output array of 10 outputs, each up to 40 bytes in length
Integer i; //Define a global integer as the index
Push Get_Names { i = 1; //reset index to 1 when new request for name is sent. }
Change RxData$ { Integer semaphore; //Define a semaphore to prevent re-entrancy String sTemp[100], sDump[50];
While(semaphore = 0) { Semaphore = 1;
sTemp = Gather("/>", RxData$); //this will remove each line from the buffer to be parsed individually
IF(FIND("person job=\x22Actor\x22 name=\x22",sTemp)) {
IF(i >= 1 && < maxnames){i = i + 1}; //increment index value if between 2 and 9
//parse as usual:
sDump = remove("person job=\x22Actor\x22 name=\x22", sTemp);
Actor1[i]=left(sTemp, find("/>", sTemp)-3); //assign the parsed string to the output specified by the index [i]
Semaphore = 0;
} } }
You'll have to pardon any syntax errors as my iPad email app is not the best S+ text editor environment.
Hope that makes sense for you. This could also be done using a for loop but I thought you might understand this method more easily. You could also parse the name with a single mid statement and have no need to define sDump and save some memory but thats really irrelevant.
Ex. Actor$[i] = mid(sTemp, find("name=",sTemp) + 7,Len(sTemp) - ((find("/>", sTemp)-3) - (find("name=",sTemp))); //I'm almost sure to have missed a parenthesis but you get the idea.
-Neil Dorin
Sent from my iPad
On Sep 16, 2012, at 10:16 PM, "chrmac68" <chrmac68@> wrote:
Can you possibly give me an example of how to do this. I have tried so many ways all without success.
Thanks
--- In Crestron@..., Neil Dorin <neildorin@> wrote:
You're overwriting Actor1$ each time you parse a name. You need an integer variable to track how many names you've already parsed and use that as the index of the string output array you want to assign it to.
-Neil Dorin
Sent from my iPhone
On 2012-09-16, at 6:09 PM, "Chris" <chrmac68@> wrote:
Sorry posted this in wrong place...
maybe im missing something here. in s+ <person job="Actor" name="Brandon Lee" /> <person job="Actor" name="Rochelle Davis" /> <person job="Actor" name="Jon Thompson" />
im doing this:
IF(FIND("person job=\x22Actor\x22 name=\x22",sTemp)) {
sDump = remove("person job=\x22Actor\x22 name=\x22", sTemp);
Actor1$=left(sTemp, find("/>", sTemp)-3);
}
My output is always Jon Thompson. How can i get it to pull out 1 at a time and assign to Actor1$ Actor2$ etc.
Thanks
[Non-text portions of this message have been removed]
|
Haha, Thanks for the correction Stig. Poorly.formatted.code.example = iPad.Splus.edits + not.enough.sleep + hangover.from.wedding; //Equation to defend programmer's ego -Neil On Mon, Sep 17, 2012 at 5:02 AM, Stig <ska@...> wrote: **
With all respect Neil, Don't use iPad to edit simpl+ code ;) The index counter must also be after the first occurance of "actor Name".
-Stig
#DEFINE_CONSTANT maxnames 10 #DEFINE_CONSTANT maxlength 40 #ENABLE_TRACE
Digital_Input Get_Names; Buffer_Input RxData$[1000]; String_Output Actor$[maxnames];//[maxlength]; //Define an output array of 10 outputs, each up to 40 bytes in length
Integer i; //Define a global integer as the index Integer semaphore; //Define a semaphore to prevent re-entrancy String sTemp[100], sDump[50];
Push Get_Names { i = 1; //reset index to 1 when new request for name is sent. }
Change RxData$ { IF(semaphore = 0) { Semaphore = 1; while(len(RxData$)) {//assuming strings are like "<person job="Actor" name="Brandon Lee" />"
sTemp = Gather("/>", RxData$); //this will remove each line from the buffer to be parsed individually IF(FIND("person job=\x22Actor\x22 name=\x22",sTemp)) { sDump = remove("person job=\x22Actor\x22 name=\x22", sTemp); IF(i>=1 && i <=maxnames && IsSignalDefined(Actor$[i]) ) // parse names if index <=10 and if signalout(i) is defined in simpl) { Actor$[i]=left(sTemp, find("/>", sTemp)-3); //assign the parsed string to the output specified by the index [i] IF(i >= 1 && i < maxnames) {i = i + 1;} //increment index value if between 2 and 9 } } Semaphore = 0; } } }
Function Main() { Semaphore = 0;
}
--- In Crestron@..., Neil Dorin <neildorin@...> wrote:
Here: //Based on the sample data you've given I'm making the assumption that you'll get all the names you're after in a single query. This code will parse up to 10 names and those names would be overwritten with the next query.
#DEFINE_CONSTANT maxnames 10 #DEFINE_CONSTANT maxlength 40
Digital_Input Get_Names; Buffer_Input RxData$[1000]; String_Output Actor$[maxnames][maxlength]; //Define an output array of 10 outputs, each up to 40 bytes in length
Integer i; //Define a global integer as the index
Push Get_Names { i = 1; //reset index to 1 when new request for name is sent. }
Change RxData$ { Integer semaphore; //Define a semaphore to prevent re-entrancy String sTemp[100], sDump[50];
While(semaphore = 0) { Semaphore = 1;
sTemp = Gather("/>", RxData$); //this will remove each line from the buffer to be parsed individually
IF(FIND("person job=\x22Actor\x22 name=\x22",sTemp)) {
IF(i >= 1 && < maxnames){i = i + 1}; //increment index value if between 2 and 9
//parse as usual:
sDump = remove("person job=\x22Actor\x22 name=\x22", sTemp);
Actor1[i]=left(sTemp, find("/>", sTemp)-3); //assign the parsed string to the output specified by the index [i]
Semaphore = 0;
} } }
You'll have to pardon any syntax errors as my iPad email app is not the best S+ text editor environment.
Hope that makes sense for you. This could also be done using a for loop but I thought you might understand this method more easily. You could also parse the name with a single mid statement and have no need to define sDump and save some memory but thats really irrelevant.
Ex. Actor$[i] = mid(sTemp, find("name=",sTemp) + 7,Len(sTemp) - ((find("/>", sTemp)-3) - (find("name=",sTemp))); //I'm almost sure to have missed a parenthesis but you get the idea.
-Neil Dorin
Sent from my iPad
On Sep 16, 2012, at 10:16 PM, "chrmac68" <chrmac68@...> wrote:
Can you possibly give me an example of how to do this. I have tried so many ways all without success.
Thanks
--- In Crestron@..., Neil Dorin <neildorin@> wrote:
You're overwriting Actor1$ each time you parse a name. You need an
integer variable to track how many names you've already parsed and use that as the index of the string output array you want to assign it to.
-Neil Dorin
Sent from my iPhone
On 2012-09-16, at 6:09 PM, "Chris" <chrmac68@> wrote:
Sorry posted this in wrong place...
maybe im missing something here. in s+ <person job="Actor" name="Brandon Lee" /> <person job="Actor" name="Rochelle Davis" /> <person job="Actor" name="Jon Thompson" />
im doing this:
IF(FIND("person job=\x22Actor\x22 name=\x22",sTemp)) {
sDump = remove("person job=\x22Actor\x22 name=\x22", sTemp);
Actor1$=left(sTemp, find("/>", sTemp)-3);
}
My output is always Jon Thompson. How can i get it to pull out 1
at a time and
assign to Actor1$ Actor2$ etc.
Thanks
[Non-text portions of this message have been removed]
[Non-text portions of this message have been removed]
[Non-text portions of this message have been removed]
|
Just say it was beta code. ;) You can get away with anything then.
toggle quoted message
Show quoted text
On Mon, Sep 17, 2012 at 8:23 AM, Neil Dorin <neildorin@...> wrote: Haha,
Thanks for the correction Stig.
Poorly.formatted.code.example = iPad.Splus.edits + not.enough.sleep + hangover.from.wedding; //Equation to defend programmer's ego
-Neil
On Mon, Sep 17, 2012 at 5:02 AM, Stig <ska@...> wrote:
**
With all respect Neil, Don't use iPad to edit simpl+ code ;) The index counter must also be after the first occurance of "actor Name".
-Stig
#DEFINE_CONSTANT maxnames 10 #DEFINE_CONSTANT maxlength 40 #ENABLE_TRACE
Digital_Input Get_Names; Buffer_Input RxData$[1000]; String_Output Actor$[maxnames];//[maxlength]; //Define an output array of 10 outputs, each up to 40 bytes in length
Integer i; //Define a global integer as the index Integer semaphore; //Define a semaphore to prevent re-entrancy String sTemp[100], sDump[50];
Push Get_Names { i = 1; //reset index to 1 when new request for name is sent. }
Change RxData$ { IF(semaphore = 0) { Semaphore = 1; while(len(RxData$)) {//assuming strings are like "<person job="Actor" name="Brandon Lee" />"
sTemp = Gather("/>", RxData$); //this will remove each line from the buffer to be parsed individually IF(FIND("person job=\x22Actor\x22 name=\x22",sTemp)) { sDump = remove("person job=\x22Actor\x22 name=\x22", sTemp); IF(i>=1 && i <=maxnames && IsSignalDefined(Actor$[i]) ) // parse names if index <=10 and if signalout(i) is defined in simpl) { Actor$[i]=left(sTemp, find("/>", sTemp)-3); //assign the parsed string to the output specified by the index [i] IF(i >= 1 && i < maxnames) {i = i + 1;} //increment index value if between
2 and 9 } } Semaphore = 0; } } }
Function Main() { Semaphore = 0;
}
--- In Crestron@..., Neil Dorin <neildorin@...> wrote:
Here: //Based on the sample data you've given I'm making the assumption that you'll get all the names you're after in a single query. This code will parse up to 10 names and those names would be overwritten with the next query.
#DEFINE_CONSTANT maxnames 10 #DEFINE_CONSTANT maxlength 40
Digital_Input Get_Names; Buffer_Input RxData$[1000]; String_Output Actor$[maxnames][maxlength]; //Define an output array of 10 outputs, each up to 40 bytes in length
Integer i; //Define a global integer as the index
Push Get_Names { i = 1; //reset index to 1 when new request for name is sent. }
Change RxData$ { Integer semaphore; //Define a semaphore to prevent re-entrancy String sTemp[100], sDump[50];
While(semaphore = 0) { Semaphore = 1;
sTemp = Gather("/>", RxData$); //this will remove each line from the buffer to be parsed individually
IF(FIND("person job=\x22Actor\x22 name=\x22",sTemp)) {
IF(i >= 1 && < maxnames){i = i + 1}; //increment index value if between 2 and 9
//parse as usual:
sDump = remove("person job=\x22Actor\x22 name=\x22", sTemp);
Actor1[i]=left(sTemp, find("/>", sTemp)-3); //assign the parsed string to the output specified by the index [i]
Semaphore = 0;
} } }
You'll have to pardon any syntax errors as my iPad email app is not the best S+ text editor environment.
Hope that makes sense for you. This could also be done using a for loop but I thought you might understand this method more easily. You could also
parse the name with a single mid statement and have no need to define sDump
and save some memory but thats really irrelevant.
Ex. Actor$[i] = mid(sTemp, find("name=",sTemp) + 7,Len(sTemp) - ((find("/>", sTemp)-3) - (find("name=",sTemp))); //I'm almost sure to have
missed a parenthesis but you get the idea.
-Neil Dorin
Sent from my iPad
On Sep 16, 2012, at 10:16 PM, "chrmac68" <chrmac68@...> wrote:
Can you possibly give me an example of how to do this. I have tried so many ways all without success.
Thanks
--- In Crestron@..., Neil Dorin <neildorin@> wrote:
You're overwriting Actor1$ each time you parse a name. You need an
integer variable to track how many names you've already parsed and use that
as the index of the string output array you want to assign it to.
-Neil Dorin
Sent from my iPhone
On 2012-09-16, at 6:09 PM, "Chris" <chrmac68@> wrote:
Sorry posted this in wrong place...
maybe im missing something here. in s+ <person job="Actor" name="Brandon Lee" /> <person job="Actor" name="Rochelle Davis" /> <person job="Actor" name="Jon Thompson" />
im doing this:
IF(FIND("person job=\x22Actor\x22 name=\x22",sTemp)) {
sDump = remove("person job=\x22Actor\x22 name=\x22", sTemp);
Actor1$=left(sTemp, find("/>", sTemp)-3);
}
My output is always Jon Thompson. How can i get it to pull out 1
at a time and
assign to Actor1$ Actor2$ etc.
Thanks
------------------------------------
Check out the Files area for useful modules, documents, and drivers.
A contact list of Crestron dealers and programmers can be found in the Database area. Yahoo! Groups Links
|
Been there :)
toggle quoted message
Show quoted text
--- In Crestron@..., Neil Dorin <neildorin@...> wrote: Haha,
Thanks for the correction Stig.
Poorly.formatted.code.example = iPad.Splus.edits + not.enough.sleep + hangover.from.wedding; //Equation to defend programmer's ego
-Neil
On Mon, Sep 17, 2012 at 5:02 AM, Stig <ska@...> wrote:
**
With all respect Neil, Don't use iPad to edit simpl+ code ;) The index counter must also be after the first occurance of "actor Name".
-Stig
#DEFINE_CONSTANT maxnames 10 #DEFINE_CONSTANT maxlength 40 #ENABLE_TRACE
Digital_Input Get_Names; Buffer_Input RxData$[1000]; String_Output Actor$[maxnames];//[maxlength]; //Define an output array of 10 outputs, each up to 40 bytes in length
Integer i; //Define a global integer as the index Integer semaphore; //Define a semaphore to prevent re-entrancy String sTemp[100], sDump[50];
Push Get_Names { i = 1; //reset index to 1 when new request for name is sent. }
Change RxData$ { IF(semaphore = 0) { Semaphore = 1; while(len(RxData$)) {//assuming strings are like "<person job="Actor" name="Brandon Lee" />"
sTemp = Gather("/>", RxData$); //this will remove each line from the buffer to be parsed individually IF(FIND("person job=\x22Actor\x22 name=\x22",sTemp)) { sDump = remove("person job=\x22Actor\x22 name=\x22", sTemp); IF(i>=1 && i <=maxnames && IsSignalDefined(Actor$[i]) ) // parse names if index <=10 and if signalout(i) is defined in simpl) { Actor$[i]=left(sTemp, find("/>", sTemp)-3); //assign the parsed string to the output specified by the index [i] IF(i >= 1 && i < maxnames) {i = i + 1;} //increment index value if between 2 and 9 } } Semaphore = 0; } } }
Function Main() { Semaphore = 0;
}
--- In Crestron@..., Neil Dorin <neildorin@> wrote:
Here: //Based on the sample data you've given I'm making the assumption that you'll get all the names you're after in a single query. This code will parse up to 10 names and those names would be overwritten with the next query.
#DEFINE_CONSTANT maxnames 10 #DEFINE_CONSTANT maxlength 40
Digital_Input Get_Names; Buffer_Input RxData$[1000]; String_Output Actor$[maxnames][maxlength]; //Define an output array of 10 outputs, each up to 40 bytes in length
Integer i; //Define a global integer as the index
Push Get_Names { i = 1; //reset index to 1 when new request for name is sent. }
Change RxData$ { Integer semaphore; //Define a semaphore to prevent re-entrancy String sTemp[100], sDump[50];
While(semaphore = 0) { Semaphore = 1;
sTemp = Gather("/>", RxData$); //this will remove each line from the buffer to be parsed individually
IF(FIND("person job=\x22Actor\x22 name=\x22",sTemp)) {
IF(i >= 1 && < maxnames){i = i + 1}; //increment index value if between 2 and 9
//parse as usual:
sDump = remove("person job=\x22Actor\x22 name=\x22", sTemp);
Actor1[i]=left(sTemp, find("/>", sTemp)-3); //assign the parsed string to the output specified by the index [i]
Semaphore = 0;
} } }
You'll have to pardon any syntax errors as my iPad email app is not the best S+ text editor environment.
Hope that makes sense for you. This could also be done using a for loop but I thought you might understand this method more easily. You could also parse the name with a single mid statement and have no need to define sDump and save some memory but thats really irrelevant.
Ex. Actor$[i] = mid(sTemp, find("name=",sTemp) + 7,Len(sTemp) - ((find("/>", sTemp)-3) - (find("name=",sTemp))); //I'm almost sure to have missed a parenthesis but you get the idea.
-Neil Dorin
Sent from my iPad
On Sep 16, 2012, at 10:16 PM, "chrmac68" <chrmac68@> wrote:
Can you possibly give me an example of how to do this. I have tried so many ways all without success.
Thanks
--- In Crestron@..., Neil Dorin <neildorin@> wrote:
You're overwriting Actor1$ each time you parse a name. You need an
integer variable to track how many names you've already parsed and use that as the index of the string output array you want to assign it to.
-Neil Dorin
Sent from my iPhone
On 2012-09-16, at 6:09 PM, "Chris" <chrmac68@> wrote:
Sorry posted this in wrong place...
maybe im missing something here. in s+ <person job="Actor" name="Brandon Lee" /> <person job="Actor" name="Rochelle Davis" /> <person job="Actor" name="Jon Thompson" />
im doing this:
IF(FIND("person job=\x22Actor\x22 name=\x22",sTemp)) {
sDump = remove("person job=\x22Actor\x22 name=\x22", sTemp);
Actor1$=left(sTemp, find("/>", sTemp)-3);
}
My output is always Jon Thompson. How can i get it to pull out 1
at a time and
assign to Actor1$ Actor2$ etc.
Thanks
[Non-text portions of this message have been removed]
[Non-text portions of this message have been removed]
|