D
D
Dmitry Bravikov2016-06-11 10:59:06
Pascal
Dmitry Bravikov, 2016-06-11 10:59:06

What are the ways to change a local variable in Pascal?

I deal with someone else's source code in Pascal and came to a dead end.
I have a repeat until loop that should theoretically end when a variable has a certain value, but I can't find the place in the loop where that variable changes.
I do not write in Pascal, but rewrite the Pascal program in C ++, so there is no deep knowledge of Pascal.
I will give the code below.
We are talking about the variable N, it can take values ​​greater than 1. If it does not change in the cycle, then the cycle will be eternal, or until the Escape key is pressed.
In the assembled program, the cycle ends without Escape. Although, I do not use my assembly, my hands have not yet reached, to self-assembly.

procedure s180t90(pause1,pause2,point,count:real);
var
  i, N, T, M, K, itmp:integer;
  b1: byte;
  data: word;
  p: float;
begin
  N:= trunc(point);
  T:= trunc(count);
    if N<1 then N:= 1;
    {if T>N then T:= 1;}
  K:= 9;
  M:= K*(N+1);
  i:=1;
    repeat
      NewTrackBar(msgSent);
      for i:= T to N do begin
        itmp:= i*K;
        TrackBar(itmp+1,M,msgSent);
        rod0;
        SendCommandb(commandX, itmp+2, M, msgSent);{X}

        p:=i*Pause1;
          if p<0 then p:=1;
        SetPausesuni1(p, pause2,CommandR, CommandF, CommandN, itmp+3, M, msgSent);


        ComShowOSC(trunc(pause2));{show osc-picture}
    {***BEGIN*ABORT******************}
          if ESC then begin
            AbortMeasure;
            Exit;
          end;
    {****END**ABORT******************}
        end;
      DeleteTrackBar;
    until N=1;
  rod1;{Now u can see osc-picture}
end;

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey, 2016-06-11
@alsopub

I would venture to guess that point is passed less than 1, so N is always 1.
Have you checked what values ​​N are before the loop is executed?

R
Roman Mirilaczvili, 2016-06-11
@2ord

A local variable in Pascal can be changed by a nested procedure/function, i.e. declared inside procedure s180t90. Also inline assembler and other tricks for direct work with memory, bypassing Pascal.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question