Jump to content


Photo

SetFormat ...


  • Please log in to reply
1 reply to this topic

#1 Beastmaster

Beastmaster
  • Members
  • 191 posts

Posted 30 April 2004 - 10:19 AM

I'm parsing/filtering a file. The output file should get a trailer line which contains the count of lines which have been transfered to it (without header- and trailer line, --> number of lines - 2)

Cause the number of lines changes from file to file I thought about to use the SetFormat command. But it seems not to work ...

With a static value (no variable) it has worked fine, using: SetFormat, float, 06.0

A shrinked code (without the SetFormat command) for testing 8)

Loop, read, a.txt, b.txt
{
	LC++
	If A_LoopReadLine <> %PrevA_LoopReadLine%
		FileAppend, %A_LoopReadLine%`n
	PrevA_LoopReadLine = %A_LoopReadLine%
	IfInString, %A_LoopReadLine%, TLR
	{
		LC -= 2
		FileAppend, TLR%LC%
	}
}
The format of the trailer has to be: TLRxxxxxx

BTW:
I think the sample lines in AHK's help on SetFormat are not realy helpfull :cry:
- cause it's only a repeat of the syntax :oops:

Something like:

If number is 12.333333

SetFormat, float, 06.0 --> 000012
SetFormat, float, 0.2 --> 12.33
SetFormat, ...


that should point out directly what an unexperienced user will get if using ... :wink:
Have I ever mentioned that math wasn't my favourite at school :roll: :D

#2 Chris

Chris
  • Administrators
  • 10727 posts

Posted 30 April 2004 - 11:18 AM

I think the sample lines in AHK's help on SetFormat are not really helpful

I will add examples like yours, thanks. I'm always interested in improving the help file; I know certain sections are somewhat weak.

Cause the number of lines changes from file to file I thought about to use the SetFormat command. But it seems not to work ...

For specified float format to take effect, at least one of the inputs to an operation must contain a decimal point. Once a float such as 000003 has had it's decimal point removed (due to rounding off), you have to do it another way, perhaps this: LC -= 2.0