[SOLVED] Enumerated variables: increment and set lazarus / 61-Beginners ---------------------------------------------------------------------- tudi_x · 2017-11-02 12:43 hi All, i just started to work with enumerated variables. for the code below and attached i am trying to increment the value of the s variable and set the t variable one step backwards of s. please help with how i could do this. thank you Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit main; {$mode objfpc}{$H+} interfaceuses  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls; type  TStatus = (action_1, action_2, action_3, action_4, action_5); type  TForm1 = class(TForm)    Button1: TButton;    Memo1: TMemo;    procedure Button1Click(Sender: TObject);  end; var  Form1: TForm1; implementation {$R *.lfm} procedure TForm1.Button1Click(Sender: TObject);var  s: TStatus;  t: TStatus;   //one action before action s  r: string; begin  s:= action_4;   //how can i increment s to action 5?  how can i set t to action 4?  writestr(r, s);  Memo1.Append(r);  Memo1.Append(inttostr(ord(s)));end; end. ---------------------------------------------------------------------- howardpc · 2017-11-02 12:58 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.Button1Click(Sender: TObject);var  s: TStatus;  t: TStatus;   //one action before action s  r: string;begin  s := action_4;  writestr(r, s);  Memo1.Append(Format('s=%s (%d)',[r, Ord(s)]));  //how can i increment s to action 5?  how can i set t to action 4?  t:=s;   if s < High(TStatus) then      s:=Succ(s);  writestr(r, s);  Memo1.Append(Format('after s:=Succ(s), s=%s (%d)',[r, Ord(s)]));   writestr(r, t);  Memo1.Append(Format('after t:=s, t=%s (%d)',[r, Ord(t)]));end; ---------------------------------------------------------------------- tudi_x · 2017-11-02 13:17 thank you! without involving s, is there a way to just set t to value 3 (action_4)? ---------------------------------------------------------------------- tudi_x · 2017-11-02 14:01 I updated the wiki at: http://wiki.lazarus.freepascal.org/Enumerated_types ---------------------------------------------------------------------- howardpc · 2017-11-02 16:26 Quote from: tudi_x on November 02, 2017, 02:17:29 pmwithout involving s, is there a way to just set t to value 3 (action_4)? either Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i t := action_4;or Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i t := TStatus(3);