Forum > LCL
Converting a constant to a variable
(1/1)
Pe3s:
Hi I have a code by @wp that draws a progress bar, in the code the constant MAX_COUNTER is used. My question is how to replace the constant MAX_COUNTER with an Integer variable. I tried but I get an error dividing by zero.
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.PaintBox1Paint(Sender: TObject);var R: TRect;begin Paintbox1.Canvas.Brush.Color := clWhite; Paintbox1.Canvas.Pen.Color := clBlack; Paintbox1.Canvas.Rectangle(0, 0, Paintbox1.Width, Paintbox1.Height); R := Rect(2, 2, Paintbox1.Width * FCounter div MAX_COUNTER -2, Paintbox1.Height -2); Paintbox1.Canvas.Brush.Color := RGB(169, 43, 79); Paintbox1.Canvas.FillRect(R);end;
paweld:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.PaintBox1Paint(Sender: TObject);var R: TRect; MAX_COUNTER_var: Integer;begin MAX_COUNTER_var := 75; Paintbox1.Canvas.Brush.Color := clWhite; Paintbox1.Canvas.Pen.Color := clBlack; Paintbox1.Canvas.Rectangle(0, 0, Paintbox1.Width, Paintbox1.Height); R := Rect(2, 2, Paintbox1.Width * 50 div MAX_COUNTER_var -2, Paintbox1.Height -2); Paintbox1.Canvas.Brush.Color := clYellow; Paintbox1.Canvas.FillRect(R);end;
Navigation
[0] Message Index