LumpClose: Difference between revisions

Add example
(Created page with "{{ACSWarning}}{{DevfeatureWarning|version=3.2|type=an ACS function}} void '''LumpClose'''(int ''lump'') {{Devfeature|3.2|alpha}} ==Usage== Closes the specified lump which has been opened with <code>LumpOpen</code>. This function frees the internal handler that was created with <code>LumpOpen</code> and should always be called when finished with the lump to avoid issues. ===Parameters=== *''lump'': The lump index as returned from <code>LumpOpen</code>. ==...")
Tag: Source edit
 
(Add example)
Line 2: Line 2:
void '''LumpClose'''(int ''lump'') {{Devfeature|3.2|alpha}}
void '''LumpClose'''(int ''lump'') {{Devfeature|3.2|alpha}}
==Usage==
==Usage==
Closes the specified lump which has been opened with <code>[[LumpOpen]]</code>.
Closes the specified lump which has been opened with [[LumpOpen]].
 
This function frees the internal handler that was created with [[LumpOpen]] and should always be called when finished with the lump to avoid issues.
=== Parameters===
*''lump'': The lump index as returned from [[LumpOpen]].


This function frees the internal handler that was created with <code>[[LumpOpen]]</code> and should always be called when finished with the lump to avoid issues.
===Parameters===
*''lump'': The lump index as returned from <code>[[LumpOpen]]</code>.
==Examples==
==Examples==
{{noexamples}}
<syntaxhighlight lang="js" line="1">
// This script prints the lump index of all the `MAPINFO` lumps that can be found.
// `CLIENTSIDE` is optional.
Script 1 OPEN CLIENTSIDE
{
int startIndex = -1;
Log(s:"Collecting MAPINFO lumps.");
while(true)
{
startIndex = LumpOpen("MAPINFO", startIndex + 1);
if (startIndex == -1)
{
Log(s:"No more MAPINFO lumps found.");
break;
}
Log(s:"Next MAPINFO lump was found at index ", d:startIndex, s:".");
 
// At this point you can read its contents with either `LumpRead` or `LumpReadString`.
 
// Make sure to close the lump again to free the handle.
LumpClose(startIndex);
}
}
</syntaxhighlight>
 
==See also==
*[[LumpOpen]]
*[[LumpRead]]
*[[LumpReadArray]]
*[[LumpReadString]]
*[[LumpGetInfo]]