80 x 25 Text Editor

DOS specific questions.
exagonx
Posts: 110
Joined: Mar 20, 2009 17:03
Location: Italy
Contact:

80 x 25 Text Editor

Postby exagonx » Apr 27, 2018 14:14

Hello

I tryed to make a simple text editor for a micro machine where work with a 486 architecture, now this micro pc work with Linux Based OS, but for what I need to do I have to work with MS DOS 7.00, for make a little controller for LPT port, the software is complete and work correctly but some time I have to put some information and write other code for more instruction.

For now I use MSDOS Editor for all, Its possibile to make a same editor with FreeBASIC ? or make a text buffer like edit for transform to IDE or somenthing like geany but under MSDOS ?
MrSwiss
Posts: 2728
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: 80 x 25 Text Editor

Postby MrSwiss » Apr 27, 2018 15:29

exagonx wrote:For now I use MSDOS Editor for all, Its possibile to make a same editor with FreeBASIC ?
or make a text buffer like edit for transform to IDE or somenthing like geany but under MSDOS ?
Last things first: you can but, I wouldn't (takes up, far to much time/effort).
I'd write a few .bat files (for CLI compiler call's, with the most used switches).

To write code, I'd stick with the current Editor.

Re: putting messages to console ... (position / color etc.)
I've made a Sub, that handles, all console related 'output':

Code: Select all

' ShowStr_Sub-test.bas -- 2018-04-25, MrSwiss.
'
' compile: -s console -exx -w pedantic (NO warnings/errors! for test only)
'
Declare Sub ShowStr(ByVal row As UByte = 1, ByVal col As UByte = 1, ByVal strg As String = "", _
                    ByVal fcl As UByte = 7, ByVal bcl As UByte = 0, ByVal lf   As Boolean = FALSE)

' test/demo code
Width 80, 25    ' standard sized console window
Dim As String   s = " Welcome to FreeBASIC ", _
                t = " Sub ShowStr() ... DEMO ... "
Dim As UShort   c = 1, r

ShowStr( , , t, 14)                     ' show title (default pos. row/column)
ShowStr(2, , String(Len(t), "~"), 14)   ' show underline (default column)

For r = 4 To 23                         ' used for row position
    ' choose any one of the 3 possibilities below (comment the other two!)
    ShowStr(r, c, s, (r Mod 8) + 8, r Mod 8) ' both colors used
    'ShowStr(r, c, s, (r Mod 8) + 8)     ' foreground color only
    'ShowStr(r, c, s)                    ' no colors at all (default colors)
    c += 3                              ' used for column position
Next

ShowStr(25, 5, " press a key, to EXIT ... ", 9, 15) ' using 5 parameters

Sleep
' test/demo code - end

Sub ShowStr( _  ' put a positioned string to console (with colors = optional)
    ByVal row   As UByte = 1, _         ' row pos. (default = 1 = top)
    ByVal col   As UByte = 1, _         ' column pos. (default = 1 = left)
    ByVal strg  As String = "", _       ' string (default = empty = position cursor only)
    ByVal fcl   As UByte = 7, _         ' foreground color (default = 7 = grey)
    ByVal bcl   As UByte = 0, _         ' background color (default = 0 = black)
    ByVal lf    As Boolean = FALSE _    ' (default = no line feed)
    )
    Locate row, col                     ' position cursor (console only)

    If fcl = 7 AndAlso bcl = 0 Then     ' use default colors
        If Not lf Then Print strg; Else Print strg ' print string (without/with lf)
    Else
        Color fcl, bcl                  ' set colors (user defined), one/other or both
        If Not lf Then Print strg; Else Print strg ' print string (without/with lf)
        Color 7, 0                      ' reset colors to default
    End If
End Sub
' ----- EOF -----
Before using it however, I'd test it on DOS (since, I have no DOS machine, any longer!).
It's only been tested on Windows-Console! (WIN-FBC 32/64, no DOS-FBC here!)
exagonx
Posts: 110
Joined: Mar 20, 2009 17:03
Location: Italy
Contact:

Re: 80 x 25 Text Editor

Postby exagonx » May 02, 2018 13:51

[quote="MrSwiss"]
Before using it however, I'd test it on DOS (since, I have no DOS machine, any longer!).
It's only been tested on Windows-Console! (WIN-FBC 32/64, no DOS-FBC here!)[/quote

Thank you for your suggestion that was helpfull but im looking for a scrolled window.
MrSwiss
Posts: 2728
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: 80 x 25 Text Editor

Postby MrSwiss » May 02, 2018 14:04

exagonx wrote:Thank you for your suggestion that was helpfull but im looking for a scrolled window.
It is currently not scrolling, because the Line-Feed is disabled (default setting).
By explicitly stating the last parameter = TRUE, LF is enabled ...

(Most users, want to prevent the scrolling but, don't know, how to achieve it.)

Return to “DOS”

Who is online

Users browsing this forum: No registered users and 1 guest