所以我在闲聊中有一个字符串,该字符串通过 TCP/IP 连接作为“$100xxxxxxZZ”,其中 x 是数字 0-9 或字母 A - Z,ZZ 是发送方计算的校验和。使用该字符串,我需要计算“100xxxxxx”的校验和,以验证这是正确的味精和校验和。所以我需要能够从 '$100xxxxxxZZ' 中删除 '$' 和 'ZZ'
我已经知道如何截断“ZZ”,这是我的代码:
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 如何在 Visualworks 2.5 的 smalltalk 中删除字符串中的第一个字符(是的,我知道这是古老的)