Announcement

Collapse
No announcement yet.

Price based on width and height

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Price based on width and height

    Hello,

    I want to implement the code on a project made in Autoplay Media Studio:

    //Declare a multidimensional array to store the values.
    //A struct would work better.

    int sizes[][] = new int[10][2];
    sizes[0][0] = 100000; //Minimal area size
    sizes[0][1] = 0.00056; //Price per unit.

    sizes[1][0] = 200000;
    sizes[1][1] = 0.00061;
    //Repeat for all values

    //Calculate dimensions
    int width = 200;
    int height = 800;
    int surface = width * height;

    int foundArea;
    while(int i < sizes.size(); i++)
    {
    //Check where the value belongs in the array
    if(surface =< sizes[i][0])
    {
    foundArea = i;
    break;
    }
    }

    //Finally get the size
    int price = sizes[foundArea][1] * surface;

    The thing is, that i have alot of erros, and i don't know how to implement this code.
    I want to do something like this, to implement on this project.
    If someoane can help, it will be amazing! Thank you!

  • #2
    Code:
    [font=Courier New][size=2][color=#0000FF][b]local[/b][/color] sizes [color=#FF0000]=[/color] [color=#FF0000]{[/color][color=#FF0000]}[/color];
    
    sizes[color=#FF0000][[/color][color=#FF6600]0[/color][color=#FF0000]][/color]    [color=#FF0000]=[/color] [color=#FF0000]{[/color][color=#FF0000]}[/color];
    sizes[color=#FF0000][[/color][color=#FF6600]0[/color][color=#FF0000]][/color][color=#FF0000][[/color][color=#FF6600]0[/color][color=#FF0000]][/color] [color=#FF0000]=[/color] [color=#FF6600]100000[/color];
    sizes[color=#FF0000][[/color][color=#FF6600]0[/color][color=#FF0000]][/color][color=#FF0000][[/color][color=#FF6600]1[/color][color=#FF0000]][/color] [color=#FF0000]=[/color] [color=#FF6600]0.00056[/color];
    
    sizes[color=#FF0000][[/color][color=#FF6600]1[/color][color=#FF0000]][/color]    [color=#FF0000]=[/color] [color=#FF0000]{[/color][color=#FF0000]}[/color];
    sizes[color=#FF0000][[/color][color=#FF6600]1[/color][color=#FF0000]][/color][color=#FF0000][[/color][color=#FF6600]0[/color][color=#FF0000]][/color] [color=#FF0000]=[/color] [color=#FF6600]200000[/color];
    sizes[color=#FF0000][[/color][color=#FF6600]1[/color][color=#FF0000]][/color][color=#FF0000][[/color][color=#FF6600]1[/color][color=#FF0000]][/color] [color=#FF0000]=[/color] [color=#FF6600]0.00061[/color];
    
    [color=#0000FF][b]local[/b][/color] width [color=#FF0000]=[/color] [color=#FF6600]200[/color];
    [color=#0000FF][b]local[/b][/color] height [color=#FF0000]=[/color] [color=#FF6600]800[/color];
    [color=#0000FF][b]local[/b][/color] surface [color=#FF0000]=[/color] width [color=#FF0000]*[/color] height;
    
    [color=#0000FF][b]local[/b][/color] foundArea;
    [color=#0000FF][b]local[/b][/color] price;
    
    [color=#0000FF][b]for[/b][/color] i [color=#FF0000]=[/color] [color=#FF6600]0[/color][color=#FF0000],[/color] [url=http://umodel.narod.ru/webhelp/ams/Program_Reference/Actions/Table/Table.Count.htm][color=#000000]Table[/color][color=#FF0000].[/color][color=#000000]Count[/color][/url](sizes) [color=#FF0000]-[/color] [color=#FF6600]1[/color] [color=#0000FF][b]do[/b][/color]
        [color=#0000FF][b]if[/b][/color] (surface [color=#FF0000]<[/color][color=#FF0000]=[/color] sizes[color=#FF0000][[/color]i[color=#FF0000]][/color][color=#FF0000][[/color][color=#FF6600]0[/color][color=#FF0000]][/color]) [color=#0000FF][b]then[/b][/color]
            foundArea [color=#FF0000]=[/color] i;
            [color=#0000FF][b]break[/b][/color];
        [color=#0000FF][b]end[/b][/color]
    [color=#0000FF][b]end[/b][/color]
    
    [color=#0000FF][b]if[/b][/color] foundArea [color=#0000FF][b]then[/b][/color] price [color=#FF0000]=[/color] sizes[color=#FF0000][[/color]foundArea[color=#FF0000]][/color][color=#FF0000][[/color][color=#FF6600]1[/color][color=#FF0000]][/color] [color=#FF0000]*[/color] surface; [color=#0000FF][b]end[/b][/color]
    
    [url=http://umodel.narod.ru/webhelp/ams/Program_Reference/Actions/Dialog/Dialog.Message.htm][color=#000000]Dialog[/color][color=#FF0000].[/color][color=#000000]Message[/color][/url]([color=#800080]""[/color][color=#FF0000],[/color] price[color=#FF0000],[/color] MB_OK[color=#FF0000],[/color] MB_ICONINFORMATION[color=#FF0000],[/color] MB_DEFBUTTON1);[/size][/font]

    Comment


    • #3
      I'm trying to create a excel sheet which will automatically calculate a price based on a given width or height. At the moment we calculate price by manually looking in a price book which has plenty of rows and columns and prices. I want to simplify this by simply entering the dimensions so it automatically calculates price based on the dimensions entered.
      you enter width of 1500mm in one field, then 900mm in another field, and next to that it automatically shows the price (based on some price list on another spreadsheet or workbook).

      Here is an example price list:


      So, after entering the width and height, the price is automatically found:


      So the problem is how to determine the price based on the two separate dimensions (width & height) in autoplay media studio???

      in Excell 2007 i have the Worksheet Formulas:

      Cell Formula
      D19 =INDEX(Sheet1!$A$3:$F$8,MATCH(C19,Sheet1!$A$3:$A$8 ,0),MATCH(B19,Sheet1!$A$3:$F$3,0))
      D20 =INDEX(Sheet1!$A$3:$F$8,MATCH(C20,Sheet1!$A$3:$A$8 ,0),MATCH(B20,Sheet1!$A$3:$F$3,0))
      D21 =INDEX(Sheet1!$A$3:$F$8,MATCH(C21,Sheet1!$A$3:$A$8 ,0),MATCH(B21,Sheet1!$A$3:$F$3,0))

      Comment

      Working...
      X