rossnixon Posted May 24, 2007 Share Posted May 24, 2007 Hi all, Is anyone willing to help me with a small program? It needs to convert a folder of CAD files into JGW files. The .CAD files have 3 lines like the following, with only the 1st line different in each file. 2675170000.000,6022050000.000 125000.000 0 I need .JGW output for this example that has 6 lines as follows: .2 0.00000000 0.00000000 -.2 2675170 6022175 The first 4 lines in the output will always be the same. The 5th line is one-thousandth of the first value from the first line. The 6th line is one-thousandth of the second value from the first line PLUS one-thousandth of the 2nd line (i.e. 125) I do have AutoIt3, but am not experienced enough to do this yet. Source au3 file would be useful as an example. Thanks in anticipation! Link to comment Share on other sites More sharing options...
Xenobiologist Posted May 24, 2007 Share Posted May 24, 2007 HI, Global $old = '2675170000.000,6022050000.000' & @CRLF & '125000.000' & @CRLF & '0' MsgBox(64, "", _createNewFileStructur($old)) Func _createNewFileStructur($old) Local $splitted = StringSplit($old, ',') Local $lines = StringSplit($old, @CRLF) Return '.2' & @CRLF & '0.00000000' & @CRLF & '-.2' & @CRLF & _ $splitted[1] / 1000 & @CRLF & (($splitted[2] / 1000) + ($lines[3] / 1000)) EndFunc ;==>_createNewFileStructur So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
Davo Posted May 24, 2007 Share Posted May 24, 2007 (edited) Hi, I think Mega missed a crucial part of your post, so I posted another set of code that I think will do the job a bit better Dim $firstLineSplit $fileHandle = FileOpen("yourFilePathHere.CAD",0) $firstLineSplit = StringSplit(FileReadLine($fileHandle,1),",") FileClose($fileHandle) $fileHandle = FileOpen("newFilePathHere.JGW",2) FileWriteLine($fileHandle,.2) FileWriteLine($fileHandle,0.00000000) FileWriteLine($fileHandle,0.00000000) FileWriteLine($fileHandle,-.2) FileWriteLine($fileHandle,0.001 * $firstLineSplit[1]) FileWriteLine($fileHandle,0.001 * $firstLineSplit[2] + 125) FileClose($fileHandle) Exit Dave Edited May 24, 2007 by Davo ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------"I don't need to know everything, I just need to know where to find it when I need it"....EinsteinAnd in our case... That's the AutoIT helpfile ;) Please read before posting!!! Link to comment Share on other sites More sharing options...
Zedna Posted May 24, 2007 Share Posted May 24, 2007 Not tested #Include <File.au3> Const $header = '.2' & @CRLF & '0.00000000' & @CRLF & '0.00000000' & @CRLF & '-.2' & @CRLF $FileList=_FileListToArray(@ScriptDir, '*.CAD',1) If @Error=1 Then MsgBox (0,"","No Files Found.") Exit EndIf For $i = 1 To $FileList[0] ProcessFile($FileList[$i]) Next Func ProcessFile($name) $text = StringSplit(FileRead($name),@CRLF,1) $text2 = $header $line1 = StringSplit($text[1],',') $line2 = $text[2] $text2 &= $line1[1] / 1000 & @CRLF $text2 &= $line1[2] / 1000 + $line2 / 1000 $name_out = StringReplace($name, '.CAD','.JGW') FileWrite($name_out, $text2) EndFunc Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
rossnixon Posted May 25, 2007 Author Share Posted May 25, 2007 Not testedThanks Zedna, that worked straight up! If you are ever in New Zealand I will give you a chocolate fish. :-) Link to comment Share on other sites More sharing options...
Zedna Posted May 25, 2007 Share Posted May 25, 2007 Thanks Zedna, that worked straight up! If you are ever in New Zealand I will give you a chocolate fish. :-)I wonder I stay here at my opposite part of Earth (Czech republic) :) but post at least screenshot of such strange thing Happy Autoit scripting .... Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
rossnixon Posted May 26, 2007 Author Share Posted May 26, 2007 I wonder I stay here at my opposite part of Earth (Czech republic) :) but post at least screenshot of such strange thing Happy Autoit scripting .... http://en.wikipedia.org/wiki/Chocolate_fish (description at this link, Cheers Ross) Link to comment Share on other sites More sharing options...
James Posted May 26, 2007 Share Posted May 26, 2007 Wow tasty! If only I was awake, I could of helped you, and got that tasty fish Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
Zedna Posted May 26, 2007 Share Posted May 26, 2007 (edited) http://en.wikipedia.org/wiki/Chocolate_fish (description at this link, Cheers Ross) Hmm. looks good. I never seen that before. Edited May 26, 2007 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search 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