Liberty BASIC Community Forum
« Graphicbox code reduction ... HELP!!! »

Welcome Guest. Please Login or Register.
Apr 28th, 2017, 4:49pm


Rules|Home|Help|Search|Recent Posts|Notification


« Previous Topic | Next Topic »
Pages: 1 2 3  Notify Send Topic Print
 veryhotthread  Author  Topic: Graphicbox code reduction ... HELP!!!  (Read 707 times)
BeeTrap
New Member
Image


member is offline

Avatar




PM


Posts: 4
xx Re: Graphicbox code reduction ... HELP!!!
« Reply #30 on: Apr 20th, 2017, 08:08am »

I apologize to all for getting into "Turtleman's" question. Since this thread is not "active" I would like to thank Rod and Turtleman. Per your Reply #16, I did rewrite my program using the 2-DIM array. I was worried that adding the extra code to "handle" this array would actually add to the size of my program. But, once completed I compared the original to the new version, with ALL Remarks " ' lines " removed and went from 30KB to 26KB. Also the code just looks better. So I thank Turtleman for asking the question that got me started and Rod for pointing this out to me.
User IP Logged

Turtleman
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 161
xx Re: Graphicbox code reduction ... HELP!!!
« Reply #31 on: Apr 21st, 2017, 05:23am »

I want to publicly thank Rob for all the help he's provided over the years and particularly the past couple of months on this board and via emails. His suggestions and examples have been nothing short of tremendous and are most appreciated. smiley

Not wanting to take further advantage of his generosity, I'm posting my latest roadblock in case anyone else can offer suggestions. In particular, I'm trying to reduce the amount of redundant code and possibly even program correctly for a change. For example, I'm using the following code to read the contents of a dozen textboxes having consecutively numbered variables:

#tab3.w1, "!contents? w1"
#tab3.w2, "!contents? w2"
and so on to
#tab3.w12, "!contents? w12"

My feeble attempts at assigning a handle to an array and using FOR / NEXT so far haven't worked and I could sorely use an example showing how to go about it. Likewise, I suspect there's a more efficient way of writing the contents of the textboxes to a file than listing each line separately:

print #5, w1
print #5, w2
and so on to
print #5, w12

I've been frequenting this novice section for years and doubt I'll ever evolve into a more advanced programmer, but I'm trying. Thanks for everyone's kind assistance!
User IP Logged

Rod
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Graphics = goosebumps!


PM

Gender: Male
Posts: 5251
xx Re: Graphicbox code reduction ... HELP!!!
« Reply #32 on: Apr 21st, 2017, 07:09am »

This should be all you need.

Code:
for t= 1 to 12
    'create the #handle variable
    h$="#tab3.w"+str$(t)
    'get the textbox contents using the handle variable
    'save those contents to intermediate variable w
    #h$ "!contents? w"
    'now store it in the array
    w(t)=w
next

'open the file
'printing from the array is simpler than the textboxes
for t = 1 to 12
    #5 w(t)
next
 
User IP Logged

Turtleman
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 161
xx Re: Graphicbox code reduction ... HELP!!!
« Reply #33 on: Apr 21st, 2017, 09:21am »

Thanks so much. I was very close on the reading the contents of the textboxes and had exactly the same code for writing; but as we all know, "close" doesn't count. I now see that a large portion of my program's nearly 17K lines of code can be drastically streamlined, which is almost like starting over. As Rob has educated me, I need to stop using static variables in favor of arrays.

Back later right now I have a tremendous amount of code to clean up! Thanks again!!!!
User IP Logged

Pages: 1 2 3  Notify Send Topic Print
« Previous Topic | Next Topic »

Rules|Home|Help|Search|Recent Posts|Notification

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls