theguy0000 Posted May 4, 2007 Posted May 4, 2007 (edited) hm, I never thought of doing it so simply I'm going to try to make my own language, too...but with a different syntax...something like message box:title=This is weird syntax!;text=yup...definitely weird... so that the order of the parameters doesn't matter. i dunno, just exploring Edited May 4, 2007 by theguy0000 The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN
James Posted May 4, 2007 Posted May 4, 2007 Download Modified Guide Heretheguy: That is strange syntax, maybe even confusing! Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
A. Percy Posted May 4, 2007 Posted May 4, 2007 if each option was preceded by a "/" like "messagebox /title=This is weird syntax! /text=yup" you can use a stringsplit to return all parts: messagebox title=This is weird syntax! text=yup Skiping the first item, you can treat all individual terms (title, text) in a looping, in independent order. Só o que posso lhe dizer, bom é quando faz mal!My work:Au3Irrlicht - Irrlicht for AutoItMsAgentLib - An UDF for MSAgentAu3GlPlugin T2 - A 3D plugin for AutoIt...OpenGl Plugin - The old version of Au3GlPlugin.MAC Address Changer - Changes the MAC AddressItCopter - A dragonfly R/C helicopter simulator VW Bug user Pinheiral (Pinewood) city: http://pt.wikipedia.org/wiki/Pinheiral
James Posted May 4, 2007 Posted May 4, 2007 (edited) Also using $String[2] etc.. StringSplit looks handy there.Edit: A.Percy beat me to it.. Edited May 4, 2007 by Secure_ICT Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
theguy0000 Posted May 4, 2007 Posted May 4, 2007 (edited) yay, it works! CODEexpandcollapse popup#include <GUIConstants.au3> ; == GUI generated with Koda == $gui = GUICreate("My Command Line", 338, 192, 192, 125) $txt = GUICtrlCreateEdit("", 0, 0, 337, 161, $ES_READONLY) ;~ GUICtrlSetData($txt, "> Welcome to my command line!" &@CRLF) $cLine = GUICtrlCreateInput("clear", 0, 168, 257, 21) $Execute = GUICtrlCreateButton("Execute", 264, 168, 74, 22, $BS_DEFPUSHBUTTON) GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Execute $string = StringSplit(GuiCtrlRead($cLine),Chr(58)) $cmd = $string[1] If UBound($string) > 2 Then $pline = $string[2] Else $pline = "" EndIf $params = StringSplit ($pline, Chr(59)) Switch $cmd Case 'echo' _ConsoleWrite ($pline) Case 'clear' GUICtrlSetData($txt, "") Case 'popup' MsgBox (0, _Param('title'), _Param('text')) EndSwitch GUICtrlSetData ($cLine, "") EndSelect WEnd Func _ConsoleWrite($text) GUICtrlSetData($txt,$text & @crlf,GUICtrlRead($txt)) EndFunc Func _TrimSpaces(ByRef $parameter) Local $string $string = StringSplit($parameter, "") If $string[1] = Chr(32) then $string = StringtrimLeft($parameter,1) Return $string Else Return $parameter EndIf EndFunc Func _Param($sVar, $iVarType=0) ; it's almost exactly the same as _Get from Web.au3! Local $varstring, $num, $vars, $var_array $varstring = $pline If Not StringInStr($varstring, $sVar&"=") Then Return "" $num = __StringFindOccurances($varstring, "=") Local $vars[$num+1] $vars = StringSplit ($varstring, ";") For $i=1 To $vars[0] If $iVarType Then If $vars[$i] = $sVar Then Return True Else $var_array = StringSplit ($vars[$i], "=") If $var_array[0] < 2 Then Return "error" If $var_array[1] = $sVar Then Return $var_array[2] EndIf Next If $iVarType Then Return False Return True EndFunc Func __StringFindOccurances($sStr1, $sStr2) For $i = 1 to StringLen($sStr1) If not StringInStr($sStr1, $sStr2, 1, $i) Then ExitLoop Next Return $i EndFunc the parameters are retrieved by the same function used for _Get and _Post (and _Cookie), just modified the tiniest bit. now you can echo:hello! see? it works! popup:title=a cool title;text=look, ma! no commas! or popup:text=haha! text comes first;title=...and then the title or even popup:title=hello;uselessParam=something useless;text=and it ignores the useless parameter! or you can just clear Edited May 4, 2007 by theguy0000 The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN
James Posted May 4, 2007 Posted May 4, 2007 Can you attach it, or remove the codebox? I am having troubles copying it.. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
theguy0000 Posted May 4, 2007 Posted May 4, 2007 (edited) Can you attach it, or remove the codebox? I am having troubles copying it..terminal.au3 edit: wrong file Edited May 4, 2007 by theguy0000 The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN
James Posted May 4, 2007 Posted May 4, 2007 Thanks.. Thats pretty cool! Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
i542 Posted May 5, 2007 Author Posted May 5, 2007 terminal.au3 edit: wrong file cool i542 I can do signature me.
James Posted May 5, 2007 Posted May 5, 2007 i542, send me your MSN address and I will add you. When are you going to start writing a new version? Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
i542 Posted May 5, 2007 Author Posted May 5, 2007 (edited) i542, send me your MSN address and I will add you.When are you going to start writing a new version?For ~30 minutes, just to post some posts & incerase my post counter i542EDIT: My MSN: ivan_ostric@hotmail.com Edited May 5, 2007 by i542 I can do signature me.
James Posted May 5, 2007 Posted May 5, 2007 Added Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
i542 Posted May 5, 2007 Author Posted May 5, 2007 (edited) AddedOh rly?i542EDIT: Stupid MSN. I use Live Messenger... Edited May 5, 2007 by i542 I can do signature me.
James Posted May 5, 2007 Posted May 5, 2007 Yes, I have done it now. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
A. Percy Posted May 8, 2007 Posted May 8, 2007 (edited) Yes, I have done it now. Today I made some modifications on your code... see bellow Edit: look at color function expandcollapse popup#include <GuiConstants.au3> #NoTrayIcon $font = "Courier New" $gui = GUICreate("My Programming Command Line", 482, 250, -1,-1) GUISetIcon("shell32.dll", 42) $txt = GUICtrlCreateEdit("", 0, 0, 481, 217, $ES_READONLY + $WS_VSCROLL) GUICtrlSetFont (-1, 9, 400, 4, $font) GUICtrlSetBkColor(-1, 0x000000) GUICtrlSetColor(-1, 0xffffff) GUICtrlSetData($txt, "> Welcome to mycommand line, you are logged in as: " & @UserName & @CRLF) $cLine = GUICtrlCreateInput("", 5, 224, 380, 21) ClearLine( ) $Execute = GUICtrlCreateButton("Execute", 390, 221, 89, 25, $BS_DEFPUSHBUTTON) GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Execute TreatCommandLine( ) EndSelect WEnd Func _ConsoleWrite($text) GUICtrlSetData($txt, $text & @crlf, GUICtrlRead($txt)) EndFunc Func _TrimSpaces(ByRef $parameter) Local $string $string = StringSplit($parameter, "") If $string[1] = Chr(47) then $string = StringtrimLeft($parameter,1) Return $string Else Return $parameter EndIf EndFunc Func GetFunctionParameters( $CmdArray ) Local $RetVal[1][2] $RetVal[0][0] = 0 ;count parameters If $CmdArray[0] > 1 Then For $i = 1 to $CmdArray[0] Local $Parameter = StringSplit( $CmdArray[$i], Chr(58) ) If $Parameter[0] >= 1 Then $RetVal[0][0] += 1 Local $Index = $RetVal[0][0] ReDim $RetVal[ $Index + 1 ][2] $RetVal[ $Index ][0] = _TrimSpaces( $Parameter[1] ) $RetVal[ $Index ][1] = "" If $Parameter[0] > 1 Then $RetVal[ $Index ][1] = _TrimSpaces( $Parameter[2] ) EndIf EndIf Next EndIf Return $RetVal EndFunc Func _NewGUI( $string ) $nGUI = GuiCreate("New GUI", $string[2], $string[3], -1, -1) GuiSetState(@SW_SHOW) While WinActive($nGUI) $gMsg = GuiGetMsg() Switch $gMsg Case $GUI_EVENT_CLOSE GUIDelete($nGUI) EndSwitch WEnd EndFunc Func ClearLine( ) GuiCtrlSetData($cLine, "", "") EndFunc Func TreatCommandLine( ) Local $string = StringSplit(GuiCtrlRead($cLine), Chr(47)) $string[1] = StringStripWS( $string[1], 8 ) Switch $string[1] Case "clear" Clear( ) Case "echo" Echo( $string ) Case "beep" MyBeep( $string ) Case "exit" MyExit( ) Case "computer" Computer( ) Case "about" About( ) Case "gui" Gui( $string ) Case "popup" MyPopUp( $string ) Case "title" WinSetTitle($gui, "", $string[2]) Case "color" Color( $string ) Case "cd" CdRom( $string ) Case "computer" _ConsoleWrite("> Syntax: computer") _ConsoleWrite("> Shows the computer information") _ConsoleWrite("> Remarks: none") Case "" _ConsoleWrite("> You forgot to add a command") Case "help" Help( $string ) Case "gui" _ConsoleWrite("> You haven't added any values to the width and height.") _ConsoleWrite("> Example: >gui, 400, 500") Case Else _ConsoleWrite("Error with syntax: " & $string[1]) _ConsoleWrite("Use help /? to find help!") EndSwitch ClearLine( ) EndFunc Func Clear( ) _ConsoleWrite("> Clearing...") Sleep(1000) GUICtrlSetData($txt, "", "") EndFunc Func Echo( $String ) If $String[0] > 1 Then $string[2] = _TrimSpaces($string[2]) _ConsoleWrite($string[2]) EndIf EndFunc Func MyBeep( $string ) $string[2] = _TrimSpaces($string[2]) Beep($string[2], $string[3]) _ConsoleWrite("> Beep successfull") EndFunc Func MyExit( ) _ConsoleWrite("> Goodbye.") Sleep(1000) Exit EndFunc Func Computer( ) _ConsoleWrite("> Your username is: " & @Username) _ConsoleWrite("> Your computer name is: " & @ComputerName) _ConsoleWrite("> Your Operating System is: " & @OSVersion) _ConsoleWrite("> Service Pack is: " & @OSServicePack) _ConsoleWrite("> OS Build: " & @OSBuild) _ConsoleWrite("> Language: " & @OSLang) EndFunc Func About( ) _ConsoleWrite("> My Programming Language") _ConsoleWrite("> Created with i542's Programming Language System") _ConsoleWrite("> This language is licensed to: Secure_ICT") EndFunc Func Gui( $string ) $checkline = GUICtrlRead($cLine) If $checkline = "gui" Then _ConsoleWrite("> You have not specified width and height to create a GUI.") Else _ConsoleWrite("> Creating GUI") Sleep(1000) _NewGUI( $string ) EndIf EndFunc Func MyPopUp( $CmdArray ) MsgBox(0, $CmdArray[2], $CmdArray[3]) GUICtrlSetData($txt,"<Popup Executed Successfully>" & @CRLF, GuiCtrlRead($txt)) EndFunc Func Color( $CmdArray ) If UBound( $CmdArray ) = 0 Then Return 0 Local $RetVal = 0 If $CmdArray[0] > 1 Then $Parameters = GetFunctionParameters( $CmdArray ) For $i = 1 to $Parameters[0][0] Switch $Parameters[$i][0] Case "back" GUICtrlSetBkColor($txt, _GetColor( $Parameters[$i][1] ) ) $RetVal = 1 Case "front" GUICtrlSetColor($txt, _GetColor( $Parameters[$i][1] ) ) $RetVal = 1 EndSwitch Next EndIf If $RetVal = 0 Then _ConsoleWrite("> color command usage:") _ConsoleWrite("> color /back:white /front:black") _ConsoleWrite("> Possible colors: green, white, blue, rose, pink, black") EndIf Return $RetVal EndFunc Func _GetColor( $Color ) $Color = StringStripWS( $Color, 8 ) Switch $Color Case "green" Return 0xaaffbb Case "white" Return 0xffffff Case "blue" Return 0x0000ff Case "turquoise" Return 0x00ffff Case "red" Return 0xff0000 Case "rose" Return 0xddacaa Case "pink" Return 0xddacee Case "black" Return 0x000000 Case Else Return 0xffffff EndSwitch EndFunc Func CdRom( $CmdArray ) If UBound( $CmdArray ) = 0 Then Return 0 Local $RetVal = 0 If $CmdArray[0] > 1 Then $Parameters = GetFunctionParameters( $CmdArray ) For $i = 1 to $Parameters[0][0] Switch $Parameters[$i][0] Case "open" $drive = DriveGetDrive("CDROM") CDTray($drive, "open") _ConsoleWrite("CD Tray Opened") Case "close" CDTray("H:\", "closed") _ConsoleWrite("CD Tray Closed") EndSwitch Next EndIf If $RetVal = 0 Then _ConsoleWrite("> color command usage:") _ConsoleWrite("> color /back:white /front:black") _ConsoleWrite("> Possible colors: green, white, blue, rose, pink, black") EndIf Return $RetVal EndFunc Func Help( $CmdArray ) If UBound( $CmdArray ) = 0 Then Return 0 If $CmdArray[0] > 1 Then $Parameters = GetFunctionParameters( $CmdArray ) For $i = 1 to $Parameters[0][0] Switch $Parameters[$i][0] Case "echo" _ConsoleWrite("> Syntax: echo, <text>") _ConsoleWrite("> Places text in this control") _ConsoleWrite("> Remarks: none") Case "popup" _ConsoleWrite("> Syntax: popup, <title>, <text>") _ConsoleWrite("> Makes a popup appear") _ConsoleWrite("> Remarks: none") Case "clear" _ConsoleWrite("> Syntax: clear") _ConsoleWrite("> Clears all of the text in the control") _ConsoleWrite("> Remarks: none") Case "exit" _ConsoleWrite("> Syntax: exit") _ConsoleWrite("> Closes the command window") _ConsoleWrite("> Remarks: none") Case "beep" _ConsoleWrite("> Syntax: beep {Frequency, Duration}") _ConsoleWrite("> Plays back a beep to the user") _ConsoleWrite("> Remarks: Requires numbers e.g. beep, 500, 1000") Case "color" _ConsoleWrite("> color command usage:") _ConsoleWrite("> color /back:white /front:black") _ConsoleWrite("> Possible colors: green, white, blue, rose, pink, black") Case "cd" _ConsoleWrite("> Syntax: cd {open,close}") Case "title" _ConsoleWrite("> Syntax: title {new title}") _ConsoleWrite("> Changes the window title") _ConsoleWrite("> Remarks: Example; title, James Brooks Programming Command Line") Case "gui" _ConsoleWrite("> Syntax: gui {width, height}") _ConsoleWrite("> Creates a GUI") _ConsoleWrite("> Remarks: A random GUI.") Case Else _HelpError( ) EndSwitch Next Else _HelpError( ) EndIf Return 0 EndFunc Func _HelpError( ) _ConsoleWrite("> Syntax: help {command in which you need help}") _ConsoleWrite("> Shows the help information and example. Commands are, help {color, exit, clear, popup, echo, beep}") _ConsoleWrite("> Remarks: Shows help info e.g help /exit") EndFunc Bye Edited May 8, 2007 by A. Percy Só o que posso lhe dizer, bom é quando faz mal!My work:Au3Irrlicht - Irrlicht for AutoItMsAgentLib - An UDF for MSAgentAu3GlPlugin T2 - A 3D plugin for AutoIt...OpenGl Plugin - The old version of Au3GlPlugin.MAC Address Changer - Changes the MAC AddressItCopter - A dragonfly R/C helicopter simulator VW Bug user Pinheiral (Pinewood) city: http://pt.wikipedia.org/wiki/Pinheiral
James Posted May 8, 2007 Posted May 8, 2007 Hmmm I like how it gets bigger! The script is big! Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
A. Percy Posted May 8, 2007 Posted May 8, 2007 Hmmm I like how it gets bigger! The script is big!Yes. But it can be splited in more files, like modules! Só o que posso lhe dizer, bom é quando faz mal!My work:Au3Irrlicht - Irrlicht for AutoItMsAgentLib - An UDF for MSAgentAu3GlPlugin T2 - A 3D plugin for AutoIt...OpenGl Plugin - The old version of Au3GlPlugin.MAC Address Changer - Changes the MAC AddressItCopter - A dragonfly R/C helicopter simulator VW Bug user Pinheiral (Pinewood) city: http://pt.wikipedia.org/wiki/Pinheiral
A. Percy Posted May 8, 2007 Posted May 8, 2007 Observation: This script is a command line interpreter, not a programming language Só o que posso lhe dizer, bom é quando faz mal!My work:Au3Irrlicht - Irrlicht for AutoItMsAgentLib - An UDF for MSAgentAu3GlPlugin T2 - A 3D plugin for AutoIt...OpenGl Plugin - The old version of Au3GlPlugin.MAC Address Changer - Changes the MAC AddressItCopter - A dragonfly R/C helicopter simulator VW Bug user Pinheiral (Pinewood) city: http://pt.wikipedia.org/wiki/Pinheiral
James Posted May 8, 2007 Posted May 8, 2007 Yes, I know.. But it gets confusing, but I see what your thinking could be possible. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
i542 Posted May 9, 2007 Author Posted May 9, 2007 Today I made some modifications on your code...see bellow Edit: look at color function(...)ByeWhat a...?!It is too complicated for me...i542 I can do signature me.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now