Skip to content

Change string contents with POKE #108

Open

Description

@Mrdavidyunker

Problem
I created the following program that uses the POKE instruction but when I run it it does not change the contents of the memory location being referenced.

1 REM THIS PROGRAM IS suppose TO CHANGE THE STRING FROM " " TO "A " but doesn't
5 DEFINT A-N
6 DEFINT P-Z
10 OBJCODE$ = " "
20 OBJPTR = VARPTR(OBJCODE$)
25 OBJPTR = PEEK(OBJPTR+1) + 256*PEEK(OBJPTR+2)
30 A = 65
40 POKE OBJPTR,A
50 PRINT LEN(OBJCODE$), OBJCODE$
60 PRINT PEEK(OBJPTR+1),PEEK(OBJPTR+2),PEEK(OBJPTR+3)

After this program is run OBJCODE$ is not changed.
If i do a POKE OBJPTR,A instruction after the program is run then OBJCODE$ is not changed.

I am using PCBASIC version 2.0.2
Operating system version : Windows 7

Activity

  1. robhagemans commented on Nov 30, 2019

    @robhagemans
    Owner

    Hi @Mrdavidyunker ,

    POKEing to change the contents of variables or strings is not currently supported (though read access with PEEK is supported). It may be added in a future version.

    Thanks

  2. changed the title [-]Having problem with POKE instruction[/-] [+]Change string contents with POKE[/+] on Nov 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions