Tera Term 4.64 - fileopen and filereadln not working
Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Tera Term 4.64 - fileopen and filereadln not working
PostPosted: Wed Jan 20, 2010 8:10 pm 
Offline
Beginner

Joined: Thu Jul 09, 2009 11:14 am
Posts: 26
Hi,

I have the following apps installed

  • Tera Term 4.64
  • LogMeTT 2.9.7
  • TTLEditor 1.1.5


and started using fileopen and have come to question whether or not these commands work??

Here are the details behind my laptop:
Quote:
------------------
System Information
------------------
Time of this report: 1/20/2010, 19:00:57
Operating System: Windows XP Professional (5.1, Build 2600) Service Pack 3 (2600.xpsp_sp3_gdr.090804-1435)
Language: English (Regional Setting: English)
System Manufacturer: LENOVO
System Model: 7665D89
BIOS: Ver 1.00PARTTBLx
Processor: Intel(R) Core(TM)2 Duo CPU T7300 @ 2.00GHz (2 CPUs)
Memory: 2014MB RAM
Page File: 1194MB used, 2711MB available
Windows Dir: C:\WINDOWS
DirectX Version: DirectX 9.0c (4.09.0000.0904)


I went ahead and ran the tera term sample code to keep it simple but it appears the "text.txt" file never is opened and "filereadln" never populates the variable "line".

Here is the code I'm using to test the "fileopen" function:

  1.  
  2. tmp01 = ''
  3.  
  4. ; Open a file.
  5. fileopen fhandle 'test.txt' 0
  6.  
  7. messagebox fhandle 'USER PROMPT 01'
  8.  
  9. :loop
  10.  
  11. ; Read a line from the file.
  12. filereadln fhandle line
  13.  
  14. messagebox line 'USER PROMPT 02'
  15.  
  16. sprintf2 tmp01 'result = %d' result
  17. messagebox tmp01 'USER PROMPT 03'
  18.  
  19. if result = 1 goto fclose
  20.  
  21. ; Display the line.
  22. messagebox line 'test.txt'
  23.  
  24. ; Repeat until the end of the file.
  25. goto loop
  26.  
  27. :fclose
  28. ; Close the file.
  29. fileclose fhandle
  30.  
  31. end
  32.  


Here is the test.txt file content
  1.  
  2. It seems
  3. fileopen will not
  4. open text files specified
  5. very strange
  6.  


Has anyone experienced this issue with the versions outlined above?


Top
 Profile E-mail  
 
 Post subject: Re: Tera Term 4.64 - fileopen and filereadln not working
PostPosted: Wed Jan 20, 2010 11:19 pm 
Offline
Moderator, LogMeTT developer
User avatar

Joined: Sat Jan 08, 2005 7:52 am
Posts: 1141
Location: Seattle, WA, USA
I tested your code. It worked fine when I added full path to the file name.
Another option would be to change the default directory with setdir before opening the file.

_________________
Thanks.
Best regards,
// Boris


Top
 Profile E-mail  
 
 Post subject: Re: Tera Term 4.64 - fileopen and filereadln not working
PostPosted: Thu Jan 21, 2010 2:05 am 
Offline
Beginner

Joined: Thu Jul 09, 2009 11:14 am
Posts: 26
Hi Boris,

I added the setdir as indicated and the file is now read. Below is the updated change. The only other issue I have is when the end of file is reached, the variable "result" is set to 1 but it appears the goto instruction is not executing?

  • if result = 1 goto fclose

The messagebox displays the fact "result" is set to 1 at the end of the file but will not perform the "goto flclose"? The loop just continues and never ends.

I cannot determine why this is?? Where you able to notice this behavior on your end??

  1.  
  2. setdir 'C:\Documents and Settings\XP User\My Documents\TeraTermScripts'
  3. tmp01 = ''
  4.  
  5. ; Open a file.
  6. fileopen fhandle 'test.txt' 0
  7.  
  8. messagebox fhandle 'USER PROMPT 01'
  9.  
  10. :loop
  11.  
  12. ; Read a line from the file.
  13. filereadln fhandle line
  14.  
  15. sprintf2 tmp01 'result = %d' result
  16. messagebox tmp01 'USER PROMPT 03'
  17.  
  18. if result = 1 goto fclose
  19.  
  20. ; Display the line.
  21. messagebox line 'test.txt'
  22.  
  23. ; Repeat until the end of the file.
  24. goto loop
  25.  
  26. :fclose
  27. ; Close the file.
  28. fileclose fhandle
  29.  
  30. end
  31.  


Top
 Profile E-mail  
 
 Post subject: Re: Tera Term 4.64 - fileopen and filereadln not working
PostPosted: Thu Jan 21, 2010 7:15 am 
Offline
Guru

Joined: Wed Jan 25, 2006 7:28 pm
Posts: 532
Location: Denver, Colorado, USA
If you look in the help file, you see that the sprintf2 command will set the result variable after it executes. This is overwriting the value in result from the filereadln.


Top
 Profile  
 
 Post subject: Re: Tera Term 4.64 - fileopen and filereadln not working
PostPosted: Thu Jan 21, 2010 12:11 pm 
Offline
Beginner

Joined: Thu Jul 09, 2009 11:14 am
Posts: 26
Hi Boris and IshmaelCallMe,

I need to learn to read. I looked up the remarks for sprintf2:

Sprintf2
Quote:
Remarks

As a result of this command, the system variable "result" is set to one of the following values.

Value Status
0 Formatted successfully
1 No format string
2 Invalid format
3 Invalid argument
4 Invalid destnation variable



and as a result created a new variable called "fhandle_result" to preserve the system variable "result" contents. The "if" statement to "goto fclose" now works. I also changed the location of the text file to parse to the "C:\" root directory.

Here is the modified functional code.

  1.  
  2. setdir 'C:'
  3.  
  4. tmp01 = ''
  5. fhandle_result = 0
  6.  
  7. ; Open a file.
  8. fileopen fhandle 'test.txt' 0
  9.  
  10. messagebox fhandle 'USER PROMPT 01'
  11.  
  12. ;------
  13. :loop
  14. ;------
  15.  
  16. ; Read a line from the file.
  17. filereadln fhandle line
  18. fhandle_result = result
  19.  
  20. messagebox line 'USER PROMPT 02'
  21.  
  22. sprintf2 tmp01 'result = %d' fhandle_result
  23. messagebox tmp01 'USER PROMPT 03'
  24.  
  25. if fhandle_result = 1 goto fclose
  26.  
  27. ; Display the line.
  28. messagebox line 'test.txt'
  29.  
  30. ; Repeat until the end of the file.
  31. goto loop
  32.  
  33. :fclose
  34. ; Close the file.
  35. fileclose fhandle
  36.  
  37. end
  38.  


Thank you again for the quick support.


Top
 Profile E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group