Buchempfehlung
MySQL kurz & gut
MySQL kurz & gut
Das preiswerte Taschen- buch stellt MySQL-rele- vante Inhalte systematisch und knapp dar, sodass es sich optimal zum Nach- schlagen beim Pro- grammieren eignet. [Mehr Infos...]
FreeBASIC-Chat
Es sind Benutzer im FreeBASIC-Chat online.
(Stand:  )
FreeBASIC bei Twitter
Twitter FreeBASIC-Nachrichten jetzt auch über Twitter erhalten. Follow us!

fb:porticula NoPaste

Info
Info / Hilfe
Liste
Übersicht / Liste
Neu
Datei hochladen
Suche
Quellcode suchen
Download
Dateidownload

MuhEdit 0.6.6

Uploader:MitgliedThe_Muh
Datum/Zeit:30.06.2008 11:30:52

'version 0.6.6
'subs und funktionen (declare):
declare sub speichern()
declare sub laden()
declare sub standartText(seite as string)
declare function blaettern(seite as string) as string
declare function file() as string
declare sub curs(zeile as integer, spalte as integer, aspalte as integer, azeile as integer)
'Variablen:
dim hoehe as integer
dim breite as integer
breite = 50 :hoehe = 50
dim d as string
dim shared as string tZeile(1 to 50)
dim as string seite
dim as integer aspalte, azeile
dim shared as integer zeile=3, spalte=1
dim as integer mzeile, mspalte, buttons
dim i as integer
dim L as integer

'subs und funktionen:
function blaettern(seite as string) as string
    Dim zahl as integer
    do
    CLS
    standarttext(seite)
    Locate (hoehe - 2), 1 : Print "__________________________________________________"
    Locate (hoehe - 1), 1 : Print "Which page do you want to open? (1-5)"
    sleep
    zahl = val(inkey)
    if zahl < 6 and zahl > 0 then seite = "page"+str(zahl)+".txt"
    loop until zahl > 0 and zahl < 6
    return seite
end function

function file() as string
    dim files as string
    cls
    locate 1, 1 : PRINT "MuhEdit Filechoser"
    locate 2, 1 : Print "__________________________________________________"
    DIM filename AS STRING

    filename = DIR("*.txt", 0)
    print filename
    DO
        filename = DIR("")
        print filename
    LOOP WHILE LEN(filename)

    Locate (hoehe - 2), 1 : Print "__________________________________________________"
    Locate (hoehe - 1), 1 : input "Filename: ",files
    Locate (hoehe - 1), 1 : Print "acceptet                                          "
    sleep

    return files
end function

sub speichern()
    dim files as string
    dim seite as string
    dim i as integer = 1
    cls
    locate 1, 1           : PRINT "MuhEdit Saver"
    locate 2, 1           : Print "__________________________________________________"
    Locate (hoehe - 2), 1 : Print "__________________________________________________"
    Locate (hoehe - 1), 1 : input "Filename (Without .txt): ",files
    seite = files + ".txt"

    OPEN seite FOR OUTPUT AS #1
    do
        if i = 50 then exit do
        PRINT #1, tzeile(i)
        i+= 1
    loop
    CLOSE #1
    Locate (hoehe - 1), 1 : Print "acceptet                                          "
    sleep
end sub

sub laden()
    dim seite as string
    dim as integer i
    dim as integer X
    seite = file()
    For X = 1 to 50
        tzeile(X) = ""
    Next

    OPEN seite FOR INPUT AS #1
    while not EOF(1)
        i += 1
        line INPUT #1, tzeile(i)
    wend
    CLOSE #1

    CLS
    for sh as integer = 3 to 47         'text anzeigen...
        locate sh, 1
        print tzeile(sh)
    next sh
    standarttext(seite)

end sub

sub standartText(seite as string)
    locate 1, 1 : PRINT "MuhEdit / Load = F11 / Save = F12 / Quit = ESC  "
    locate 2, 1 : Print "__________________________________________________"
    Locate (hoehe - 2),1 : Print "__________________________________________________"
    Locate (hoehe - 1),1 : Print "Page: "& seite &" | Open another page = F9    "
end sub

sub curs(zeile as integer, spalte as integer, aspalte as integer, azeile as integer)
    if azeile < zeile then
        locate azeile, aspalte
        print " "
    end if
    if azeile > zeile then
        locate azeile, aspalte
        print " "
    end if
        locate zeile, spalte
        print "_"
end sub

'hauptprogramm:
screenres 400,400
COLOR 0, 15 : CLS
standartText(seite)
DO
    cls
    L = len(tzeile(zeile))
    if L < spalte then
        for i = L to spalte - L -1
            tzeile(zeile) += chr(32)
        next i
    end if
    standartText(seite)
    for sh as integer = 3 to 47         'text anzeigen...
        locate sh, 1
        print tzeile(sh)
    next sh
    curs(zeile,spalte,aspalte,azeile)
    aspalte = spalte
    azeile = zeile

    'auf eingabe warten
    do:sleep 1
    getmouse mspalte, mzeile,,buttons
    if buttons then
       mzeile = mzeile / 8
        if mzeile < (hoehe - 3) and mzeile > 3 then
            zeile = mzeile
        end if
        mspalte = mspalte / 8
        spalte = mspalte
    end if
    d=inkey:loop until d<>"" or (buttons And 1)         'wartet auf Usereingabe

    locate zeile ,spalte

    SELECT CASE d
        case CHR(255, 72)                       'oben
        if zeile > 3 then
            zeile -= 1
        else
            zeile = (hoehe - 3)
        end if
    case CHR(255, 80)                           'unten
        if zeile < (hoehe - 3) then
            zeile += 1
        else
            zeile = 3
        end if
    case CHR(255, 75)                           'links
        if spalte>1 then                        'nicht am zeilenanfang
            print chr(32)
            spalte-=1
        else                                    'am zeilenanfang
            if zeile > 3 then
                zeile -= 1
                spalte = 50
            else
                zeile = (hoehe - 3)
                spalte = 50
            end if
        end if
    case CHR(255, 77)                           'rechts
        if spalte <> 50 then
            print chr(32)
            spalte += 1
        elseif spalte = 50 and zeile < (hoehe - 3) then
            zeile += 1
            spalte = 1
        else
            zeile = 3
            spalte = 1
        end if
    case CHR$(8):                               'backspace
        if spalte>1 then                        'nicht am zeilenanfang
            spalte-=1
            locate zeile,spalte
            print chr(32)&chr(32)
            tzeile(zeile)=left(tzeile(zeile),len(tzeile(zeile))-1)
        else                                    'am zeilenanfang
            if zeile > 3 then
                zeile -= 1
                spalte = 50
                locate zeile, spalte
                print " "
            else
                beep
            end if
        end if
    case CHR$(13):                              'enter
        if zeile > 23 then
            zeile = 3
            spalte = 1
        else
            spalte = 1
            zeile += 1
        end if
    case chr$(27):                              'escape
        exit do
    case chr$(255,107):                        'das X oben
        exit do
    case CHR(255,67):                           'F9 (blättern)
        laden()
        standartText(seite)
    case CHR(126):                          'seite speichern(F12)
        speichern()
        standartText(seite)
        locate 3, 1
    case CHR(255,122):                          'Laden (F11)
        laden()
        standartText(seite)
        locate 3, 1
    case Chr(255,63):
        CLS
        zeile = 3 : spalte = 1
    case else:
    Print d;
    spalte+=1
        if spalte >= 50 then
            spalte = 1
            zeile+=1
            if zeile>(hoehe - 3) then zeile=3
        end if
    if L > spalte then
        MID(tzeile(zeile), spalte - 1, 1) = d
    else
    tzeile(zeile) = tzeile(zeile) + d
    end if
    end select
loop

cls
locate 1, 1:
PRINT "TextEditor by The_Muh | Press any key to quit   "
locate 2, 1
Print "__________________________________________________"

Locate (hoehe - 2),1
Print "__________________________________________________"
Locate (hoehe - 1),1
Print "Programming and Idea:                   The_Muh"
sleep
end