cppman Posted March 10, 2006 Share Posted March 10, 2006 Here is a little tool that converts Unix 2 Dos and Dos 2 Unix.... expandcollapse popup#include <GuiConstants.au3> #include <string.au3> #include <file.au3> GuiCreate("MyGUI", 457, 212,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) $Label_1 = GuiCtrlCreateLabel("Unix2Dos and Back again", 161, 30, 144, 16) $Label_2 = GuiCtrlCreateLabel("Input File:", 5, 83, 49, 14) $Label_3 = GuiCtrlCreateLabel("Output File:", 6, 128, 62, 13) $InFile = GuiCtrlCreateInput("Input File", 72, 79, 210, 23) $BrowseIn = GuiCtrlCreateButton("Browse...", 288, 78, 122, 27) $OutFile = GuiCtrlCreateInput("Output File", 72, 122, 208, 24) $BrowseOut = GuiCtrlCreateButton("Browse...", 289, 120, 118, 26) $Button_8 = GuiCtrlCreateButton("Convert!", 127, 172, 196, 30) $toDos = GuiCtrlCreateRadio("Unix 2 Dos", 10, 45, 100) $toUnix = GuiCtrlCreateRadio("Dos 2 Unix", 110, 45, 100) GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $BrowseIn BrowseIn() Case $msg = $BrowseOut BrowseOut() Case $msg = $Button_8 Convert() EndSelect WEnd Exit Func BrowseIn() $Input = FileOpenDialog("Input File", "", "All Files(*.*)") GUICtrlSetData($InFile, $Input) EndFunc Func BrowseOut() $Output = FileSaveDialog("Output File", "", "TXT (*.txt)") GUICtrlSetData($OutFile, $Output) EndFunc Func Convert() $toDos = GUICtrlRead($toDos) $toUnix = GUICtrlRead($toUnix) If $toDos = $GUI_CHECKED Then $iFile = FileOpen(GUICtrlRead($InFile), 0) $oFile = FileOpen(GUICtrlRead($OutFile) & ".txt", 1) $lCt = _FileCountLines(GUICtrlRead($InFile)) For $i = 1 to $lCt $String = FileReadLine($iFile, $i) $Cut = StringStripCR($String) FileWriteLine($oFile, $Cut) Next FileClose($iFile) FileClose($oFile) MsgBox(0, "Finished!", "Finished!") Else If $toUnix = $GUI_CHECKED Then $iFile = FileOpen(GUICtrlRead($InFile), 0) $oFile = FileOpen(GUICtrlRead($OutFile) & ".txt", 1) $lCt = _FileCountLines(GUICtrlRead($InFile)) For $i = 1 to $lCt $String = FileReadLine($iFile, $i) $Cut = StringReplace($String, @CRLF, @LF) FileWriteLine($oFile, $Cut) Next FileClose($iFile) FileClose($oFile) MsgBox(0, "Finished!", "Finished!") Else MsgBox(0, "Error!", "") EndIf EndIf EndFunc Miva OS Project Link to comment Share on other sites More sharing options...
jaenster Posted January 31, 2007 Share Posted January 31, 2007 Big bump , but this rocks -jaenster Link to comment Share on other sites More sharing options...
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