geofromalimos
Members-
Posts
18 -
Joined
-
Last visited
geofromalimos's Achievements
-
You are good. Thanks for your help and I am sorry for the confusion! It was a hundred lines before in the original script. I don't think it is a good idea to post 2000 lines of code for such a case. :-P
-
Firefox I am so stupid... Unfortunately the only thing I had to do is to add a fileclose after a fileopen in the my code. I am so sorry for spending your time...
-
Thanks for your reply Firefox. I am running AutoIT v3.3.8.1 in Windows 7 x32. You?
-
Dear AutoIT scripters, I am facing a weird issue with filemove. What I am trying to do, is the following: $File_A = @ScriptDir&'\PROCESSING\1234567_1111' $File_B = @ScriptDir&'\123456789' FileMove($File_A,$File_B) The above snippet works if the files have extensions PS: They are files, not folders! Any ideas?
-
Good morning devs. This is my first time trying to deal with DLLs and I've found some threads on this subject. Here is the documentation for a dll function: GetApiVersion() Function Prototype WORD GetApiVersion( LPWORD Version ); Parameter Description Version Returns version of API. Return Values RESULT_SUCCESSFUL 0 Successfully returned version. Functional Description Returns the API version I try with the below autoit code: Local $version $out = DllCall("core.dll","dword","GetApiVersion","dword",$version) consolewrite("Version of the API is : "& $out) I always get 0 as output but i can't get the Version! Any help is really appreciated.
-
Text file splitting
geofromalimos replied to geofromalimos's topic in AutoIt General Help and Support
Wow! I didn't knew that StringSplit works with @CRLF!!! Thank you very much! I'll try it and let you know!!!! -
Text file splitting
geofromalimos replied to geofromalimos's topic in AutoIt General Help and Support
Hey man take it easy! I'm just asking for suggestions here, not for a ready project! I'm just trying to find a way of identifying the 7 blank lines. Any ideas? -
Text file splitting
geofromalimos replied to geofromalimos's topic in AutoIt General Help and Support
I've done this but I'm brainly stuck! It's a bit complex. Let me show you some code: #Include <File.au3> #Include <array.au3> ;Parse all directories to an array $Printer_Dir = _FileListToArray(@ScriptDir,"_*",2) For $d = 1 To $Printer_Dir[0] ;Get Directory Size $Printer_Dir_Size = DirGetSize(@ScriptDir&"\"&$Printer_Dir[$d]) ;If the directory is empty bypass it If $Printer_Dir_Size = 0 Then ConsoleWrite("Directory "&$Printer_Dir[$d]&" bypassed. Nothing received."&@LF) EndIf ;If the directory is not empty then start reading files If $Printer_Dir_Size > 0 Then ;Get all messages found inside a folder $Printer_Dir_Files = _FileListToArray(@ScriptDir&"/"&$Printer_Dir[$d],"TEXT_*") For $m = 1 to $Printer_Dir_Files[0] ;Get the file size $File_Size = FileGetSize(@ScriptDir&"/"&$Printer_Dir[$d]&"/"&$Printer_Dir_Files[$m]) ;If the file size is 0 delete the file If $File_Size = 0 Then FileDelete(@ScriptDir&"/"&$Printer_Dir[$d]&"/"&$Printer_Dir_Files[$m]) ConsoleWrite("File "&$Printer_Dir_Files[$m]&" has been deleted due to 0 file size."&@LF) EndIf ;If the file size is not 0 start type a procedures If $File_Size > 0 Then ;HERE GOES THE CODE FOR SPLITTING! EndIf Next EndIf Next As you can see the following things happen there: 1. Inside the script directory there various folders starting with _ e.g. _FOLDER1 2. Under each folder some files exist with names like TEXT_123131.txt 3. I scan everything and if something is found I want split it (if needed) and send it to a database(ok I know how to send it!). -
Hi to all. Let's say we have a text file with this content: Line1 Line2 Line3 Line4 Line5 Line6 Line7 Line8 Line9 Line10 Line11 Line12 What I am trying to achieve is to split the file and create a new one when 7 new lines are found. So the result of the above txt file will be: txt1.txt: Line1 Line2 Line3 Line4 Line5 Line6 txt2.txt: Line7 Line8 Line9 Line10 and txt3.txt: Line11 Line12 Any ideas?
-
Autoit Service problem!
geofromalimos replied to geofromalimos's topic in AutoIt General Help and Support
Well, I've never thought that this could be a problem! I'll do the appropriate changes and let you know! Thanks! Yes, I've read it and it works fine for me, but I prefer to have a "direct" service and not a service generated by a third party app! Thanks for your reply. In case nothing works I will keep working with this app! -
Good evening everyone. Hope you are all fine! I'm facing a problem while trying to run my script as service. It is a script which every 10 seconds reads a directory splits some text files, analyzes them and then moves them to a mysql database! Can you please let me know what maybe wrong?I do not receive any errors and i'm trying to find out what I'm doing wrong! Here is the code: #Include <File.au3> #Include <Array.au3> #include "MySQL.au3" ;Retrieve Directories $ReadMsgDir = IniRead(@ScriptDir&"\Configuration.ini", "Directories", "Read Messages Directory", "NotFound") $StrdMsgDir = IniRead(@ScriptDir&"\Configuration.ini", "Directories", "Stored Messages Directory", "NotFound") $timer = IniRead(@ScriptDir&"\Configuration.ini", "Timers", "Time between checks in ms", "NotFound") $TrshMsgDir = IniRead(@ScriptDir&"\Configuration.ini", "Directories", "Trash Messages Directory", "NotFound") ;Retrieve Database Credentials and details $UserName = IniRead(@ScriptDir&"\Configuration.ini", "Database", "Username", "NotFound") $Password = IniRead(@ScriptDir&"\Configuration.ini", "Database", "Password", "NotFound") $Database = IniRead(@ScriptDir&"\Configuration.ini", "Database", "Database", "NotFound") $MySQLServerName = IniRead(@ScriptDir&"\Configuration.ini", "Database", "Server", "NotFound") ;Retrieve other options $Storeval = IniRead(@ScriptDir&"\Configuration.ini", "Options", "Store mode", "NotFound") ;Application code stars here While 1 $begin = TimerInit() sleep($timer) $dif = TimerDiff($begin) If FileExists(@Scriptdir&"\Print*" ) Then ;Scan for empty files and delete them before starting any engine $initfiles=_FileListToArray(@ScriptDir,"Print*") for $g=1 to $initfiles[0] $initsize=filegetsize($initfiles[$g]) If $initsize=0 then filedelete($initfiles[$g]) Endif Next If FileExists(@Scriptdir&"\Print*" ) Then ;Start Message Divider Engine $rawfiles=_FileListToArray(@Scriptdir,"Print*") $v=0 For $x=1 to $rawfiles[0] Dim $tpffile $a=_FileReadToArray($rawfiles[$x],$tpffile) for $i=1 to $tpffile[0] switch $tpffile[$i] case "" case "**" filewriteline("txf"&$v&".txt",$tpffile[$i]) $v=$v+1 case Else filewriteline("txf"&$v&".txt",$tpffile[$i]) Endswitch Next filecopy($rawfiles[$x],$StrdMsgDir&"*.txt") filedelete($rawfiles[$x]) Next ;Terminate Message Divider Engine $inputfiles=_FileListToArray(@Scriptdir,"txf*") ;Start Identification procedure for $d=1 to $inputfiles[0] $inline=filereadline($inputfiles[$d],1) $inlinelen=StringLen($inline) ;Handle exception of possible wrong message if $inlinelen<26 Then filecopy($inputfiles[$d],$TrshMsgDir&$inline&".txt") filedelete($inputfiles[$d]) ;Handle the file if it is a valid format message ElseIf $inlinelen=26 Then $msgdet=StringSplit($inline, " ") $sendline=filereadline($inputfiles[$d],2) $prio=Stringleft($sendline,2) $destination=StringRight($sendline,7) $orgline=filereadline($inputfiles[$d],3) $org1=StringLeft($orgline,8) $originator=StringRight($org1,7) $msgtypeln=filereadline($inputfiles[$d],4) $lenght=StringLen($msgtypeln) If $lenght = 3 Then $msgtype=$msgtypeln ElseIf $lenght <> 3 Then $msgtype="TST" EndIf $outfile= $msgdet[4]&" - "&$msgdet[5]&" - "&$originator&" - "&$destination&" - "&$msgtype&" - "&$msgdet[1]&".txt" ;Prepare data for mySQL export $explines=_FileCountLines($inputfiles[$d]) $html2="" For $p=1 to $explines $htmlline1=filereadline($inputfiles[$d],$p) $html2=$html2&$htmlline1&"<br />" Next $html="<code>"&$html2&"</code>" ;Edit date format $date1 = Stringleft($msgdet[4],5) $day = Stringleft($date1,2) $date3 = StringRight($date1,3) switch $date3 case "JAN" $month="01" case "FEB" $month="02" case "MAR" $month="03" case "APR" $month="04" case "MAY" $month="05" case "JUN" $month="06" case "JUL" $month="07" case "AUG" $month="08" case "SEP" $month="09" case "OCT" $month="10" case "NOV" $month="11" case "DEC" $month="12" EndSwitch $sqldate = @YEAR & "-" & $month & "-" & $day ;Edit time format $sqltime1=StringLeft($msgdet[5],4) $sqltime2=StringLeft($sqltime1,2) $sqltime3=StringRight($sqltime1,2) $sqltime=$sqltime2&":"&$sqltime3 $sqldatetime=$sqldate&" "&$sqltime $SQLInstance = _MySQLConnect($UserName,$Password,$Database,$MySQLServerName) $uentry= "INSERT INTO master.main (`MID` ,`MRD` ,`MRT` ,`MRDT`,`ORG`,`DES` ,`TYPE` ,`PRIO` ,`MSG` ,`READ`) VALUES ( '"&$msgdet[1]&"', '"&$sqldate&"', '"&$sqltime&"', '"&$sqldatetime&"', '"&$originator&"', '"&$destination&"', '"&$msgtype&"', '"&$prio&"', '"&$html&"', 'NOP' );" _Query($sqlinstance,$uentry) _MySQLEnd($SQLInstance) Switch $Storeval case 0 consolewrite("File proccessed and deleted."&@LF) case 1 filecopy($inputfiles[$d],$ReadMsgDir&$outfile) consolewrite("File proccessed and stored in a new format."&@LF) EndSwitch filedelete($inputfiles[$d]) EndIf Next EndIf Endif WEnd Any help is really appreciated!
-
Arrays/text files problem
geofromalimos replied to geofromalimos's topic in AutoIt General Help and Support
Ok, I've written some code here: $v=0 For $i=1 to 7259 $inline=filereadline("test.txt",$i) switch $inline case "" case Else filewriteline("test"&$v&".txt",$inline) Endswitch consolewrite($inline&@LF) switch $inline case "**" $inline2=filereadline("test.txt",$i+1) switch $inline2 case "" $inline3=filereadline("test.txt",$i+2) switch $inline3 Case "" consolewrite("END") $v=$v+1 case Else EndSwitch case Else Endswitch case Else EndSwitch Next It finally works fine!(Keep in mind that it also removes blank lines beetween the text but that is not a problem for me, it actually helps!) -
Arrays/text files problem
geofromalimos replied to geofromalimos's topic in AutoIt General Help and Support
Can you please explain to me or tell me where I can find some documentation about the expression in bold? $aFile = StringRegExp($sStr, "((?:[^\v]+\v{0,10})+(?:\v{12,}|$))", 3) Actually i forgot something at the beginning.The txt files are like this: test test test test test test ** test2 test2 test2 test2 ** test3 test3 test3 test3 test3 ** So when the app scans ** and then 4 empty lines it divides the file... Thanks in advance for all your time and help. -
Arrays/text files problem
geofromalimos replied to geofromalimos's topic in AutoIt General Help and Support
Dear Malkey thank you also for your precious help. It works fine but I need to study it to understand how it works! Thank you all once more. In case of any troubles through my tests I'll ask you if you have no problem. -
Arrays/text files problem
geofromalimos replied to geofromalimos's topic in AutoIt General Help and Support
Ok, I'm here so far and it seems that till now everything is fine... #Include <File.au3> Dim $VT $file=FileOpen("test.txt",0) _FileReadToArray("test.txt",$VT) For $x=1 to $VT[0] $v="" $line=filereadline($file,$x+1) $ln=StringLen($line) switch $ln ;problem here... EndSwitch Next The problem i'm facing is with the switch function.Sorry I'm just a beginner...1000 thanks for your time.