Opry99er Posted January 8, 2018 Share Posted January 8, 2018 (edited) Bear with me... I'm going to work through an issue in my head here and I hope someone might have some additional opinions that might give me a little better understanding. Thanks in advance. I'm working on a project right now that requires a significant amount of text to be available to the program for display. I have chosen to put all the text into DATA statements, and then use a small subroutine to load all the text into a string array. It works beautifully, but I am noticing that it is chewing through my stack space. So far I have 33% of all the required text in DATA statements, but my stack space has been cut in half with just the 1/3 of text I need. I still have enough PROGRAM space, I think, to finish the project. Two things: 1) I don't mind hitting a disk for the data, but I only want to do it once. This means that the stack space will still have to absorb all this text into the string arrays, and we will probably run out of stack space. Example of #1: (text on disk pulled into a string array) Initialize Open disk file Read all text from disk and feed it into a text array Close disk file Begin Program Display Text from string arrays End Program In this scenario we save PROGAM space, but not STACK space. 2) I COULD read the text directly from the DATA statements and bypass the use of string arrays. This, however, would require that all the DATA is in my program at all times, and would significantly cut down on my PROGRAM space. Example of #2: (text read from DATA statements and displayed as needed) Initialize Begin Program Display text from DATA statements as needed using RESTORE End Program In this scenario, we save STACK space, but not program space Perhaps there is something I missed here... Any thoughts? Edited January 8, 2018 by Opry99er Quote Link to comment Share on other sites More sharing options...
+adamantyr Posted January 8, 2018 Share Posted January 8, 2018 You're actually doubling your usage with that approach. If you want to be as efficient as possible, you either: Store your text in DATA statements and READ them into a single static string only as needed. This requires copious use of RESTORE commands to point to the right location to read text from Store all your text on disk and read them into string arrays at the start of the program If you are already seeing half the stack burned with only 1/3 of your actual data complete, that means you may not have enough space for it using a single method. You could use both methods though to share the load between the two memory types. Quote Link to comment Share on other sites More sharing options...
Opry99er Posted January 8, 2018 Author Share Posted January 8, 2018 Sorry, the formatting got screwy and it dropped half my post off. I sort of fixed it now Quote Link to comment Share on other sites More sharing options...
Opry99er Posted January 8, 2018 Author Share Posted January 8, 2018 You're actually doubling your usage with that approach. If you want to be as efficient as possible, you either: Store your text in DATA statements and READ them into a single static string only as needed. This requires copious use of RESTORE commands to point to the right location to read text from Store all your text on disk and read them into string arrays at the start of the program If you are already seeing half the stack burned with only 1/3 of your actual data complete, that means you may not have enough space for it using a single method. You could use both methods though to share the load between the two memory types. I think I can absorb more of a hit to my PROGRAM space at this point than STACK. I may need to re-think the extent of detail in the text. Quote Link to comment Share on other sites More sharing options...
Opry99er Posted January 8, 2018 Author Share Posted January 8, 2018 One nice feature of my DATA is the padding. Each segment of data takes up 9 DATA statements. I need only offset the RESTORE by that many statements in order to retrieve the correct information. The question is, can I GOTO A... where A is a variable containing a line number. I havent tested it yet, but Im sure we could find a way to skin that cat. Quote Link to comment Share on other sites More sharing options...
Willsy Posted January 9, 2018 Share Posted January 9, 2018 You don't need to place your strings in arrays, they're already in memory as data statements. Why have them in memory twice? Quote Link to comment Share on other sites More sharing options...
Opry99er Posted January 9, 2018 Author Share Posted January 9, 2018 (edited) Perhaps someone with access to a terminal could try it out for me? 10 CALL CLEAR 20 A=100 30 GOTO A 40 ON ERROR PRINT FAIL 50 END 100 PRINT SUCCESS 110 END Edited January 9, 2018 by Opry99er Quote Link to comment Share on other sites More sharing options...
Opry99er Posted January 9, 2018 Author Share Posted January 9, 2018 You don't need to place your strings in arrays, they're already in memory as data statements. Why have them in memory twice? Yes sir... I have two options... put them in arrays (drawn from disk) or use DATA statements to house the data. Im trying to find the best way to accomplish the goal. Quote Link to comment Share on other sites More sharing options...
Opry99er Posted January 9, 2018 Author Share Posted January 9, 2018 10 CALL CLEAR 20 A=100 30 GOTO A 40 ON ERROR PRINT FAIL 50 END 100 PRINT SUCCESS 110 END It keeps taking the quotations out of my PRINT statements for some reason... Quote Link to comment Share on other sites More sharing options...
+adamantyr Posted January 9, 2018 Share Posted January 9, 2018 You can't GOTO or GOSUB based on variables. Use an ON GOTO command with a list of RESTORE statements. Quote Link to comment Share on other sites More sharing options...
Opry99er Posted January 9, 2018 Author Share Posted January 9, 2018 (edited) Wow.. that method will eat up a ton of space with 36 data sets. But it probably (sadly) is the most efficient way. Appreciate the tip. Edited January 9, 2018 by Opry99er Quote Link to comment Share on other sites More sharing options...
+InsaneMultitasker Posted January 9, 2018 Share Posted January 9, 2018 If you can take the hit to the stack, loading the data from disk is a good option. Quote Link to comment Share on other sites More sharing options...
Opry99er Posted January 9, 2018 Author Share Posted January 9, 2018 (edited) Thats what I am hoping to do... but I dont think the stack will be able to withstand the onslaught of data. Im going to try though. Adams suggestion will likely be my only option, but Im going to try to load the text data in one big WHAM from disk and cross my fingers. Edited January 9, 2018 by Opry99er Quote Link to comment Share on other sites More sharing options...
+TheBF Posted January 9, 2018 Share Posted January 9, 2018 Thats what I am hoping to do... but I dont think the stack will be able to withstand the onslaught of data. Im going to try though. Adams suggestion will likely be my only option, but Im going to try to load the text data in one big WHAM from disk and cross my fingers. It's been 30 something years but I know I built a pretty big application on TI-BASIC that used a database of information and I could read the records from disk with just an record number. (it even used a binary search for find key strings in the records. :-) You should have heard the old disk drives chunking!) Couldn't you make a separate program that creates all your text on a file and then the final program can pull them in by record number, like you would in an array, and print them to the screen? That way you only have the strings in memory that you need to display at the time. Am I missing something else important? 1 Quote Link to comment Share on other sites More sharing options...
Opry99er Posted January 9, 2018 Author Share Posted January 9, 2018 No... only that if I pull data from an external source, I can only do it once. This program is being designed to run from tape, so record access is tough and limited. I want to load the program into memory, then hit a big record pull from cassette all at once to populate the arrays... Or, as has been suggested, keep all records in DATA statements and access them as needed using RESTORE. Quote Link to comment Share on other sites More sharing options...
Opry99er Posted January 9, 2018 Author Share Posted January 9, 2018 Had some success! I was able to put all the data into a data file and pull it all in one clean shot. It leaves me with only 2K of stack space left, but I think that is okay. I need to learn the size limits of data files that can be pulled from CS1, because my current data file is a hair over 9K. The main program is now less than 2K, but that will grow significantly now that I have some headroom. Thanks for the suggestions, folks. Quote Link to comment Share on other sites More sharing options...
+TheBF Posted January 9, 2018 Share Posted January 9, 2018 No... only that if I pull data from an external source, I can only do it once. This program is being designed to run from tape, so record access is tough and limited. I want to load the program into memory, then hit a big record pull from cassette all at once to populate the arrays... Or, as has been suggested, keep all records in DATA statements and access them as needed using RESTORE. AH... I missed the Cassette component. Serial access only. Quote Link to comment Share on other sites More sharing options...
Willsy Posted January 9, 2018 Share Posted January 9, 2018 It's time to buy Buck a PEB, papa! ? Quote Link to comment Share on other sites More sharing options...
Opry99er Posted January 9, 2018 Author Share Posted January 9, 2018 (edited) Lol!!! Weve got PEBs... This is primarily a Because its There deal. There will be no official or unofficial release for diskette. If this thing comes together as planned, youll either need a modem or a cassette player to play it. Edited January 9, 2018 by Opry99er Quote Link to comment Share on other sites More sharing options...
Opry99er Posted January 9, 2018 Author Share Posted January 9, 2018 Why is Atariage erasing all my quotation marks around words or phrases? Hmmm.... Quote Link to comment Share on other sites More sharing options...
senior_falcon Posted January 10, 2018 Share Posted January 10, 2018 (edited) Why is Atariage erasing all my quotation marks around words or phrases? Hmmm.... Hi Opry: "You can have all the quotes you want. Click on the <> icon and you can paste in code or, for that matter type it in as I am doing now." 10 PRINT "HELLO WORLD" Edited January 10, 2018 by senior_falcon Quote Link to comment Share on other sites More sharing options...
Opry99er Posted January 10, 2018 Author Share Posted January 10, 2018 Test Quote Link to comment Share on other sites More sharing options...
Opry99er Posted January 10, 2018 Author Share Posted January 10, 2018 Hmm.... it appears my mobile version doesnt play nicely... Test with code tags... Test Quote Link to comment Share on other sites More sharing options...
Opry99er Posted January 10, 2018 Author Share Posted January 10, 2018 Even inside the code tags it isnt working. Might need to switch to desktop version to figure it out Quote Link to comment Share on other sites More sharing options...
sometimes99er Posted January 10, 2018 Share Posted January 10, 2018 Test your www.Opry99er.com too. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.