Generate a data list

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
andaluza
Newbie
Posts: 2
Joined: Fri Mar 14, 2008 7:12 am

Generate a data list

Post by andaluza » Fri Mar 14, 2008 7:36 am

I'm trying to generate a data list, introducing values to a variable, and after obtain the number of data list and their values. For example, if we introduce values for X = 100, 200 and 300, we want get "Number of data = 3 and values x1=100, x2=200 and x3=300"

I know that's a simple question, but I need a clear solution to continue with simple macros.

Thanks

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri Mar 14, 2008 8:15 am

So you want:

- An array of numbers
- A function which returns the first n elements of the array

Correct?

Before I write code I want to be clear on what you are asking for.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

andaluza
Newbie
Posts: 2
Joined: Fri Mar 14, 2008 7:12 am

Post by andaluza » Fri Mar 14, 2008 8:58 am

Exactly. Thank you for you attention

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri Mar 14, 2008 9:15 am

This is just an example. It creates an array of numbers from 100-1000 stepped by 100. It then asks the user how many numbers you want to retrieve and returns that many from the top of the array and displays in a string.

Code: Select all

//Create an array of numbers 100 to 1000 step by 100
Let>thenumber=0
Let>index=0
Repeat>index
  Let>index=index+1
  Let>thenumber=thenumber+100
  Let>MyArray_%index%=thenumber
Until>index=100

//Ask user how many numbers you want to get
Input>num,Enter how many numbers you want to return:
Let>x=0
Let>myString=
Repeat>x
  Let>x=x+1
  Let>this_number=MyArray_%x%
  Let>myString=%myString% x%x%=%this_number%;
Until>x=num

MessageModal>myString
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts