Just for kiding ...
The smallest language that ever was designed.
Here you have a source editor, and the possibility to make instant execution !
Code: Select all
Global CurrentDirectory.s
CurrentDirectory = Space(#MAX_PATH)
Enumeration
#Window_Main
#Gadget_Image
#Gadget_Image1
#Gadget_Image2
#Gadget_Editor
#Menu_Item_New
#Menu_Item_Load
#Menu_Item_Run
#Menu_Item_Save
#Menu_Item_SaveAs
#Menu_Item_Exit
#PopupMenu
EndEnumeration
Procedure.s ReadSource(FileName.s)
If ReadFile(0, FileName)
*b = AllocateMemory(Lof())
ReadData(*b, Lof())
CloseFile(0)
SetGadgetText(#Gadget_Editor, PeekS(*b))
While WindowEvent() : Wend
ProcedureReturn FileName
Else
ProcedureReturn ""
EndIf
EndProcedure
Procedure.s SaveSource(FileName.s)
If CreateFile(0, FileName)
WriteStringN(GetGadgetText(#Gadget_Editor))
CloseFile(0)
ProcedureReturn FileName
Else
ProcedureReturn ""
EndIf
EndProcedure
WindowXSize.l = 640
WindowYSize.l = 480
GetCurrentDirectory_(255, @CurrentDirectory)
CurrentDirectory + "\"
FileName.s
GetCursorPos_(CursorPosition.POINT)
Quit.l = #FALSE
If OpenWindow(#Window_Main, CursorPosition\x - WindowXSize / 2, CursorPosition\y - WindowYSize / 2, WindowXSize, WindowYSize - 20, #PB_Window_Invisible, "YABL")
AddKeyboardShortcut(#Window_Main, #PB_Shortcut_Escape, #PB_Shortcut_Escape)
GetWindowRect_(WindowID(), MyRect.RECT)
ImageID = CreateImage(0, WindowXSize, WindowYSize)
StartDrawing(ImageOutput())
For i = 0 To 31
Box(i, i, WindowXSize - 2 * i, WindowYSize - 2 * i, RGB(0, 0, 255 - 8 * i)) ; , 255 - 8 * i, 255 - 16 * i))
Next
DrawingMode(4)
Box(0, 0, WindowXSize, WindowYSize, $C0FFFF)
StopDrawing()
If CreateGadgetList(WindowID())
SetGadgetFont(#PB_Default, LoadFont(0, "Verdana", 7, #PB_Font_HighQuality))
ImageGadget(#Gadget_Image, 0, 0, WindowXSize, WindowYSize, ImageID)
EditorGadget(#Gadget_Editor, 25, 25, WindowXSize - 50, WindowYSize - 50)
EndIf
If CreatePopupMenu(#PopupMenu)
MenuItem(#Menu_Item_New, "New")
MenuItem(#Menu_Item_Load, "Load")
MenuItem(#Menu_Item_Run, "Run")
MenuBar()
MenuItem(#Menu_Item_Save, "Save")
MenuItem(#Menu_Item_SaveAs, "SaveAs")
MenuBar()
MenuItem(#Menu_Item_Exit, "Exit")
EndIf
SetWindowLong_(WindowID(), #GWL_STYLE, #WS_DLGFRAME | #WS_CLIPCHILDREN | #WS_CLIPSIBLINGS)
SetWindowPos_(WindowID(), 0, 0, 0, 0, 0, #SWP_NOSIZE | #SWP_NOMOVE | #SWP_FRAMECHANGED)
While WindowEvent()
Wend
HideWindow(0,0)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = #TRUE
Case #PB_Event_Menu
Select EventMenuID()
Case #PB_Shortcut_Escape
Quit = #TRUE
Case #Menu_Item_New
SetGadgetText(#Gadget_Editor, "")
Case #Menu_Item_Load
ReadSource(OpenFileRequester("Select a source file to load", CurrentDirectory + "*.YABL", "YABL files|*.YABL|All files|*.*", 0))
Case #Menu_Item_Run
FileName.s = SaveSource(CurrentDirectory + Str(GetTickCount_()) + ".YABL")
RunProgram("pbcompiler.exe", FileName + " /EXE " + FileName + ".exe", CurrentDirectory, 1 | 2)
RunProgram(FileName + ".exe", "", CurrentDirectory)
Case #Menu_Item_Save
SaveSource(SaveFileRequester("Enter the file name to save", CurrentDirectory + "*.YABL", "YABL files|*.YABL|All files|*.*", 0))
Case #Menu_Item_SaveAs
SaveSource(SaveFileRequester("Enter the file name to save", CurrentDirectory + "*.YABL", "YABL files|*.YABL|All files|*.*", 0))
Case #Menu_Item_Exit
Debug "Exit selected"
Quit = #TRUE
EndSelect
Case #PB_Event_Gadget
Case #WM_LBUTTONDOWN
ReleaseCapture_()
SendMessage_(WindowID(), #WM_NCLBUTTONDOWN, #HTCAPTION, #NULL)
Case #WM_RBUTTONDOWN
Debug "R Button clicked"
DisplayPopupMenu(#PopupMenu, WindowID())
EndSelect
Until Quit
EndIf
TerminateProcess_(GetCurrentProcess_(), 0)
End
Focus in the editor gadget and enter whatever you want to do !
ie :
a = 12
b = 13
openconsole()
printn(str(a + b))
while inkey() = "" : wend
closeconsole()
Then right click to select "Run" tab in the popup menu. It should run (except if pbcompiler is not accessible from %PATH% variable of your environment variables ... in this case, just tune the program accordingly.
Well ... it was just a joke but, I guess it is a good possibility to enter any kind of code that you can parse and translate to PureBasic compatible code before running ...
My avatar is a small copy of the 4x1.8m image I created and exposed at 'Le salon international du meuble à Paris' january 2004 in Matt Sindall's 'Shades' designers exhibition. The original laminated print was designed using a 150 dpi printout.