Chr$() function

birrebirre Member Posts: 22
Hi,

For my serial communication I need to translate a VB6 project to NAV.
This is the code:
begin = Chr$(0) + Chr$(1) + Chr$(adr) + Chr$(3) + Chr$(&HC0) + "001" + Chr$(&HE2) + Chr$(&HC1) + Chr$(&HC0)
zend = begin + tmp2 + Chr$(4)  

ck = 0
For i = 1 To Len(send)
ck = ck Xor Asc(Mid$(send, i, 1))
Next i
send = send+ Chr$(ck)

Winsock.SendData send

Now I can't seem to find what alternative NAV uses for the Chr$ function.
Thank you

Comments

  • birrebirre Member Posts: 22
    Apparantly some text has lost.

    I use local variable Chars to define the numbers:

    Chr0 := 0; //Chr$(0)
    Chr1 := 1; //Chr$(1)

    I convert the hexadecimal values and put them to chars:

    ChrHC0 := 192; //Chr$(&HC0)

    Then I concatenate the different Chars.

    The problem is within the checksum:
    ck = 0
    For i = 1 To Len(send)
    ck = ck Xor Asc(Mid$(send, i, 1))
    Next i
    send = send+ Chr$(ck)
    

    Can I perform a XOR for the ASC value of the SUBSTR?
  • David_SingletonDavid_Singleton Member Posts: 5,479
    Why are you doing this? Why not just leave the code in VB and call it from Navision?
    David Singleton
  • birrebirre Member Posts: 22
    It has to be integrated in Navision, no other choise available i'm afraid.
  • MBergerMBerger Member Posts: 413
    The main problem is that the NAV function XOR can only be used on booleans, not on integers like in other languages. You'll have to find some way to make a function that does the same. small tip regarding your MID$ function, you can get the nth character of a test variable by using textvar[n].
Sign In or Register to comment.