window settings

Metaconta 41 Reputation points
2022-03-17T05:20:24.347+00:00

Hello:

I have the code in C# and I want to adapt it in F#. What it does is configure the window in the console, enter a text and indicate its coordinate.

Some help?

C# code:

using System;

namespace Configuracion_ventanas_Consola_CS
{
    internal class Program
    {
        static void Main(string[] args)
        {
            #region window settings .
            // window title .
            Console.Title = "window title ";

            // Window size, x, y o, width and height. 
            const byte ancho = 80;
            const byte alto = 20;
            Console.SetWindowSize(ancho, alto);

            // Background color.
            Console.BackgroundColor = ConsoleColor.Black;

            // Color of the letters. 
            Console.ForegroundColor = ConsoleColor.Green;

            // Clear screen and leave everything in background color. 
            Console.Clear();

            // Cursor visible. 
            Console.CursorVisible = false;
            #endregion

            // Cursor position. 
            int anchoX = 20;
            int altoY = 8;
            Console.SetCursorPosition(anchoX, altoY);

            // Show texts. 
            Console.WriteLine("Estás leyendo este texto en pantalla. C#");

            // Press any key to exit. 
            Console.ReadKey();
        }
    }
}

A cordial greeting.

.NET F#
.NET F#
.NET: Microsoft Technologies based on the .NET software framework.F#: A strongly typed, multi-paradigm programming language developed by the F# Software Foundation, Microsoft, and open contributors.
92 questions
0 comments No comments
{count} votes

Accepted answer
  1. Bruce (SqlWork.com) 55,686 Reputation points
    2022-03-29T22:08:48.22+00:00

    simple convert:

    module Configuracion_ventanas_Consola_CS
    open System
    
    // window title .
    Console.Title = "window title "
    
    // Window size, x, y o, width and height. 
    let ancho = 80
    let alto = 20
    Console.SetWindowSize(ancho, alto)
    
    // Background color.
    Console.BackgroundColor = ConsoleColor.Black
    
    // Color of the letters. 
    Console.ForegroundColor = ConsoleColor.Green
    
    // Clear screen and leave everything in background color. 
    Console.Clear()
    
    // Cursor visible. 
    Console.CursorVisible = false
    
    // Cursor position. 
    let anchoX = 20
    let altoY = 8
    Console.SetCursorPosition(anchoX, altoY)
    
    // Show texts. 
    Console.WriteLine("Estás leyendo este texto en pantalla. C#")
    
    // Press any key to exit. 
    Console.ReadKey()
    
    0 comments No comments

0 additional answers

Sort by: Most helpful