fb:porticula NoPaste
Simple DOS-IDE
Uploader: | ytwinky |
Datum/Zeit: | 20.01.2008 21:11:56 |
'This simple Ide doesn't need any libs..
'..but reqires external programs
'THE EDITOR
'and THE COMPILER :lol:
'njoy
'ytwinky
Declare Sub Compile(byVal AndRun As Integer=1=0)
Declare Sub Edit(byVal What As String="")
Declare Sub Settings(byVal s As String)
Declare Sub RunProg()
Declare Function Exists(byVal DateiName As String, byVal Attr As Integer=&h27) As Integer'G. knows if WinAPI is available..
Declare Function LoadAll(byVal DateiName As String) As String
Declare Function GetChar(byVal s As String, byVal Range As String, byVal Upper As Integer=1=0) As String
Declare Function MenuChar(byVal s As String, byVal Which As Integer=1) As String
Declare Function GetFileName(byVal s As String) As String
Const Ini="Dos_Ide.Ini", Erw=".bas", LF=!"\n", Esc=!"\27", Bsl="\"
Const IdeEditor="C:" & Bsl &"Windows" & Bsl &"System32" & Bsl &"Edit.Com" 'should work on a lot of machines :rofl:
Dim m As String, Result As Integer
Dim Shared As String Prt, FileName, Compiler, DefaultDir, Editor, Options, Params, t
Dim Shared As Integer fp
Compiler="D:" & Bsl &"Sprachen" & Bsl &"FreeBASIC-Dos" & Bsl &"fbc.exe" 'modify to your needs..
Prt=Environ("Tmp") & Bsl &"Dos_Ide.Prt"
Function Exists(byVal DateiName As String, byVal Attr As Integer=&h27) As Integer
Return Dir(DateiName, Attr)<>"" '..do not use WinAPI-Functions ;-)))
End Function
Sub RunProg()
t=Left(Filename, Len(FileName)-4) &".exe"
If Exists(t) Then Exec(t, Params)
End Sub
Sub Edit(byVal What As String="")
Dim Result As Integer, This As String=What
If This="" Then This=FileName
If Not Exists(Editor) Then
Print "You'll have to change the settings:"
Print Editor &" not found.."
Sleep
Exit Sub
End If
If This<>"" Then
Result=Exec(Editor, This)
If Result Then
Print "Ooops, 'Edit'-Error "; Result
Sleep
End
End If
End If
End Sub
Sub Compile(byVal RunIt As Integer=1=0)
If FileName="" Then
Print "You did not yet enter a filename.."
FileName=GetFileName("No problem.. do it right now:")
End If
If Exists(FileName) Then
If Not Exists(Compiler) Then
Print "You'll have to change the settings or reinstall FB:"
Print Compiler &" not found.."
Sleep
Exit Sub
End If
Shell Compiler & Options &" " &FileName &" >" &Prt
t=LoadAll(Prt)
If t="" Then
Print "Maybe no error ;-))"
Else
Edit(Prt &" " &FileName) 'remember Alt-F switches edit-windows
End If
Sleep
Kill Prt
End If
If t="" And RunIt Then RunProg()
End Sub
Function GetChar(byVal s As String, byVal Range As String, byVal Upper As Integer=1=0) As String
Dim m As String
If s<>"" Then Print s;
If Range="" Then Range=!"\r\n"
Do
m=Input(1)
If Upper Then m=UCase(m)
Loop Until Instr(Range, m)
Print m
Return m
End Function
Sub Settings(byVal s As String)
Dim m As String
Do
Cls
If s<>"" Then Print s Else Print "Settings for the Dos-Ide"
Print "(Caution: Dos-Ide won't work correctly with false settings..)"
Print MenuChar("Compiler");Tab(28);Compiler
Print MenuChar("Default sources directory");Tab(28);DefaultDir
Print MenuChar("Editor");Tab(28);Editor
Print MenuChar("Filename");Tab(28);FileName
Print MenuChar("Options");Tab(28);Options
Print MenuChar("Save");Tab(28);CurDir & Bsl &Ini
m=GetChar("Select:", "CDEFOS" &Esc, 1=1)
Select Case m
Case "C"
m=""
Do
Line Input m+"Location of the FreeBASIC-Compiler(Enter is currentdir):", Compiler
If Compiler="" Then Compiler=CurDir
fp=Exists(Compiler, &h37)
If Not fp Then m=Compiler &" not found.." &Lf
Loop Until fp
Case "D"
m=""
Do
Line Input m+"Enter the default sources path(Enter is currentdir):", DefaultDir
If DefaultDir="" Then DefaultDir=CurDir
fp=Exists(DefaultDir, &h37)
If Not fp Then m=DefaultDir &" not found.." &Lf
Loop Until fp
Case "E"
m=""
Do
Line Input m &"Enter the editor's filename(with path):", Editor
If Editor="" Then Editor=IdeEditor
fp=Exists(Editor)
If Not fp Then m=Editor &" not found.." &Lf
Loop Until fp
Case "F"
FileName=GetFileName("Enter a filename:")
Case "O"
Line Input "Enter your default options:", Options
Case "S"
Open Ini For Output Access Write As #fp
Print #fp, Compiler
Print #fp, DefaultDir
Print #fp, Editor
Print #fp, FileName
Print #fp, Options
Close #fp
m=Esc
End Select
Loop Until m=Esc
End Sub
Function LoadAll(byVal DateiName As String) As String
Dim Datei As Integer=FreeFile, Puffer As String Ptr 'init variables..
If Exists(DateiName, 39) Then 'file existe and is no dir
Open DateiName For Binary As #Datei 'open file binary
fp=Lof(Datei) 'get filesize
Puffer=cAllocate(fp)'allocate buffer
*Puffer=Space(fp) 'init buffer
Get #Datei,, *Puffer 'copy whole file to buffer
Close #Datei 'close file
t=*Puffer 'stor buffer in temporary
DeAllocate Puffer 'free buffer, no is the time..
Else 'Ooops, error..
t="Ooops, something's wrong with " &DateiName
End If
Return t 'return buffer..
End Function
Function MenuChar(byVal s As String, byVal Which As Integer=1) As String
Const Red=12, DarkGray=8
Dim As Integer FG=LoWord(Color), BG=HiWord(Color)
If Which>1 Then ?Left(s, Which-1);
Color Red, BG
Print Chr(s[Which-1]);
Color FG, BG
Return Mid(s, Which+1)
End Function
Function GetFileName(byVal s As String) As String
If s<>"" Then Print s;
Input t
If t="" Then Return t
If lcase(Right(t, 4))<>Erw Then t+=Erw
If Instr(t, ":" & Bsl)=0 Then
If Exists(CurDir & Bsl &t) Then Return CurDir & Bsl &t
t=DefaultDir & Bsl &t
End If
Return t
End Function
'Main finally..
fp=FreeFile
If Exists(Ini) Then
Open Ini For Input Access Read As #fp
Input #fp, Compiler
Input #fp, DefaultDir
Input #fp, Editor
Input #fp, FileName
Input #fp, Options
Close #fp
Else
Settings("This is the first time you run Dos-Ide here.." &Lf &"Please configure it now.")
End If
If Command(1)<>"" Then FileName=Command(1)
If Editor="" Then Editor=IdeEditor
Do
Cls
Print "Dos-IDE v1.1 (c) 2007 by ytwinky, MD"
Print "Tested with FB-Dos 0.17f, cwsdpmi.exe in Path, using VM-MsDos 3.30"
Print MenuChar("Compile ");MenuChar("and run")
Print MenuChar(" Options:", 3);Options
Print Menuchar("Edit")
Print Menuchar("FileName ");FileName
Print MenuChar("Parameters:");Params
Print MenuChar("Run")
Print MenuChar("Settings")
Print MenuChar("Quit Dos-Ide")
m=GetChar("Enter your choice:", "CAOEFPRSQ" &Esc, 1=1)
Select Case m
Case "A"
Compile(1=1)
Case "C"
Compile(1=0)
Case "O"
Input "You may now enter your desired Options:", Options
Case "P"
Input "You may now enter your desired Parameters:", Params
Case "E"
If FileName="" Then FileName=GetFileName("At first enter a filename:")
Edit()
Case "F"
FileName=GetFileName("You may now enter a filename:")
Case "R"
RunProg()
Case "S"
Settings("Reconfigure Dos-Ide..")
End Select
Loop Until Instr(Esc &"Q", m)
End