CRC-16 Hash Calculation

PB 9.0.3

Has anyone written a CRC-16 Hash calculation in PowerScript?  I have the 
source code in C but my skills of converting C to PowerScript is a little 
lacking.  Short of just asking someone to do this for me (I will send you a 
six pack of you favorite beer/beverage if you do) - what is the best place 
to start to convert this?

Chris Craft 


begin 666 CRC-16 VoiceCode.c
M<'5B;&EC('-T871I8R!C;&%S<R!6;VEC94-O9&4-"GL-"B @('!U8FQI8R!S
M=&%T:6,@<W1R:6YG($-O;7!U=&4H<W1R:6YG($=424XL('-T<FEN9R!L;W0I
M#0H@("![#0H@(" @("!U<VAO<G0@8W)C(#T@0W)C,38N0V]M<'5T94-H96-K
M<W5M*$5N8V]D:6YG+D%30TE)+D=E=$)Y=&5S*'-T<FEN9RY&;W)M870H(GLP
M?7LQ?2(L($=424XL(&QO="DI*3L-"B @(" @(')E='5R;B!S=')I;F<N1F]R
M;6%T*")[,#HP,#!](BP@8W)C("4@,3 P,# I.PT*(" @?0T*?0T*<'5B;&EC
M('-T871I8R!C;&%S<R!#<F,Q-@T*>PT*(" @(W)E9VEO;B!S=&%T:6,@;65M
M8F5R<PT*(" @<')I=F%T92!C;VYS="!U<VAO<G0@<&]L>6YO;6EA;" ](#!X
M03 P,3L-"B @('!R:79A=&4@<W1A=&EC('5S:&]R="!;72!T86)L92 ](&YE
M=R!U<VAO<G1;,C4V73L-"B @('-T871I8R!#<F,Q-B@I#0H@("![#0H@(" @
M("!U<VAO<G0@=F%L=64[#0H@(" @("!U<VAO<G0@=&5M<#L-"B @(" @(&9O
M<B H=7-H;W)T(&D@/2 P.R!I(#P@=&%B;&4N3&5N9W1H.R K*VDI#0H@(" @
M("![#0H@(" @(" @("!V86QU92 ](# [#0H@(" @(" @("!T96UP(#T@:3L-
M"B @(" @(" @(&9O<B H8GET92!J(#T@,#L@:B \(#@[("LK:BD-"B @(" @
M(" @('L-"B @(" @(" @(" @(&EF("@P("$P("@H=F%L=64@7B!T96UP*2 F
M(#!X,# P,2DI#0H@(" @(" @(" @("![#0H@(" @(" @(" @(" @("!V86QU
M92 ]("AU<VAO<G0I*"AV86QU92 ^/B Q*2!>('!O;'EN;VUI86PI.PT*(" @
M(" @(" @(" @?0T*(" @(" @(" @(" @96QS90T*(" @(" @(" @(" @>PT*
M(" @(" @(" @(" @(" @=F%L=64@/CX](#$[#0H@(" @(" @(" @("!]#0H@
M(" @(" @(" @("!T96UP(#X^/2 Q.PT*(" @(" @(" @?0T*(" @(" @(" @
M=&%B;&5;:5T@/2!V86QU93L-"B @(" @('T-"B @('T-"B @("-E;F1R96=I
M;VX-"B @('!U8FQI8R!S=&%T:6,@=7-H;W)T($-O;7!U=&5#:&5C:W-U;2AB
M>71E6UT@8GET97,I#0H@("![#0H@(" @("!U<VAO<G0@8W)C(#T@,#L-"B @
M(" @(&9O<B H:6YT(&D@/2 P.R!I(#P@8GET97,N3&5N9W1H.R K*VDI#0H@
M(" @("![#0H@(" @(" @("!B>71E(&EN9&5X(#T@*&)Y=&4I*&-R8R!>(&)Y
M=&5S6VE=*3L-"B @(" @(" @(&-R8R ]("AU<VAO<G0I*"AC<F,@/CX@."D@
M7B!T86)L95MI;F1E>%TI.PT*(" @(" @?0T*(" @(" @<F5T=7)N(&-R8SL-
;"B @('T-"GT-"@T*(" @(" @(" @(" @(" @
`
end

0
Chris
1/12/2011 12:28:52 AM
sybase.powerbuilder.general 62418 articles. 17 followers. Follow

18 Replies
1485 Views

Similar Articles

[PageSpeed] 13

Compile the C code to a dll and call it as an external
function.

Since PB doesn't have any bitwise operators, any
implementation you write (using mod, '+' etc) will be
multiple orders of magnitude slower than a C function.

> PB 9.0.3
>
> Has anyone written a CRC-16 Hash calculation in
> PowerScript?  I have the  source code in C but my skills
> of converting C to PowerScript is a little  lacking.
> Short of just asking someone to do this for me (I will
> send you a  six pack of you favorite beer/beverage if you
> do) - what is the best place  to start to convert this?
>
> Chris Craft
>
>
>
> [Attachment: CRC-16 VoiceCode.c]
0
Jeremy
1/12/2011 6:10:43 AM
Hi Jeremy;

   All the bitwise commands are implemented in my STD Foundation Classes 
(see the SourceForge link at the end of my signature). So you could code it 
in PowerScript if you wanted to. However, I am not sure about the 
performance.   Note that bitwise operators are now natively available in PB 
12.net.

Regards ... Chris
President: OSUG / STD Inc.
Blog: http://chrispollach.blogspot.com
PBDJ: http://chrispollach.sys-con.com
SourceForge: http://sourceforge.net/projects/stdfndclass

wrote in message news:4d2d45e3.2817.1681692777@sybase.com...

Compile the C code to a dll and call it as an external
function.

Since PB doesn't have any bitwise operators, any
implementation you write (using mod, '+' etc) will be
multiple orders of magnitude slower than a C function.

> PB 9.0.3
>
> Has anyone written a CRC-16 Hash calculation in
> PowerScript?  I have the  source code in C but my skills
> of converting C to PowerScript is a little  lacking.
> Short of just asking someone to do this for me (I will
> send you a  six pack of you favorite beer/beverage if you
> do) - what is the best place  to start to convert this?
>
> Chris Craft
>
>
>
> [Attachment: CRC-16 VoiceCode.c] 

0
Chris
1/12/2011 3:59:26 PM
Thanks Jeremy,

I was planning on creating a global function because I need to use it in the 
DataWindow for printing Case Tags.  Do you think putting the call in the 
Global Function would have a huge perfomance hit?  There could be 1000's of 
tags in one print job?

Chris Craft

<Jeremy.Lakeman@gmail.com> wrote in message 
news:4d2d45e3.2817.1681692777@sybase.com...
> Compile the C code to a dll and call it as an external
> function.
>
> Since PB doesn't have any bitwise operators, any
> implementation you write (using mod, '+' etc) will be
> multiple orders of magnitude slower than a C function.
>
>> PB 9.0.3
>>
>> Has anyone written a CRC-16 Hash calculation in
>> PowerScript?  I have the  source code in C but my skills
>> of converting C to PowerScript is a little  lacking.
>> Short of just asking someone to do this for me (I will
>> send you a  six pack of you favorite beer/beverage if you
>> do) - what is the best place  to start to convert this?
>>
>> Chris Craft
>>
>>
>>
>> [Attachment: CRC-16 VoiceCode.c] 


0
Chris
1/12/2011 5:50:06 PM
Chris,

I downloaded the Classes but I don't see what you are referring to.  Where 
are they?

Chris Craft

"Chris Pollach" <cpollach@travel-net.com> wrote in message 
news:4d2dcfde$1@forums-1-dub...
> Hi Jeremy;
>
>   All the bitwise commands are implemented in my STD Foundation Classes 
> (see the SourceForge link at the end of my signature). So you could code 
> it in PowerScript if you wanted to. However, I am not sure about the 
> performance.   Note that bitwise operators are now natively available in 
> PB 12.net.
>
> Regards ... Chris
> President: OSUG / STD Inc.
> Blog: http://chrispollach.blogspot.com
> PBDJ: http://chrispollach.sys-con.com
> SourceForge: http://sourceforge.net/projects/stdfndclass
>
> wrote in message news:4d2d45e3.2817.1681692777@sybase.com...
>
> Compile the C code to a dll and call it as an external
> function.
>
> Since PB doesn't have any bitwise operators, any
> implementation you write (using mod, '+' etc) will be
> multiple orders of magnitude slower than a C function.
>
>> PB 9.0.3
>>
>> Has anyone written a CRC-16 Hash calculation in
>> PowerScript?  I have the  source code in C but my skills
>> of converting C to PowerScript is a little  lacking.
>> Short of just asking someone to do this for me (I will
>> send you a  six pack of you favorite beer/beverage if you
>> do) - what is the best place  to start to convert this?
>>
>> Chris Craft
>>
>>
>>
>> [Attachment: CRC-16 VoiceCode.c]
> 


0
Chris
1/12/2011 9:26:59 PM
On 12/01/2011 5:10 PM, Jeremy.Lakeman@gmail.com wrote:
> Compile the C code to a dll and call it as an external
> function.
>
> Since PB doesn't have any bitwise operators, any
> implementation you write (using mod, '+' etc)



> will be  multiple orders of magnitude slower than a C function.
Yep, exactly what a developer I used to work with encountered when 
trying to do a hash routine.


>
>> PB 9.0.3
>>
>> Has anyone written a CRC-16 Hash calculation in
>> PowerScript?  I have the  source code in C but my skills
>> of converting C to PowerScript is a little  lacking.
>> Short of just asking someone to do this for me (I will
>> send you a  six pack of you favorite beer/beverage if you
>> do) - what is the best place  to start to convert this?
>>
>> Chris Craft
>>
>>
>>
>> [Attachment: CRC-16 VoiceCode.c]

0
Adam
1/12/2011 10:24:33 PM
Or how about making it an Oracle Function that gets called in the Select of 
the DataWindow?  There is the BitAnd() function is that all I need?

Chris Craft

<Jeremy.Lakeman@gmail.com> wrote in message 
news:4d2d45e3.2817.1681692777@sybase.com...
> Compile the C code to a dll and call it as an external
> function.
>
> Since PB doesn't have any bitwise operators, any
> implementation you write (using mod, '+' etc) will be
> multiple orders of magnitude slower than a C function.
>
>> PB 9.0.3
>>
>> Has anyone written a CRC-16 Hash calculation in
>> PowerScript?  I have the  source code in C but my skills
>> of converting C to PowerScript is a little  lacking.
>> Short of just asking someone to do this for me (I will
>> send you a  six pack of you favorite beer/beverage if you
>> do) - what is the best place  to start to convert this?
>>
>> Chris Craft
>>
>>
>>
>> [Attachment: CRC-16 VoiceCode.c] 


0
Chris
1/12/2011 10:37:04 PM
Is he still alive?  This is about to drive me nuts...

"Adam Simmonds" <adam.simmonds@remove.exemail.com.au> wrote in message 
news:4d2e2a21$1@forums-1-dub...
> On 12/01/2011 5:10 PM, Jeremy.Lakeman@gmail.com wrote:
>> Compile the C code to a dll and call it as an external
>> function.
>>
>> Since PB doesn't have any bitwise operators, any
>> implementation you write (using mod, '+' etc)
>
>
>
>> will be  multiple orders of magnitude slower than a C function.
> Yep, exactly what a developer I used to work with encountered when trying 
> to do a hash routine.
>
>
>>
>>> PB 9.0.3
>>>
>>> Has anyone written a CRC-16 Hash calculation in
>>> PowerScript?  I have the  source code in C but my skills
>>> of converting C to PowerScript is a little  lacking.
>>> Short of just asking someone to do this for me (I will
>>> send you a  six pack of you favorite beer/beverage if you
>>> do) - what is the best place  to start to convert this?
>>>
>>> Chris Craft
>>>
>>>
>>>
>>> [Attachment: CRC-16 VoiceCode.c]
> 


0
Chris
1/12/2011 10:39:38 PM
How big is the value you need to hash?  The OUTLN_EDIT_PKG package has
a GENERATE_SIGNATURE method that will give you a hash value.

On 12 Jan 2011 14:37:04 -0800, "Chris Craft"
<NOChrisATfamoussoftwareDOTcom> wrote:

>Or how about making it an Oracle Function that gets called in the Select of 
>the DataWindow?  There is the BitAnd() function is that all I need?
>
>Chris Craft
>
><Jeremy.Lakeman@gmail.com> wrote in message 
>news:4d2d45e3.2817.1681692777@sybase.com...
>> Compile the C code to a dll and call it as an external
>> function.
>>
>> Since PB doesn't have any bitwise operators, any
>> implementation you write (using mod, '+' etc) will be
>> multiple orders of magnitude slower than a C function.
>>
>>> PB 9.0.3
>>>
>>> Has anyone written a CRC-16 Hash calculation in
>>> PowerScript?  I have the  source code in C but my skills
>>> of converting C to PowerScript is a little  lacking.
>>> Short of just asking someone to do this for me (I will
>>> send you a  six pack of you favorite beer/beverage if you
>>> do) - what is the best place  to start to convert this?
>>>
>>> Chris Craft
>>>
>>>
>>>
>>> [Attachment: CRC-16 VoiceCode.c] 
>
0
Bruce
1/12/2011 11:53:25 PM
Jeremy,

I tried compiling to a dll but when I go to use it in PB I get 'Error 
calling external function...'.  Here is my local declaration:
    Function string VoiceCode(string gtin, string lot) library 
"C:\Develop\TestApp\VoiceCode.dll"

What else might I be missing?  Do I need to use CCW to call it?

Chris Craft

<Jeremy.Lakeman@gmail.com> wrote in message 
news:4d2d45e3.2817.1681692777@sybase.com...
> Compile the C code to a dll and call it as an external
> function.
>
> Since PB doesn't have any bitwise operators, any
> implementation you write (using mod, '+' etc) will be
> multiple orders of magnitude slower than a C function.
>
>> PB 9.0.3
>>
>> Has anyone written a CRC-16 Hash calculation in
>> PowerScript?  I have the  source code in C but my skills
>> of converting C to PowerScript is a little  lacking.
>> Short of just asking someone to do this for me (I will
>> send you a  six pack of you favorite beer/beverage if you
>> do) - what is the best place  to start to convert this?
>>
>> Chris Craft
>>
>>
>>
>> [Attachment: CRC-16 VoiceCode.c] 


0
Chris
1/13/2011 12:29:14 AM
Not many - Currently 34 characters and maybe 7 more for the date.

So this is interesting - I Googled 'OUTLN_EDIT_PKG generate_signature' and 
it returned only 14 items.  I have never in my life googled something that 
returned less than 1 million hits!  Even 'PowerBuilder' returns 2.5 million.

Anyway, I created a function for this but my hash return is quite large.  I 
need it to be calculated using CRC-16.  Here is a website that does the 
conversion: http://zorc.breitbandkatze.de/crc.html .  If you put in 
'1085051000201146587443HG234' as the Data the return hex value is 66F7 which 
in decimal is 26359.  The last part of the C code will return the least 
significant digits in decimal form (Hash mod 10000).  I tried finding more 
info on the Oracle package to do this but I can't seem to find anything.  Do 
you think it is possible using this package?

Thanks again Bruce for your input,
Chris Craft

"Bruce Armstrong" <NOCANSPAM_bruce.armstrong@yahoo.com> wrote in message 
news:tkfsi6t804kohf692k2kljq7qijqn3196v@4ax.com...
>
> How big is the value you need to hash?  The OUTLN_EDIT_PKG package has
> a GENERATE_SIGNATURE method that will give you a hash value.
>
> On 12 Jan 2011 14:37:04 -0800, "Chris Craft"
> <NOChrisATfamoussoftwareDOTcom> wrote:
>
>>Or how about making it an Oracle Function that gets called in the Select 
>>of
>>the DataWindow?  There is the BitAnd() function is that all I need?
>>
>>Chris Craft
>>
>><Jeremy.Lakeman@gmail.com> wrote in message
>>news:4d2d45e3.2817.1681692777@sybase.com...
>>> Compile the C code to a dll and call it as an external
>>> function.
>>>
>>> Since PB doesn't have any bitwise operators, any
>>> implementation you write (using mod, '+' etc) will be
>>> multiple orders of magnitude slower than a C function.
>>>
>>>> PB 9.0.3
>>>>
>>>> Has anyone written a CRC-16 Hash calculation in
>>>> PowerScript?  I have the  source code in C but my skills
>>>> of converting C to PowerScript is a little  lacking.
>>>> Short of just asking someone to do this for me (I will
>>>> send you a  six pack of you favorite beer/beverage if you
>>>> do) - what is the best place  to start to convert this?
>>>>
>>>> Chris Craft
>>>>
>>>>
>>>>
>>>> [Attachment: CRC-16 VoiceCode.c]
>> 


0
Chris
1/13/2011 1:02:09 AM
Hi Chris;

  Have a look at the "nc_numerical" NVUO!  :-)

HTH

Regards ... Chris


"Chris Craft"  wrote in message news:4d2e1ca3$1@forums-1-dub... 

Chris,

I downloaded the Classes but I don't see what you are referring to.  Where 
are they?

Chris Craft

"Chris Pollach" <cpollach@travel-net.com> wrote in message 
news:4d2dcfde$1@forums-1-dub...
> Hi Jeremy;
>
>   All the bitwise commands are implemented in my STD Foundation Classes 
> (see the SourceForge link at the end of my signature). So you could code 
> it in PowerScript if you wanted to. However, I am not sure about the 
> performance.   Note that bitwise operators are now natively available in 
> PB 12.net.
>
> Regards ... Chris
> President: OSUG / STD Inc.
> Blog: http://chrispollach.blogspot.com
> PBDJ: http://chrispollach.sys-con.com
> SourceForge: http://sourceforge.net/projects/stdfndclass
>
> wrote in message news:4d2d45e3.2817.1681692777@sybase.com...
>
> Compile the C code to a dll and call it as an external
> function.
>
> Since PB doesn't have any bitwise operators, any
> implementation you write (using mod, '+' etc) will be
> multiple orders of magnitude slower than a C function.
>
>> PB 9.0.3
>>
>> Has anyone written a CRC-16 Hash calculation in
>> PowerScript?  I have the  source code in C but my skills
>> of converting C to PowerScript is a little  lacking.
>> Short of just asking someone to do this for me (I will
>> send you a  six pack of you favorite beer/beverage if you
>> do) - what is the best place  to start to convert this?
>>
>> Chris Craft
>>
>>
>>
>> [Attachment: CRC-16 VoiceCode.c]
> 

0
Chris
1/13/2011 1:19:53 AM
Hi Chris;

1) Drop the path (C:\Develop\TestApp) in the external function declaration.
2) Do any parameters need to be declared as REF?

Regards ... Chris



"Chris Craft"  wrote in message news:4d2e475a$1@forums-1-dub... 

Jeremy,

I tried compiling to a dll but when I go to use it in PB I get 'Error 
calling external function...'.  Here is my local declaration:
    Function string VoiceCode(string gtin, string lot) library 
"C:\Develop\TestApp\VoiceCode.dll"

What else might I be missing?  Do I need to use CCW to call it?

Chris Craft

<Jeremy.Lakeman@gmail.com> wrote in message 
news:4d2d45e3.2817.1681692777@sybase.com...
> Compile the C code to a dll and call it as an external
> function.
>
> Since PB doesn't have any bitwise operators, any
> implementation you write (using mod, '+' etc) will be
> multiple orders of magnitude slower than a C function.
>
>> PB 9.0.3
>>
>> Has anyone written a CRC-16 Hash calculation in
>> PowerScript?  I have the  source code in C but my skills
>> of converting C to PowerScript is a little  lacking.
>> Short of just asking someone to do this for me (I will
>> send you a  six pack of you favorite beer/beverage if you
>> do) - what is the best place  to start to convert this?
>>
>> Chris Craft
>>
>>
>>
>> [Attachment: CRC-16 VoiceCode.c] 

0
Chris
1/13/2011 1:26:17 AM
1) I had tried that first, the path was an attempt at directing it.
2) I don't believe so - at least from what I can tell looking at the C# 
code.

All I did was bring that code into VS under a Class Library project and then 
compiled it.  Moved that dll to a directory in my system path and then tried 
to use it in PB.  I have not dealt with C much so are there different ways 
to work with a dll if the code is C# compared to C++?  Isn't C# dealing with 
namespaces so we have to do something a little different?

Chris Craft


"Chris Pollach" <cpollach@travel-net.com> wrote in message 
news:4d2e54b9$1@forums-1-dub...
> Hi Chris;
>
> 1) Drop the path (C:\Develop\TestApp) in the external function 
> declaration.
> 2) Do any parameters need to be declared as REF?
>
> Regards ... Chris
>
>
>
> "Chris Craft"  wrote in message news:4d2e475a$1@forums-1-dub...
> Jeremy,
>
> I tried compiling to a dll but when I go to use it in PB I get 'Error 
> calling external function...'.  Here is my local declaration:
>    Function string VoiceCode(string gtin, string lot) library 
> "C:\Develop\TestApp\VoiceCode.dll"
>
> What else might I be missing?  Do I need to use CCW to call it?
>
> Chris Craft
>
> <Jeremy.Lakeman@gmail.com> wrote in message 
> news:4d2d45e3.2817.1681692777@sybase.com...
>> Compile the C code to a dll and call it as an external
>> function.
>>
>> Since PB doesn't have any bitwise operators, any
>> implementation you write (using mod, '+' etc) will be
>> multiple orders of magnitude slower than a C function.
>>
>>> PB 9.0.3
>>>
>>> Has anyone written a CRC-16 Hash calculation in
>>> PowerScript?  I have the  source code in C but my skills
>>> of converting C to PowerScript is a little  lacking.
>>> Short of just asking someone to do this for me (I will
>>> send you a  six pack of you favorite beer/beverage if you
>>> do) - what is the best place  to start to convert this?
>>>
>>> Chris Craft
>>>
>>>
>>>
>>> [Attachment: CRC-16 VoiceCode.c]
> 


0
Chris
1/13/2011 4:27:57 AM
Make sure your dll is actually exporting "VoiceCode" and not
"_VoiceCode@8" or similar.
Make sure it's declared as __stdcall.

> Jeremy,
>
> I tried compiling to a dll but when I go to use it in PB I
> get 'Error  calling external function...'.  Here is my
> local declaration:
>     Function string VoiceCode(string gtin, string lot)
> library  "C:\Develop\TestApp\VoiceCode.dll"
>
> What else might I be missing?  Do I need to use CCW to
> call it?
>
> Chris Craft
>
> <Jeremy.Lakeman@gmail.com> wrote in message
> news:4d2d45e3.2817.1681692777@sybase.com...
> > Compile the C code to a dll and call it as an external
> > function.
> >
> > Since PB doesn't have any bitwise operators, any
> > implementation you write (using mod, '+' etc) will be
> > multiple orders of magnitude slower than a C function.
> >
> >> PB 9.0.3
> >>
> >> Has anyone written a CRC-16 Hash calculation in
> >> PowerScript?  I have the  source code in C but my
> skills >> of converting C to PowerScript is a little
> lacking. >> Short of just asking someone to do this for me
> (I will >> send you a  six pack of you favorite
> beer/beverage if you >> do) - what is the best place  to
> start to convert this? >>
> >> Chris Craft
> >>
> >>
> >>
> >> [Attachment: CRC-16 VoiceCode.c]
>
>
0
Jeremy
1/13/2011 4:30:10 AM
So your bitwise and calls getbit twice, then setbit (which
also calls getbit...). Far too many method calls and
redundant calculations there. You should find this to be a
bit quicker, but you'd only notice if you call the function
a few thousand times.

public function unsignedlong bitwise_and (unsignedlong
aul_arg1, unsignedlong aul_arg2);ulong ul_exp, ul_bit1,
ul_bit2, ul_ret
long ll_i
if aul_arg1=0 or aul_arg2=0 then return 0

for ll_i = 1 to 31
   ul_exp=2^ll_i
   ul_bit1=mod(aul_arg1,ul_exp)
   ul_bit2=mod(aul_arg2,ul_exp)

   if ul_bit1=ul_bit2 then
      ul_ret+=ul_bit1
   end if

   aul_arg1 -=ul_bit1
   aul_arg2 -=ul_bit2
next

if aul_arg1=aul_arg2 then
   ul_ret+=aul_arg1
end if

return ul_ret
end function

OR and XOR left as an exercise for the reader.

Though I use a system library function from an external dll
call which is still multiple orders of magnitude faster than
the above.


> Hi Jeremy;
>
>    All the bitwise commands are implemented in my STD
> Foundation Classes  (see the SourceForge link at the end
> of my signature). So you could code it  in PowerScript if
> you wanted to. However, I am not sure about the
> performance.   Note that bitwise operators are now
> natively available in PB  12.net.
>
> Regards ... Chris
> President: OSUG / STD Inc.
> Blog: http://chrispollach.blogspot.com
> PBDJ: http://chrispollach.sys-con.com
> SourceForge: http://sourceforge.net/projects/stdfndclass
>
> wrote in message
> news:4d2d45e3.2817.1681692777@sybase.com...
>
> Compile the C code to a dll and call it as an external
> function.
>
> Since PB doesn't have any bitwise operators, any
> implementation you write (using mod, '+' etc) will be
> multiple orders of magnitude slower than a C function.
>
> > PB 9.0.3
> >
> > Has anyone written a CRC-16 Hash calculation in
> > PowerScript?  I have the  source code in C but my skills
> > of converting C to PowerScript is a little  lacking.
> > Short of just asking someone to do this for me (I will
> > send you a  six pack of you favorite beer/beverage if
> > you do) - what is the best place  to start to convert
> this? >
> > Chris Craft
> >
> >
> >
> > [Attachment: CRC-16 VoiceCode.c]
>
0
Jeremy
1/13/2011 4:41:54 AM
Hi Chris,

If CRC16 usage is not obligatory, how about using the 4-byte CRC32. I would 
strongly recommend you the ZLIB.DLL - it has this function and much much 
more (compression):

The official site:
http://zlib.net/

The Windows compiled binary (DLL):
http://www.winimage.com/zLibDll/index.html

Regards,
Ivaylo

"Chris Craft" <NOChrisATfamoussoftwareDOTcom> wrote in message 
news:4d2cf5c4$1@forums-1-dub...
> PB 9.0.3
>
> Has anyone written a CRC-16 Hash calculation in PowerScript?  I have the 
> source code in C but my skills of converting C to PowerScript is a little 
> lacking.  Short of just asking someone to do this for me (I will send you 
> a six pack of you favorite beer/beverage if you do) - what is the best 
> place to start to convert this?
>
> Chris Craft
>
> 


0
Ivaylo
1/13/2011 6:58:59 AM
On 13/01/2011 9:39 AM, Chris Craft wrote:
> Is he still alive?  This is about to drive me nuts...

He is still alive but working o/s now.
I dont believe he finished the code because it was too slow and wasnt 
going to be suitable. The alternative was to go out to a web service 
which could then do the work in .NET or Java world.

>
> "Adam Simmonds"<adam.simmonds@remove.exemail.com.au>  wrote in message
> news:4d2e2a21$1@forums-1-dub...
>> On 12/01/2011 5:10 PM, Jeremy.Lakeman@gmail.com wrote:
>>> Compile the C code to a dll and call it as an external
>>> function.
>>>
>>> Since PB doesn't have any bitwise operators, any
>>> implementation you write (using mod, '+' etc)
>>
>>
>>
>>> will be  multiple orders of magnitude slower than a C function.
>> Yep, exactly what a developer I used to work with encountered when trying
>> to do a hash routine.
>>
>>
>>>
>>>> PB 9.0.3
>>>>
>>>> Has anyone written a CRC-16 Hash calculation in
>>>> PowerScript?  I have the  source code in C but my skills
>>>> of converting C to PowerScript is a little  lacking.
>>>> Short of just asking someone to do this for me (I will
>>>> send you a  six pack of you favorite beer/beverage if you
>>>> do) - what is the best place  to start to convert this?
>>>>
>>>> Chris Craft
>>>>
>>>>
>>>>
>>>> [Attachment: CRC-16 VoiceCode.c]
>>
>
>

0
Adam
1/14/2011 12:47:16 AM
And what about MD5, this is available easilly in windows.
Claude


"Ivaylo Ivanov"  a �crit dans le message de groupe de discussion : 
4d2ea2b3$1@forums-1-dub...

Hi Chris,

If CRC16 usage is not obligatory, how about using the 4-byte CRC32. I would
strongly recommend you the ZLIB.DLL - it has this function and much much
more (compression):

The official site:
http://zlib.net/

The Windows compiled binary (DLL):
http://www.winimage.com/zLibDll/index.html

Regards,
Ivaylo

"Chris Craft" <NOChrisATfamoussoftwareDOTcom> wrote in message
news:4d2cf5c4$1@forums-1-dub...
> PB 9.0.3
>
> Has anyone written a CRC-16 Hash calculation in PowerScript?  I have the 
> source code in C but my skills of converting C to PowerScript is a little 
> lacking.  Short of just asking someone to do this for me (I will send you 
> a six pack of you favorite beer/beverage if you do) - what is the best 
> place to start to convert this?
>
> Chris Craft
>
>

0
Claude
1/15/2011 7:52:20 AM
Reply:

Similar Artilces:

Hashes and hashes of hashes
Hi, First of all thanks for the references to the Storables module to dump a hash/array into a file so other cgi's can use this hash/array too. It works great! But I ran into another issue (I think it's just a syntax issue, but I'm not sure I'm appraoching this correctly): When my script is called, I parse in some variables. I want to build a hash where the one variable will function as the a key of the hash and the other variables must be referenced by again a reference.. Confused? Me too. Example: %newdata = (); $newdata{$TAG} = $co->param(&#...

add hash to hash of hash
------=_NextPart_000_0269_01C17C11.0E643120 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi, Still more hash questions:=20 using the example in chapter 9 of Programming Perl: %HoH =3D ( flintstones =3D> { husband =3D> "fred", pal =3D> "barney", }, ); how can dynamically add another hash to %HoH? In Programming Perl, they = have a hard coded example: $HoH{mash} =3D { captain =3D> "pierce", ... }; I've tried:=2...

processing a hash of a hash of a hash
I am trying to print out a hash of a hash of a hash table(with code chunk 1), but I keep getting the following error: Use of uninitialized value in hash element at ./clearwhite.pl line 522. I don't understand where this error is coming from since I can process a hash of a hash just fine, using code chunk2, and i know that the values I am trying to process exist, as i can print them out, or run the exists/defined/true tests on them as i do here. Where is my mistake? How is this done? thanks fo rlooking at this, ryan ------------------------- 1 - Use of uninitialize...

Hash of Hash
Greetings, I am attempting to make a hash of hashes or something equivalent but can't seem to get it working properly. Here is what I have so far: @name = ("one", "two", "three"); Foreach my $layer (@name) { $thief_opt = { $layer = { type => "solid", origin => "datum", use_arcs => "yes", } }; } ##--for test purposes simply print the vars for now while (($key, $val) = each %$thief_opt) { while (($key2, $val2) = each %$val) { print "$key $key2 $val2; } } I am try...

Hashes of Hashes
Hi, I'm working on a complex data structure with hashes of hashes and hashes of arrays and I noticed a weird behavior I was hoping someone could explain. Here's a sample: $Data{US17}{1}{GROUP} = "STRING"; $Data{US17}{1}{GROUP}{.001} = 5; $Data{US17}{1}{GROUP}{.002} = 6; $Data{US17}{1}{GROUP}{.003} = 7; print "group = $Data{US17}{1}{GROUP}\n"; for my $time (keys %{$Data{US17}{1}{GROUP}}){ print "time = $time $Data{US17}{1}{GROUP}{$time}\n"; } The output is: group = STRING time = 0.002 6 time = 0.003 7 time = 0.001 5 If I ...

calculator for powerbuilder
Hi Does anybody know, if there is a tool / object that implements a calculator (simple version). Best would be a native Powerbuilder implementation that can be called in any datawindow field with a keystroke and pass the calculated value back to that field. Isnt' there something in pfc (i don't use it) or has somebody written such a thing for own? thanks for help Martin take a look at PFC, which has a dropdown calculator In article <4742a1b3@forums-1-dub>, m.kaltenboeck@utanet.at says... > Hi > > Does anybody know, if there is a tool / obje...

Hash of Hashes
--0-1461055884-1254217382=:30526 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable How can I create a Hash of Hashes from two lists. Is it possible?=0A=0AI wa= nt the effective functionality to be served like this=0A=0A$ChildHash["Joe"= ]["21A"]=3D"Sally"=0A=0Ai.e Joe at 21A has a child called Sally. List1 here= will be the name of Parents, List2 here will contain the house number. =0A= =0ASoham=0A=0A=0A=0A From cricket scores to your friends. Try the Yaho= o! India Homepage! http://in.yahoo.com/trynew --0-1461055...

Hash of hashes
Fellow PERLians, Thanks so much for all your help in advance. I have a rather vexing problem. I'm trying to construct a hash of hashes from data sent to a script from a form. I've already parsed the arrays @data and @model to the point I want them. This is the code that fails me: $i=0; for $fields(split /&/, @data) { ($key, $value) = split /=/, $fields; $bigData{$model[$i]}{$key} = "$value"; $i++; } It won't print out @data or @model from anywhere inside the f...

Hash of hashes?
This I cannot get my mind around... My data: SNP Genotype 1 CC 1 CT 1 TT 1 NN It seems to me that I need a hash of hashes. Inner hash: $inner{ $Genotype }++ ; Since the value of the out hash ( $outer{ $SNP } ) has to be a scalar, this scalar has to be a reference to the inner hash, correct? If so, how do I declare them? my %outer ; Or should it be a reference to an anonymous hash? my $outer = +{} ; So that my code might look like: $outer -> { $SNP }{ $Genotype }++ ; Any help or reference is appreciated. My text on hand a...

What generals generally do
Reading a McChrystal thread elsewhere, I came across someone quoting a US general http://en.wikipedia.org/wiki/Smedley_Butler > I spent 33 years and four months in active military service and > during that period I spent most of my time as a high class thug for > Big Business, for Wall Street and the bankers. In short, I was a > racketeer, a gangster for capitalism. I helped make Mexico and > especially Tampico safe for American oil interests in 1914. I helped > make Haiti and Cuba a decent place for the National City Bank boys to > collect revenues in. I ...

Powerbuilder is not a calculator
Hi, I just found out Powerbuilder (6.5) can't calculate. Try the following example: decimal{2} ldc_1, ldc_2, ldc_3 real lr_3 ldc_1 = 114229115.00 ldc_2 = 18952980.00 ldc_3 = ldc_1 + ldc_2 lr_3 = ldc_1 + ldc_2 The result of ldc_3 is 133182095.00 as anticipated, however lr_3 gets the value 133182096 ?!? Maybe the ghost of the infamous Perntiumbug is haunting PB ;-) Roy L. It's called a floating point rounding error, and it will happen with just about any product running on a PC, because of the way that floating point numbers are handled. On Tue, ...

Hashes of hashes..
Hi all, Another simple one, I hope. I have data like this. Computername:Description:Failed Pings At present I am putting this data into seperate arrays and using an index to get it out in order. Not an extremely efficient way to do this and I will need to add more fields later and the like. I have considered using a hash, but if I, say use the keys function, and am using a multidimensional hash (i.e $hash => computername => description => failed pings) it will, I assume, return all the values as keys, whereas I only want the first layer (I.E Computername) then I c...

hash of hashes
I'm trying to create a multi level hash of hashes/arrays Here's my code: HV* PortInfo(cp,profile=NULL) Laff::Cell cp char* profile CODE: { node_p names,np; HV *top,*hv; name_p name; top = newHV(); RETVAL = top; names = node_find(cp->head,lNAMES); np = node_next(names,names); while(np) { if (np->type EQ lNAME) { name = (name_p) np->data; hv = newHV(); hv_store(top,name->name,strlen(name->name),(SV*)hv,0); } np = node_next(np,names); } } OUTPUT: RETVAL Here's the...

hashing out hashes
For a program I'm writting I'm making a complex data structure, a hash of hashes. I'm constructing a hash along the way, then trying to insert that hash into the larger hash. Problem is I'm not sure precicely how to do it. $external_hash{'key'} = %internal_hash; gives a fraction, which I've discerned to be a reference based off of the errors. \%internal_hash obviously gives a reference and in the more normal format. So what's the trick? ~wren On Sun, Apr 06, 2003 at 08:35:29PM -0700, Nicholas G. Thornton wrote: > For a program I'm writting...

Web resources about - CRC-16 Hash Calculation - sybase.powerbuilder.general

Calculation - Wikipedia, the free encyclopedia
A calculation is a deliberate process that transforms one or more inputs into one or more results, with variable change. The term is used in ...

Facebook to adjust calculations for total check-ins displayed on place pages
Facebook says it will change how check-ins are calculated so that place pages more accurately reflect how many people visited a location. According ...

App Store - Civil Engineering Calculations
Get Civil Engineering Calculations on the App Store. See screenshots and ratings, and read customer reviews.

Canterbury Bulldogs prop David Klemmer bolts into Kangaroos calculations
Canterbury giant David Klemmer is set to be handed a Test debut as the Kangaroos look to bolster their depleted forward stocks but the Australians ...

Sydney Swans star Ben McGlynn bursts into All Australian calculations
Ben McGlynn is the latest Sydney star to burst into All Australian calculations after continuing his rich vein of form against Port Adelaide, ...

By any calculation Melbourne kid Alex Gunning was No. 1 at world maths Olympiad
When you calculate the sheer maths of the challenge confronting him last week, the odds of Alex Gunning finishing on top were almost unfathomable. ...

Tricolours show true colours to surge into calculations
Let it now be official. Sydney Roosters have a serious scalp. Having won on Monday night against Manly under trying circumstances - at Brookvale ...

Commentary: Manila's wrong calculation
Commentary: Manila's wrong calculation People's Daily Online Links. Global TimesChinadaily.com.cn Ecns.cn Show ChinaChina Human RightsChina ...

4 Recommendations (and 1 Calculation) to Improve Social Media Engagement
Marketers often have a spectrum of goals for their Facebook pages. From growing awareness to converting Fans into email subscribers, many marketers ...

Cameron's refugee calculation
The UK pledged to admit more refugees in the country, but it is not enough.

Resources last updated: 1/18/2016 4:59:21 PM