Assign CFD margin % in AFL

I would like to look up the margin % from a CSV file for any stock in my trading universe and apply it in my AFL for setting trade size position.

I am wanting to reduce position size if the margin % is too high, otherwise I run the risk of using up all of my available equity before reaching my maximum number of open trades permitted.
Testing so far has focused on the VarGet function but have not made any progress.
Here are some ASX (Australia) stock examples with margin rates for the CFD broker I use:
CBA:5
BPT:10
EQT:35
MEK:60
TOK:80

I want to lookup the margin % based on the stock that I am exploring and pass it to my exploration AFL. Can someone please provide a suitable AFL subroutine.

Thank you !

Hi,
I was intending to do some file lookup also so I put this together as a starting point.

function LookupMargin( FilePath, FileName, Symbol, Separator )
{
    Margin = -1;  // file or symbol not found
    fh = fopen( FilePath + FileName, "r" );
    if( fh )
    {
        while( NOT feof( fh ) )
        {
            Line = fgets( fh ); // read a line of text
            if( StrExtract( Line, 0, Separator ) == Symbol )
            {
                Margin = StrToNum( StrExtract( Line, 1, Separator ) );
                break;
            }
        }
	    fclose( fh );
    }
    return Margin;
}

FilePath = "C:\\Users\\YourUserName\\";  // path to your file
FileName = "CFDmargins.txt";
Symbol = "CBA";
Margin = LookupMargin( FilePath, FileName, Symbol, ':' );

Thank you for your response. I will give your code a go and come back if I have any further questions.
How did it perform ?