CONFIGSECTIONS        Load a list of all sections in a configuration file

<< Click to Display Table of Contents >>

Navigation:  Robo-FTP User's Guide > Script Programming > Script Commands > All Script Commands >

CONFIGSECTIONS        Load a list of all sections in a configuration file

Syntax:

CONFIGSECTIONS

[ file name ] [ variable name ]

Arguments:

[ file name ]

Variable or string defining the configuration file to open.

 

[ variable name ]

Variable to assign results.

Options:

none

 

 

 

Use this script command to read in and store the names of the sections in a configuration file. It creates a zero-based array where each array element is set to the name of each section.

 

This command is for working with external configuration files. This can not be used for reading values from Robo-FTP's internal settings files.

 

For example, let's say you have the following configuration file in the current working directory named "my_config.ini."

 

[My First Section]

a_setting = some value

another_setting = some other value

[My Second Section]

a_setting = some value

another_setting = some other value

[My Third Section]

a_setting = some value

another_setting = some other value

 

You can load the section headings into a variable with the following command:

 

CONFIGSECTIONS "my_config.ini" my_sections

DISPLAY my_sections[*] ;; Set to the number of sections (3 in this case)

DISPLAY my_sections[0] ;; Set to 'My First Section'

DISPLAY my_sections[1] ;; Set to 'My Second Section'

DISPLAY my_sections[2] ;; Set to 'My Third Section'

 

If a configuration file has settings at the top that are not under a section heading, Robo-FTP will create an element in the array for that unnamed section and set it to an empty string. For example:

 

property_not_under_a_section = a value

[First Section]

first_property = some value

second_property = some other value

 

In this case, the same sample code will yield the following results:

 

CONFIGSECTIONS "my_config.ini" my_sections

DISPLAY my_sections[*] ;; Set to the number of sections (2 in this case)

DISPLAY my_sections[0] ;; Set to '' (an empty string)

DISPLAY my_sections[1] ;; Set to 'First Section'

 

Related command(s): CONFIGLOAD

See also: Working with External Configuration Files, Arrays