Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SetCharsAt #32

Open
jtengg opened this issue Jul 5, 2020 · 0 comments
Open

SetCharsAt #32

jtengg opened this issue Jul 5, 2020 · 0 comments

Comments

@jtengg
Copy link

jtengg commented Jul 5, 2020

the SetCharsAt function does not work. I tried converting from string to a byte slice, writing to plc, and reading back using GetCharsAt. The values return all zeros.

ive found the solution below to work

//SetCharsAt Set Array of char (S7 ARRAY OF CHARS)
func (s7 *Helper) SetCharsAt(buffer []byte, pos int, value string) {
copy(buffer[pos:pos+len(value)], []byte(value))
//buffer = append(buffer[:pos], append([]byte(value), buffer[pos:]...)...)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant