Raised This Month: $ Target: $400
 0% 

read file


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
iCap
BANNED
Join Date: Oct 2007
Old 10-07-2007 , 14:24   read file
Reply With Quote #1

how do you read from a secondary file?
iCap is offline
purple_pixie
Veteran Member
Join Date: Jun 2007
Location: Winchester, England
Old 10-08-2007 , 11:54   Re: read file
Reply With Quote #2

How do you mean?

As in read two files at once? Or just read from a file?

If you mean how to read in general:


PHP Code:
new line,file[128],text[128],length
copy
(file,sizeof file -1,"file to read.txt")
while ( ( 
line read_file(file,line,text,sizeof text -,length) ) )
{
    
log_amx(text)

The "while" line might confuse you ...

First, the loop itself:
The code in {} after the while () will be executed again and again until the expression after while ( in () ) is no longer true.

And secondly the condition:
( line = x ) has the value of x, and sets line to x.

e.g.
PHP Code:
if ( ( line ) )
{
    
log_amx("hello")

would set line to 0, but not log anything (since 0 is false).
(without the extra pair of parentheses, you would get a "possibly unintended assignment" warning.

PHP Code:
if ( ( line ) )
{
    
log_amx("hello")

would set line to 1 and log hello (because 1 is true)

Last edited by purple_pixie; 10-08-2007 at 12:32.
purple_pixie is offline
M249-M4A1
I <3 Mac
Join Date: May 2005
Location: Not interested
Old 10-08-2007 , 12:17   Re: read file
Reply With Quote #3

You should understand a while loop because most reading techniques use a while loop until the end of the file (eof) has been met
__________________
M249-M4A1 is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 16:14.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode