Set decimal [decFreq] value to 1.1 (save value to profile)
Set integer [intRange] value to 1 (save value to profile)
Set decimal [decLat] value to 1.2 (save value to profile)
Set decimal [decLong] value to 1.3 (save value to profile)
Set text [txtStreamFile] to 'hello world' (save value to profile)
Write [Blue] '{DEC:decFreq}' to log
Write [Blue] '{INT:intRange}' to log
Write [Blue] '{DEC:decLat}' to log
Write [Blue] '{DEC:decLong}' to log
Write [Blue] '{TXT:txtStreamFile}' to log
Set text [~textFile] to [C:\MSFS Utl\BostonRadio\Boston Radio Freq.txt]
Set integer [~targetLine] value to 2
Inline C# Function: , wait until execution finishes
Inline C# Function: , wait until execution finishes
Set text [txtStreamFile] to [Saved Value] (save value to profile)
Write [Blue] '"{TXT:~lineOutput}"' to log
Write [Blue] '{DEC:decFreq}' to log
Write [Blue] '{INT:intRange}' to log
Write [Blue] '{DEC:decLat}' to log
Write [Blue] '{DEC:decLong}' to log
Write [Blue] '{TXT:txtStreamFile}' to log
Inline C# Function: , wait until execution finishes (First one)
using System;
public class VAInline
{
public void main()
{
string input = VA.GetText("~textFile");
if (input == null)
{
VA.WriteToLog("Cannot get line, no file set", "red");
return;
}
int targetLine = VA.GetInt("~targetLine") ?? -1;
if (targetLine < 1)
{
VA.WriteToLog("Cannot get line, no or invalid line number set", "red");
return;
}
string[] lines = input.Split(new[] {Environment.NewLine}, StringSplitOptions.None);
if (targetLine > lines.Length)
{
VA.WriteToLog("Warning: Target line is " + targetLine + ", but the file only contains " + lines.Length + " lines", "orange");
return;
}
VA.SetText("~lineOutput", lines[targetLine - 1]);
/*
string[] substrings = VA.GetText("~lineOutput").Split(' ');
VA.SetDecimal("decFreq", decimal.Parse(substrings[0]));
VA.SetInt("intRange", int.Parse(substrings[1]));
VA.SetText("txtStreamFile", substrings[2]);
*/
}
}
Inline C# Function: , wait until execution finishes (second one)
using System;
public class VAInline
{
public void main()
{
string[] substrings = VA.GetText("~lineOutput").Split(' ');
VA.SetDecimal("decFreq", decimal.Parse(substrings[0]));
VA.SetInt("intRange", int.Parse(substrings[1]));
VA.SetDecimal("decLat", decimal.Parse(substrings[2]));
VA.SetDecimal("decLong", decimal.Parse(substrings[3]));
VA.SetText("txtStreamFile", substrings[4]);
// VA.SetText("txtStreamFile", substrings[2].Split('\n')[0]);
}
}
Sample Boston Radio Freq.txt
120.35 0 zbw_mpv.pls
121.1 0 kbtv_app.pls
123.75 0 zbw_gdm.pls
124.85 0 kbdl2_zbw_pvd_low.pls
124.9 0 kmht_murp_fitzy.pls
126.1 0 kack_app.pls
128.2 0 zbw_parso.pls
128.325 0 kalb1_zbw_cam39.pls
132.85 0 cyul_app.pls
134.7 0 zbw_con.pls
135.7 0 zbw_mpv.pls
125.1 1 42.79277778 71.52361111 kash_atis.pls
121.8 1 42.79277778 71.52361111 kash4_gnd.pls
133.2 1 42.79277778 71.52361111 kash4_twr.pls