Licencia de Creative Commons
This tutorial is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.

 

SC PASCAL: WORKING WITH *.INI FILES

INI files are very useful when we work with scripts and we have to change some values in it, for example:

  • the name of SimIO cards
  • the value for analogue inputs (potentiometers): two different pots will give different values on the same position
  • the values for servo motors: two different servo motors will reach different positions with the same order
  • ...

 

 

As an example, we will see how to set a general name for an USB card in the script, and define the exact name in the INI file. Displays_INI.ini file is placed in the "projects" folders of SC Pascal and would be:

[General]

; set your USB boards accordingly with the boards
; installed in your system.

Main_Board_1=SIMIO000085
Servo_Board_1=SIMIO000025

; set your expansion boards addresses accordingly
; with the boards addresses list. For example,
; Displays card ID 3 with binary address 100010
; would be: Displays_Board_3=SIMIO*****-EXT17

64In_Board_1=SIMIO000085-EXT0
64Out_Board_1=SIMIO000085-EXT5
32In32Out_Board_1=SIMIO000085-EXT10
Displays_Board_1=SIMIO000085-EXT15
Displays_Board_2=SIMIO000085-EXT16

 

 

The use of the INI file in the SC Pascal script would be:


PROGRAM Displays_using_INI_files;


const
OFFSET_HDG=105;

var
file_ini:string;
Main_Board_1:string;
Displays_Board_2:string; //Displays card with address 000010


procedure OnEncoderChange(id_encoder,value:integer);
begin
end;

//IOCP EVENTs
procedure OnIOCPConnect(socket:byte);
begin
   RegIOCPOffset(1,OFFSET_HDG);
end;

procedure OnIOCPConnectClosed(socket:byte);
begin
end;

procedure OnIOCPConnectFail(socket:byte);
begin
end;

procedure OnIOCPChangeSyncro(socket,offset:byte;value:integer);
begin
end;

procedure OnIOCPChange(socket,offset:byte;value:integer);
begin

   //WriteDisplaysSwap('SIMIO000085-EXT16',4,inttostr(value),'0',3,0); This would be the code without INI file
   WriteDisplaysSwap(Displays_Board_2,4,inttostr(value),'0',3,0); //Value read from the INI file

end;

//MAIN
Begin
   file_ini:='Displays_INI.ini'; //INI file definition
   Displays_Board_2:=ReadINIFile(file_ini,'General','Displays_Board_2'); //We read the desired value from the INI file
   SetDisplayIntensity('Displays_Board_2',1,2); //Value read fron the INI file
End.

 

 

 

 

Last edited: 06.02.2018

 

Versión española

English version