Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 19:34 25 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : MMBasic data in subroutine?

Author Message
cwilt
Senior Member

Joined: 20/03/2012
Location: United States
Posts: 147
Posted: 02:17pm 18 Apr 2012
Copy link to clipboard 
Print this post

I was working with Data, Read, and Restore functions and trying to use it inside a subroutine and every time I did it would crash mmbasic. If I put the Data statements in the main code area it worked fine. Is this normal? Any way around it?
 
jman

Guru

Joined: 12/06/2011
Location: New Zealand
Posts: 711
Posted: 07:43pm 18 Apr 2012
Copy link to clipboard 
Print this post

Hi

The Data should NOT be in in your sub routine
The best place for the Data is at the bottom of your code
But of course you can place it anywhere
A better way to do it is create a "data file" on the SD
Then read the file into an array . This will use less code space

John
 
cwilt
Senior Member

Joined: 20/03/2012
Location: United States
Posts: 147
Posted: 08:42pm 18 Apr 2012
Copy link to clipboard 
Print this post

  jman said   Hi

The Data should NOT be in in your sub routine
The best place for the Data is at the bottom of your code
But of course you can place it anywhere
A better way to do it is create a "data file" on the SD
Then read the file into an array . This will use less code space

John


Hello John. Thanks for the reply.

This sub routine is being used like a library for accessing an external device via SPI interface. Having the Data outside of the routine is not convenient. Storing the data in a file and then loading an array is a possibility but not the best way in my opinion.

Data stored in the routine is the way I wanted it to work but you say it won't so I may look at other methods.

Kind regards,
Charles
 
cwilt
Senior Member

Joined: 20/03/2012
Location: United States
Posts: 147
Posted: 11:34pm 18 Apr 2012
Copy link to clipboard 
Print this post

Update....

Loaded released version of 3.2 for UBW32 and problem solved.
Got the data inside my sub routine for a nice compact library.

Thanks again.
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024