Post new topic Reply to topic  [ 28 posts ] 

Board index : TeleFlow Forums : General

Go to page Previous  1, 2
Author Message
 Post subject: Re: Best Practices
PostPosted: Mon May 05, 2008 10:08 am 
Offline
Site Admin

Joined: Wed Dec 31, 1969 5:00 pm
Posts: 329
Location: Vancouver, BC
Without seeing the DLL source, I cannot guess what the problem might be. However, troubleshooting DLL issues is actually out of the scope of this forum. We can offer the support of one of our engineers to debug your code with/for you. Please contact sales@engenic.com if you are interested.

I do think it would be a good enhancement to our BasicScript step to have an ASC() function to return the ASCII value of character. I will add that suggestion to our engineering queue. Unfortunately, I cannot give you a time frame when this change will be available in a general release.


Back to top
 Profile WWW 
 
 Post subject: Re: Best Practices
PostPosted: Tue May 06, 2008 12:41 pm 
Offline
Site Admin

Joined: Wed Dec 31, 1969 5:00 pm
Posts: 329
Location: Vancouver, BC
CrazyBucky:

I have some bad news/good news for you. When I added this suggestion to the Engineering queue, I was informed that TeleFlow already has this functionality. As it turns out, it never got documented :shock:. Therefore, it is the help deficiencies that have been added to queue.

Which means, I can tell you how to achieve what you want to do with the Run BasicScript step. Considering the goose-chase you've been on, I'm going to go into more detail than I usually would. Here's what you need to know.

Firstly, there is an ASC() function. Here's an example of how it works:
Code:
@ASCIIVALUE = ASC(@MYCHAR)

It returns the ASCII value of the first character in a TeleFlow variable (@MYCHAR in the example) into the result variable (@ASCIIVALUE).

Secondly, the BXOR (binary exclusive or) entry in the TeleFlow Help is incorrect. It represents BXOR as a function, but it is, in fact, an operator. To calculate the BXOR of two values, you need to compose your statement like so:
Code:
@RESULT = @VALUE1 BXOR @VALUE2

The two values must be numeric. Non-numeric values are treated as zero.

Lastly, you'll need to get a single character at a time out of your string. You can use the SUBSTR() function for this. It is documented in the help, but I will give you a quick overview:
Code:
@MYCHAR = SUBSTR(@MYSTRING, @POSITION, 1)

Where @MYSTRING is the full string, @POSITION is the character position you want to get, and 1 is to get a single character.

Putting it all together, the following example should work for your XOR checksum script:
Code:
@TOTAL_STRING = "ABCDEFG"
@LENGTH = LEN(@MYSTRING)
@POS = 1
@SINGLE_CHAR = ""
@ASCII_VALUE = 0
@XRESULT = 0
           
FOR @POS = 1 TO @LENGTH
         
    @SINGLE_CHAR = SUBSTR(@TOTAL_STRING, @POS, 1)
    @ASCII_VALUE = ASC(@MYCHAR)
    @XRESULT = @XRESULT BXOR @ASC_VALUE
             
NEXT

You'll have to change it to suit your application, of course.

Important Note: The above code will only work on TeleFlow version 2007.1123 and later.


Back to top
 Profile WWW 
 
 Post subject: Re: Best Practices
PostPosted: Tue May 06, 2008 4:24 pm 
Offline

Joined: Thu Jan 31, 2008 8:54 pm
Posts: 19
I gave your code a shot but when a letter goes through the ASC() function it actually gets the decimal equivalent rather than the Hex I need. Is there any way we you could put a request for a HEX() function?


This is what I get now...
: Setting global variable '@SINGLE_CHAR' to 'J'
: @ASCII_VALUE = 'ASC(@SINGLE_CHAR)'
: Setting global variable '@ASCII_VALUE' to '74'

This is what I need...
: Setting global variable '@SINGLE_CHAR' to 'J'
: @HEX_VALUE = 'HEX(@SINGLE_CHAR)'
: Setting global variable '@ASCII_VALUE' to '4A'


This chart might help explain what i'm trying to do better...
http://www.asciitable.com/



BTW THANK YOU so much for all your help!!!


Last edited by crazybucky on Tue May 06, 2008 5:05 pm, edited 1 time in total.

Back to top
 Profile  
 
 Post subject: Re: Best Practices
PostPosted: Tue May 06, 2008 4:45 pm 
Offline

Joined: Thu Jan 31, 2008 8:54 pm
Posts: 19
Also I have tested your code with a few changes and it works great except it needs the Hex rather then the Decimal.

Code:
@TOTAL_STRING = "AS105"
@LENGTH = LEN(@TOTAL_STRING)
@POSi = 1
@SINGLE_CHAR = ""
@ASCII_VALUE = 0
@XRESULT = SUBSTR(@TOTAL_STRING, @POSi, 1)
@XRESULT =  ASC(@XRESULT)
         
FOR @POSi = 2 TO @LENGTH
         
    @SINGLE_CHAR = SUBSTR(@TOTAL_STRING, @POSi, 1)
    @ASCII_VALUE = ASC(@SINGLE_CHAR)
    @XRESULT = @XRESULT BXOR @ASCII_VALUE
             
NEXT


When run, I get...
: Setting global variable '@XRESULT' to '38'

"38" being the Decimal value of the Charater of "&" which I need it's hex of "26".

I wonder If I can somehow just just convert the 38 to a base 16 somehow.


Back to top
 Profile  
 
 Post subject: Re: Best Practices
PostPosted: Tue May 06, 2008 5:30 pm 
Offline
Site Admin

Joined: Wed Dec 31, 1969 5:00 pm
Posts: 329
Location: Vancouver, BC
This another un-documented function that will aid you, here: CHAR2HEX().
You will want all of your BXOR calculations to use decimal, because TeleFlow isn't cognisant of Hex as numbers. It will think that '41' is decimal 41, and 'A' is 0 (zero). So... run your script as you have it, but add this to the end:
Code:
@RESULT_CHAR = CHAR(@XRESULT)
@HEX_VALUE = CHAR2HEX(@RESULT_CHAR)

You could probably combine these functions into one line:
Code:
@HEX_VALUE = CHAR2HEX(CHAR(@XRESULT))

The important thing is to convert the decimal back into a single character, then you can use the CHAR2HEX() function to get the final result in hexidecimal.


Back to top
 Profile WWW 
 
 Post subject: Re: Best Practices
PostPosted: Tue May 06, 2008 6:21 pm 
Offline

Joined: Thu Jan 31, 2008 8:54 pm
Posts: 19
Adding this above this to the above code WORKS!..

Code:
@XRESULT = CHAR(@XRESULT)
@XRESULT = CHAR2HEX(@XRESULT)



Man, If I just waited A couple minutes I wouldn't have need to write this..

Code:
@XRESULT = @XRESULT * 100
@XRESULT = @XRESULT / 16

@ZRESULT = RIGHT(@XRESULT,2)


IF LEN(@XRESULT) = 3 THEN
@YRESULT  = SUBSTR(@XRESULT, 1, 1)
Else
@YRESULT = 0
END


IF  @ZRESULT = 93 Then
@ZRESULT = "F"
Elseif @ZRESULT = 87 Then
@ZRESULT = "E"
Elseif @ZRESULT = 81 Then
@ZRESULT = "D"
Elseif @ZRESULT = 75 Then
@ZRESULT = "C"
Elseif @ZRESULT = 68 Then
@ZRESULT = "B"
Elseif @ZRESULT = 62 Then
@ZRESULT = "A"
Elseif @ZRESULT = 56 Then
@ZRESULT = "9"
Elseif @ZRESULT = 50 Then
@ZRESULT = "8"
Elseif @ZRESULT = 43 Then
@ZRESULT = "7"
Elseif @ZRESULT = 37 Then
@ZRESULT = "6"
Elseif @ZRESULT = 31 Then
@ZRESULT = "5"
Elseif @ZRESULT = 25 Then
@ZRESULT = "4"
Elseif @ZRESULT = 18 Then
@ZRESULT = "3"
Elseif @ZRESULT = 12 Then
@ZRESULT = "2"
Elseif @ZRESULT = 06 Then
@ZRESULT = "1"
Elseif @ZRESULT = 00 Then
@ZRESULT = "0"
END

@RESULTS =CONCAT(@YRESULT,@ZRESULT)





LOL


THANKS! I Think that will do it. I'll test out but I think thats solid! Can't thank you enough!


Back to top
 Profile  
 
 Post subject: Re: Best Practices
PostPosted: Tue May 06, 2008 6:29 pm 
Offline

Joined: Thu Jan 31, 2008 8:54 pm
Posts: 19
So that begs me to ask... Any other undocumented Tips or tricks that might help someone else in using Teleflow?


Back to top
 Profile  
 
 Post subject: Re: Best Practices
PostPosted: Tue May 13, 2008 10:20 am 
Offline
Site Admin

Joined: Wed Dec 31, 1969 5:00 pm
Posts: 329
Location: Vancouver, BC
Really, the answer to that requires a TeleFlow Help update, which follows the same procedure as engineering requests. Its in the queue.


Back to top
 Profile WWW 
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 28 posts ] 

Board index : TeleFlow Forums : General

Go to page Previous  1, 2

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Style by Midnight Phoenix & N.Design Studio
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.