Please enable JavaScript to view this site.

 

int = List_Count(sListVarName)

 

This macro function is used to get the number of elements of an existing list.

 

The macro below uses an override list of country names to replace the country names in the holidays table (this could be a bespoke list of country names, or the translation of country names into a different language). If no override name is found, then the default name from the table is used to build a list with all the overridden, or not, country names and their holidays set ID from the table. Here we use the function List_Count to decide if we need to look for overrides or, if the list is empty and we can just use the default names.

// load the list of country names override
List_LoadFromFile(sListCountryNameOverrides, sFileCountryNames, true)
List_Sort(sListCountryNameOverrides)
List_RemoveDuplicates(sListCountryNameOverrides)
nNumCountryOverrides = List_Count(sListCountryNameOverrides)
// make sure the list to be filled is empty
List_Clear(sListCountries)
// loop over the sets in the a-holidays
nSetIndexPos = 1
nSetID = GetNthHolSetId('a', nSetIndexPos)
while nSetID <> 0
    // only look for override if there are any overrides at all
    if nNumCountryOverrides > 0
        nIdxOverride = List_LocateName(sListCountryNameOverrides, IntToStr(nSetID))
     else
         nIdxOverride = 0
     endif
     // if an override name is found, then use it
    if nIdxOverride > 0
        sCurSetName = List_GetValue(sListCountryNameOverrides, nIdxOverride)
    else
        // otherwise use the deafult name in the table
        sCurSetName = GetHolSetNameOfId()
    endif
    // add the name found above to the new mixed list of country names
    List_Add(sListCountries, sCurSetName, nSetID)
    // move to next SET of the LIST
    nSetIndexPos = nSetIndexPos + 1
    nSetID = GetNthHolSetId(sCurHolList, nSetIndexPos)
endwhile
List_Sort(sListCountries)

When using lists, don't forget to always use the function List_Create to create your list at the top of the macro, and then the function List_Destroy to destroy it at the end of the macro.

 

See also: list macro functions.

 


Topic 178305, last updated on 18-Apr-2020