BatMan22 Posted November 18, 2017 Posted November 18, 2017 (edited) Hey Guys.. So I am trying to split up my data that I have loaded into two arrays by my test code (in this case I'm just showing 300.0 and 300.1).. I want it so that if for $ColumnC=300.1 then write to a file called "IC3.txt" the SampleID and 300.1. I will have a lot more functions and test codes eventually but I don't understand why this test case is failing.. Instead of writing "Sample 3 300.1""Sample5 300.1" it just writes "300.1" once.. Global $ColumnC[10] Global $ColumnB[10] $ColumnC[1]="300.0" $ColumnC[2]="300.0" $ColumnC[3]="300.1" $ColumnC[4]="300.0" $ColumnC[5]="300.1" $ColumnB[1]="Sample1" $ColumnB[2]="Sample2" $ColumnB[3]="Sample3" $ColumnB[4]="Sample4" $ColumnB[5]="Sample5" For $i= 0 to UBound($ColumnC) -1 ;~ ConsoleWrite($ColumnC[$i] & @LF) If $ColumnC[$i]="300.1" Then _FileWriteFromArray(@ScriptDir & "\IC3.txt", $ColumnB, $i, $i) _FileWriteFromArray(@ScriptDir & "\IC3.txt", $ColumnC, $i, $i) EndIf Next ConsoleWrite(UBound($ColumnC)) Edited November 18, 2017 by BatMan22 code didn't insert
Bowmore Posted November 18, 2017 Posted November 18, 2017 For what you are wanting to do _FileWriteFromArray is the wrong function to use. It is designed to write the whole or specified section of the array to a file at once. As such it creates a new file each time overwriting any existing file. For your purposes you need to use FileWrite or FileWriteLine as shown in the example below. #include <FileConstants.au3> Global $ColumnC[10] Global $ColumnB[10] $ColumnC[1]="300.0" $ColumnC[2]="300.0" $ColumnC[3]="300.1" $ColumnC[4]="300.0" $ColumnC[5]="300.1" $ColumnB[1]="Sample1" $ColumnB[2]="Sample2" $ColumnB[3]="Sample3" $ColumnB[4]="Sample4" $ColumnB[5]="Sample5" Local $hFile = FileOpen(@ScriptDir & "\IC3.txtm", $FO_OVERWRITE) For $i= 0 to UBound($ColumnC) -1 ;~ ConsoleWrite($ColumnC[$i] & @LF) If $ColumnC[$i]="300.1" Then FileWriteLine(@ScriptDir & "\IC3.txt", $ColumnB[$i] & " " & $ColumnC[$i]) EndIf Next FileClose($hFile) ConsoleWrite(UBound($ColumnC)) BatMan22 1 "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook
Danyfirex Posted November 18, 2017 Posted November 18, 2017 (edited) Hello. You could do this: Global $ColumnC[5] Global $ColumnB[5] $ColumnC[0] = "300.0" $ColumnC[1] = "300.0" $ColumnC[2] = "300.1" $ColumnC[3] = "300.0" $ColumnC[4] = "300.1" $ColumnB[0] = "Sample1" $ColumnB[1] = "Sample2" $ColumnB[2] = "Sample3" $ColumnB[3] = "Sample4" $ColumnB[4] = "Sample5" ;make sure $ColumnC and $ColumnB have same bound For $i = 0 To UBound($ColumnC) - 1 If $ColumnC[$i] = "300.1" Then FileWrite(@ScriptDir & "\IC3.txt", $ColumnB[$i] & " " & $ColumnC[$i] & @CRLF) EndIf Next Saludos Edited November 18, 2017 by Danyfirex BatMan22 1 Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut
BatMan22 Posted November 18, 2017 Author Posted November 18, 2017 You guys rock.. Now I can expand from here
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