找回密码
 加入
搜索
查看: 2232|回复: 7

[AU3基础] 请教用2个for的问题[已解决]

  [复制链接]
发表于 2010-5-9 22:37:47 | 显示全部楼层 |阅读模式
本帖最后由 supertiger 于 2010-5-10 00:06 编辑

我有2个档案
test1.txt         test2.txt
A                     1   
B                     2
C                     3
D                     4
E                     5

然后依序组合起来写入第3个档案
test3.txt
A1
B2
C3
D4
E5
我用2个for好像做不到
请问大大该怎么写才能做到?

评分

参与人数 1金钱 +10 收起 理由
afan + 10 感谢主动将修改帖子分类为[已解决],请继续 ...

查看全部评分

发表于 2010-5-9 22:44:08 | 显示全部楼层
分别两个循环读两个文件,在第三个文本中追加数据就好了.
发表于 2010-5-9 22:47:38 | 显示全部楼层
Local $test1 = FileOpen('test1.txt')
Local $test2 = FileOpen('test2.txt')
Local $Line1, $Line2, $str
While 1
        $Line1 = FileReadLine($test1)
        $Line2 = FileReadLine($test2)
        If @error = -1 Then ExitLoop
        $str &= $Line1 & $Line2 & @CRLF
WEnd
FileClose($test1)
FileClose($test2)
FileWrite('test3.txt', $str)
 楼主| 发表于 2010-5-9 23:20:01 | 显示全部楼层
楼上的大大对不起,我说错了
因为test2的文件是有隔1行的
test3应该是这样
A1
B3
C5
以此类推下去
真是抱歉
发表于 2010-5-9 23:48:42 | 显示全部楼层
Local $test1 = FileOpen('test1.txt')
Local $test2 = FileOpen('test2.txt')
Local $Line1, $Line2, $str, $x = 1
While 1
        $Line2 = FileReadLine($test2)
        If @error = -1 Then ExitLoop
        If Mod($x, 2) = 1 Then
                $Line1 = FileReadLine($test1)
                $str &= $Line1 & $Line2 & @CRLF
        EndIf
        $x += 1
WEnd
FileClose($test1)
FileClose($test2)
FileWrite('test3.txt', $str)
 楼主| 发表于 2010-5-10 00:05:27 | 显示全部楼层
感谢版主的指导,问题己解决
发表于 2010-5-10 01:47:00 | 显示全部楼层
如果两个文本行树不等那么第二个是不是读不到了呢?
发表于 2010-5-10 01:48:43 | 显示全部楼层
如果两个文本行树不等那么第二个是不是读不到了呢?
kxing 发表于 2010-5-10 01:47



    是第一个读不到了。读到了有用吗?
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-6-2 09:42 , Processed in 0.084393 second(s), 28 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表