Help with 'slimming down' my program - Printable Version +- Qbasicnews.com (http://qbasicnews.com/newforum) +-- Forum: QBasic (http://qbasicnews.com/newforum/forum-4.html) +--- Forum: QB Discussion & Programming Help (http://qbasicnews.com/newforum/forum-11.html) +--- Thread: Help with 'slimming down' my program (/thread-773.html) Pages:
1
2
|
Help with 'slimming down' my program - NovaProgramming - 05-04-2003 Hey everybody... I am making an RPG and just recently it is saying something equivalent to: 'out of room' (I can't remember exactly what it said.) So, the help said to break it up into subroutines... well, I have a lot of SUBs, but would adding more SUBs make this help? Also... I know it is possible to DIM multiple variables like this DIM SHARED flag(10) AS INTEGER but is there some way to do this: DIM SHARED item(10) AS STRING and dim multiple things as strings? Any help would be appreciated. Help with 'slimming down' my program - Hard Rock - 05-04-2003 Quote:DIM SHARED item(10) AS STRING I just copied + pasted your code and it worked fine. So id assume yes. Quote:well, I have a lot of SUBs, but would adding more SUBs make this help? Also... I know it is possible to DIM multiple variables like this If you remove duplicated code by doing so then yes. If not then no. Yep - Meg - 05-05-2003 You can DIM string as follows: Code: DIM Text$(1 TO 10) Code: DIM Text(1 TO 10) AS STRING * n 'n = number of characters in each string To get rid of the "out of memory" error, you can put code into subroutines, and then put subroutines into modules. There are many tutorials on how to do this. Na_th_an wrote a good one that's floating around this forum someplace. Try the FAQ or doing a search for "modularize" and see what turns up. *peace* Meg. Help with 'slimming down' my program - toonski84 - 05-05-2003 the only thing you can't use varaible-length strings on is in type structures (though you can use fixed length ones). but yeah, as meg already said, modularize means to split up into files and include them into your program (you need the full version of qb to do this). Help with 'slimming down' my program - NovaProgramming - 05-05-2003 So does that mean that this would *not* work? Code: DIM SHARED item(10) AS STRING because if that would work I would be able to dramatically downsize the length of some of my code... I am using strings that take up a lot of space... item1$ item2$ ... item10$ so if this item(n)$ were to work it would make my life easier... thus I could do something like Code: for i = 1 to 10 Help with 'slimming down' my program - Aaron - 05-05-2003 actually, that code would work fine well - Meg - 05-05-2003 Yes, you can use arrays of strings. However, they look like this: Item$(n) not Item(n)$ *peace* Meg. ok - Meg - 05-05-2003 There are many ways in which you can cut down on the size of your code. I *HIGHLY* recommend putting all item-handling code into subroutines. If you are not sure how to do this, follow this: Code: DIM SHARED Inventory$(0 to 9) 'make a 10-item inventory that can be accessed by subroutines I hope this makes sense and that I don't have any typos/logic errors. Let me know if you have any questions. *peace* Meg. Help with 'slimming down' my program - Aaron - 05-06-2003 oops, Meg is right, I didn't even see that you had the type delineator on the wrong side of the subscript omg - Meg - 05-08-2003 Quote:oops, Meg is right, I didn't even see that you had the type delineator on the wrong side of the subscript Oh my. That comment just made me realize how much of a total dork I am. *peace* Meg. |