Search code examples
stringsmalltalktruncationvisualworks

How to remove the leading character from a string in smalltalk


So I have a string in small talk, the string comes across TCP/IP connection as '$100xxxxxxZZ' where the x's are numbers 0-9 or letters A - Z, and the ZZ is the checksum as calculated by the sender. With the string I need to calculate a checksum of '100xxxxxx' in order to verify this is the correct msg and checksum. SO I need to be able to remove the '$' and 'ZZ' off of '$100xxxxxxZZ'

I already know how to truncate the 'ZZ' off, here's my code as it stands:

ValidateMsg: replyWithCheckSum

|newMsg tempMsg|
"removes the 'ZZ' from '$100xxxxxxZZ'  "
tempMsg := replyWithCheckSum copyFrom: 2 to: (replyWithCheckSum size -2).

"CODE TO REMOVE THE '$' AND STORE INTO newMsg"

"compares the 'ZZ' to the checksum calculated from newMsg"
^(self calcCheckSum: newMsg) = (self getCheckSumFromReply: replyWithCheckSum)

TL;DR how do I remove the 1st character in a string in smalltalk for visualworks 2.5 (yes I know this is ancient)


Solution

  • You could try

    myString allButFirst
    

    (which, btw, would work on any collection)