--- title: "Bug in Saving Variables" type: "article" slug: "bug-in-saving-variables" url: "http://localhost/article/bug-in-saving-variables/" markdown_url: "http://localhost/article/bug-in-saving-variables.md" published_at: "2022-09-14T02:42:50+00:00" modified_at: "2026-07-04T00:09:27+00:00" featured_image: url: "http://localhost/wp-content/uploads/2022/04/20230809-041332.jpg" excerpt: "I ran into something I thought was strange. Try this: 10 LET a$=\"sample string\" 20 SAVE \"sample\" DATA a$() Run, then rewind the tape, then NEW. 10 LOAD \"\" DATA a$() 20 PRINT a$ 30 PRINT a$() This does not work. For some reason, if you SAVE a string using the DATA token, the string…" category: - name: "LISTing Newsletter" slug: "listing-newsletter" taxonomy: "category" url: "http://localhost/category/periodicals/listing-newsletter/" post_tag: - name: "Best of Timex/Sinclair 2068 Articles and Documents" slug: "ts2068best" taxonomy: "post_tag" url: "http://localhost/tag/ts2068best/" - name: "TS 2068" slug: "ts2068" taxonomy: "post_tag" url: "http://localhost/tag/ts2068/" model: - name: "Timex/Sinclair 2068" slug: "ts-2068" taxonomy: "model" url: "http://localhost/model/ts-2068/" publication_r: id: 38992 title: "LISTing Newsletter" type: "periodical" url: "http://localhost/periodical/listing-newsletter/" issues_articles: - id: 40115 title: "LISTing Newsletter April 1985" type: "issue" url: "http://localhost/issue/listing-newsletter-april-1985/" pages: "19" pubdate: "April 1985" archive_link: false --- # Bug in Saving Variables I ran into something I thought was strange. Try this: ``` 10 LET a$="sample string" 20 SAVE "sample" DATA a$() ``` Run, then rewind the tape, then NEW. ``` 10 LOAD "" DATA a$() 20 PRINT a$ 30 PRINT a$() ``` This does not work. For some reason, if you SAVE a string using the DATA token, the string is saved and then can be loaded back into the computer, but not in a form that can be used. There is a simple patch that solves this problem by putting the string into a one-dimensional array: ``` 20 DIM t$( LEN a$) 30 FOR i=1 TO LEN a$ 40 LET t$(i)=a$(i) 50 NEXT i ``` If you SAVE t$, when you LOAD it back in, it can be use as a normal string. Do not ask me why.