Compare Values

MadhuG001

Member
Hi All,

I have a Time Value in collection stored as Text.(Time format is like 1234A for 12:34AM, 543P for 5:43PM).
I want it to check whether the values are between 1200A AND 300A (In our language between 12 AM to 3AM) or not?

Kindly advise how to proceed.
 

Sachin_Kharmale

Active Member
Hi Madhu,

for above problem follow bellow steps. you need to Design code stage in object studio and call action from process studio.
Step 1- Create new action (Check Time in Range ) in object studio (Note- Object programming language set to C#)
1.1-Create new action in Object Studio
View attachment 1593086079761.png

1.2-Action Input - TimeString Data Type - Text
View attachment 1593086110543.png

1.3-Action Output- InRange Data Type - Flag
View attachment 1593086151961.png

1.4-Code Stage Code
C#:
 bool inRange = false;
            
            char[] ch = TimeString.Trim().ToCharArray();
            if (ch[ch.Length-1] == 'A')
            {
                int TimeNumber =Convert.ToInt32(TimeString.Replace('A',' '));

                for (int i = 1200; i <= 1259; i++)
                {
                    if (TimeNumber == i)
                    {
                        inRange = true;
                    }
                }
                for (int i = 100; i <= 300; i++)
                {
                    if (TimeNumber == i)
                    {
                        inRange = true;
                    }
                }

            }

            Result=inRange;
View attachment 1593086227604.png
Step 2- Now you can call Newly created action from process Studio
2.1- Process Studio Page look likes
View attachment 1593086316600.png
2.2-Input Collection
View attachment 1593086344824.png

2.3-Output Result Collection to Store Result.
View attachment 1593086374423.png

2.4-Result after Processing all collection values
View attachment 1593086421631.png
I hope it will help you ...!!
 

MadhuG001

Member
Thank you so much Sachin. I will try this one.
Does it require to add any "External References" or "Namespace Import", under Initialize page of Object Studio ?
 

Sachin_Kharmale

Active Member
Hey Madhu,
Not required all classes belongs to System namespace you can directly copy and paste above code in code stage and gives input and output.


Only Set Language to C# that's it.

I hope it will work for you...!
 
Top