The scale function is nothing more than the equation of a line y=mx+b where m is the slope and b is the y intercept. Y is your scaled value from 0 to 100. So, for an example, if your AI ranges from 0 to 32768 then you can calculate your slope. slope=rise over run so m=(32768-0)/(100/0)=327.68. If your analog in is zero when your reading is zero then b = 0. This gives you your equation of y=327.68*x+0. x is your AI and y is your scaled value.