MegaLoop for my script?

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Daross
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 23
Joined: Thu Jun 04, 2009 8:15 pm

MegaLoop for my script?

Post by Daross » Sat May 08, 2010 11:10 am

I build a stack to create a report with the optimization of circuits with respect to the length and number of circuits (or parts).
In practice, the script must create the best combination of the circuit to select the coil with less waste.
I started with tablefield "Circuit" (where I put the ID and length of circuits) tablefield a "Coil" (where I put the length of the coils I have available)
and a field "Report" where I read the results (of course I created the report in attach. with hand! :D )

Any idea how can I do?

Thanks in advance

Davide
Attachments
Schermata 2010-05-08 a 11.58.35.png
Schermata 2010-05-08 a 11.58.35.png (57.6 KiB) Viewed 3853 times

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: MegaLoop for my script?

Post by Mark » Sat May 08, 2010 9:18 pm

Hi Davide,

What exactly is your question?

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Daross
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 23
Joined: Thu Jun 04, 2009 8:15 pm

Re: MegaLoop for my script?

Post by Daross » Tue May 11, 2010 4:12 pm

Mark,

I need help on how to write the algorithm with Rev. Until now I have written small applications, and create this script is hard for me.

The script should create groups of combinations (in relation to the total length of the coils in the field “coils") summing the item 2 of the field "Circuit" and the script must prefer the combination with less waste (see field “Report”)

I do not know if what I said is clear now..

Thanks.

Davide

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: MegaLoop for my script?

Post by dunbarx » Tue May 11, 2010 4:50 pm

I wrote a quick script that should show the way. I assumed you have your data in a field called "rawdata", and that the data contains both the ID and the length, one pair on each line separated with a comma. Not sure how optimal this is, and I only dealt with the 500 foot spools:

Code: Select all

on mouseUp
   Put fld "rawdata" into rawData
   put 0 into spools
   Sort rawData by item 2 of each
   
   repeat until the number of lines of rawdata = 0
      put 0 into balance
      add 1 to spools
      repeat with y = the number of lines of rawData down to 1
         if item 2 of line y of rawData + balance < 500 then
            add item 2 of line y of rawData to balance
            delete line y of rawData
         else
            next repeat
         end if
      end repeat
   end repeat
   
   answer spools
end mouseUp

Post Reply