" /> Help me with string parsing and conversion in URS strategy - Genesys CTI User Forum

Author Topic: Help me with string parsing and conversion in URS strategy  (Read 8227 times)

Offline Timur Karimov

  • Sr. Member
  • ****
  • Posts: 415
  • Karma: 2
Help me with string parsing and conversion in URS strategy
« on: July 11, 2008, 11:43:52 AM »
Advertisement
Hi all!

1. Can anybody try next ops in URS strategy
Create 3 variable - str1, int1, flo1
Assign to str1 value '9.70'  (str1='9.70')
Assign to int1 value str1    (int1=str1)
Assign to flo1 value str1    (flo1=str1)
Print result (Print[str1], Print[int1], Print[flo1])

Post result here. I have next:
str1: 9.70
int1: 9
flo1:[color=red]9.6999999999999993[/color]      - what a hell?!

2. In IRD we have a cool function StrAsciiTok. "The purpose of this function is to parse out a string value from a string consisting of multiple substrings delimited by characters functioning as separators; the separators are the characters occurring in Char Set."Every time the function StrAsciiTok is called, it stores in memory the index in
String of the last character of the obtained substring. For instance, calling StrAsciiTok[’toy,;,pan’,’,;’,0] three consecutive times will return toy the first time, pan the second time, and ‘’ (the empty string) the third time."
Simple to parsing any complex string value, is't? OK,  but disagreeable moment - if u use it function 1-st time in the sub-strategy, the 2-nd call it sub-strategy don't clear this memory flag. As result -calling same sub-strategy for one interaction more than once,return us unexpected value =(
Example:
Strategy Main call sub-strategy con_str2_wav. In con_str2_wav we call result=StrAsciiTok[complete_path,'+',0]
there 'complete_path' is a string '100+20'. For instance, calling StrAsciiTok three consecutive times will return 100 the first time, 20 the second time, and ‘’ (the empty string) the third time. After it we return in the Main strategy. Do samething, create next string, and call sub-strategy con_str2_wav second time. In con_str2_wav we again call result=StrAsciiTok[complete_path,'+',0] there 'complete_path' now is a string '200+10'. But after first calling it's return ‘’ (the empty string)

Can anybody help me understand how i can use power of StrAsciiTok, but clear 'memory flag' after sub-strategy end?

Offline cavagnaro

  • Administrator
  • Hero Member
  • *****
  • Posts: 7641
  • Karma: 56330
Re: Help me with string parsing and conversion in URS strategy
« Reply #1 on: July 11, 2008, 03:05:14 PM »
Which version of URS are you using? I remember having issues with FLOATS on 7.2

Kevin

  • Guest
Re: Help me with string parsing and conversion in URS strategy
« Reply #2 on: July 12, 2008, 09:36:11 PM »
Based on my experience with other languages (such as C), floats are not always stored as exact values. They only appear as exact because they are corrected during the precision of the display. As long as your precision is greater than 10[sup]-15[/sup], you have, 9.70, or 9.700, or 9.7000, or 9.70000, etc.

I've seen this occur in C programs, but I've usually been able to correct using a rounding function, or through the formatting of the output. Unfortunately, such animals do not exist in URS.

If you're using it in a calculation, you should not see much deviation in the result from 9.7 unless you are multiplying it by a [b]BIG[/b] number, such as something greater than 10[sup]12[/sup] [1 000 000 000 000 (one trillion)] or 10[sup]15[/sup] [1 000 000 000 000 000 (one quadrilllion)].



Regarding the StrAsciiTok, I've encountered the same problem with two calls to it in the same strategy but on different strings. I was able to get around it by setting the location to 1 on the initial call and 0 on subsequent calls. Such as

set location = 1
[start loop]
result=StrAsciiTok[complete_path,'+',location]
[do something with result]
set location = 0
result=StrAsciiTok[complete_path,'+',location]
[end loop]

Offline Timur Karimov

  • Sr. Member
  • ****
  • Posts: 415
  • Karma: 2
Re: Help me with string parsing and conversion in URS strategy
« Reply #3 on: July 14, 2008, 06:33:02 AM »
[quote author=cavagnaro link=topic=3130.msg12786#msg12786 date=1215788714]
Which version of URS are you using? I remember having issues with FLOATS on 7.2
[/quote]

latest available, 7.6

Offline Timur Karimov

  • Sr. Member
  • ****
  • Posts: 415
  • Karma: 2
Re: Help me with string parsing and conversion in URS strategy
« Reply #4 on: July 15, 2008, 10:00:50 AM »
[quote author=Kevin link=topic=3130.msg12795#msg12795 date=1215898571]
Regarding the StrAsciiTok......
[/quote]

fanx,Kevin . it's helpfull for me

Offline Mikael Jansson

  • Newbie
  • *
  • Posts: 28
  • Karma: 2
Re: Help me with string parsing and conversion in URS strategy
« Reply #5 on: August 04, 2008, 10:50:06 AM »
Hi !
I borrow this thread for another annoying problem with StrAsciiTok.
If I change the "token" in a series of StrAsciiTok it seems like the function dosen't realize that.
If I do as below it dosen't work.
ex-data:
    vTargetSelected get value "12345@HQ_Switch.Q"
    vDNSelected gets value 12345
    vSwitchObjectSelected get value "HQ_Switch.Q"
       and I want vSwtichSelecterd to get valye HQ_Switch
       but it gets the same value as vSwitchObjectSelected.

[attach=#]

..
But if I change the "From Index" value from "0" to "1" as below it works in that step.

[attach=#]

Have anyone else seen this and understood why or is it a bug?

/ Micke
« Last Edit: August 04, 2008, 10:52:08 AM by Mikael Jansson »

Offline S

  • Full Member
  • ***
  • Posts: 135
  • Karma: 1
Re: Help me with string parsing and conversion in URS strategy
« Reply #6 on: February 10, 2009, 05:53:15 PM »
I had the same issue with this function - so gave up and started using strSub functions