mersenneforum.org Ubasic Array question
 Register FAQ Search Today's Posts Mark Forums Read

 2004-09-14, 06:11 #1 rn0dal   Sep 2004 416 Posts Ubasic Array question How do I store all the numbers from 0 to 1000,in an array?thanks a lot for your time. Last fiddled with by rn0dal on 2004-09-14 at 06:12
2004-09-14, 08:34   #2
jocelynl

Sep 2002

10616 Posts

Quote:
 Originally Posted by rn0dal How do I store all the numbers from 0 to 1000,in an array?thanks a lot for your time.
Dim a(1000)
for x=0 to 1000
a(x)=x
next

use the help starter to get help
ubh.bat

Joss

Last fiddled with by jocelynl on 2004-09-14 at 08:35

 2004-09-14, 14:57 #3 rn0dal   Sep 2004 22 Posts Thanks a lot for your help,now one more question,lets say I want that array to be, (the number the user enters) - 2.How would I do that? could it be like this? 10 input "Last Number";x 20 p=0 30 Dim m(x-2) 40 For I = 2 to x 50 m(p) = I 60 p = p + 1 70 next I the reason why i aked it becuase I did not find an example about it. Last fiddled with by rn0dal on 2004-09-14 at 14:58
 2004-09-14, 20:13 #4 Uncwilly 6809 > 6502     """"""""""""""""""" Aug 2003 101×103 Posts 3×7×19×23 Posts You should be able to eliminate p. Assuming you want x-2 elements and each element m(z) to be equal to z+2, try this: Code: 10 input "Last Number";x 30 Dim m(x-2) 40 For i = 2 to x 50 m(i-2) = i 70 next i m(0)=2 m(1)=3 ...... m(x)=x+2 My arrays are a bit rusty, but each extra step you get rid of (and counters that are doing the same steping, like p & i), speeds things along.
 2004-09-14, 22:40 #5 rn0dal   Sep 2004 22 Posts it gives me this error: Variable area full. in 20 Thats why I asked the question.thanks a lot for your time, and for the tip (i-2). -r
 2004-09-14, 23:49 #6 rn0dal   Sep 2004 416 Posts Never mind last post, how can increase the range?so i can enter a big number,you know so I can enter the bigest number allowed by UBASIC, I dont know maybe there is a way of declaring the array so it can get bigger than 300, I want to be able to use the biggest posible number.thanks a lot for your time.
 2004-09-15, 14:57 #7 jocelynl   Sep 2002 2·131 Posts Ubasic use a stack of 65536 The dim can't be larger than 32768 * 2 words for small integers dim x%() when not using the % Ubasic use 542 words to store each numbers you can reduce the number of words used by ubasic in help look under (word) Joss

 Similar Threads Thread Thread Starter Forum Replies Last Post ewmayer Linux 29 2018-03-08 21:42 Sam Kennedy Programming 1 2012-12-25 23:25 Andi47 Programming 7 2009-02-27 00:20 Andi47 Programming 5 2008-12-28 05:52 Citrix Programming 2 2005-08-21 20:06

All times are UTC. The time now is 08:31.

Sat Jan 16 08:31:20 UTC 2021 up 44 days, 4:42, 0 users, load averages: 2.47, 2.11, 1.89