[RESOLVED] This works in Windows but not in Mac. Seems very basic, please help.

It is seeing the if statement as false and not printing “Works”. It does read the file and position[1] does equal “1”. There are no errors. Again this works in Windows but not on Mac. Same code, same Corona build.

position = {}

local i = 1

filePath = system.pathForFile( “data.txt”, system.DocumentsDirectory )

local file = io.open( filePath, “r” )

    local contents = file:read( “*a” )

    io.close( file )

    local ylast = 130

    for line in io.lines(filePath) do  

        position[i] = line

        local t = display.newText( position[i], 15, ylast, nil, 30 );

        t:setTextColor( 255, 255, 255 );    

        ylast = ylast + 20

        i = i + 1

    end

    

    if position[1] == “1” then

        local tt = display.newText( “Works”, 25, 800, nil, 50 );

        tt:setTextColor( 255, 255, 255 );    

    end

Ok I got it to work. It seems when I recreated the text file on the mac it solved the problem. For some reason it didn’t like the txt file that I brought over from windows. 

Good observation and that very well could be a potential issue.   Windows uses a 2 character line ending (the CR and LF characters) or sometimes just the CR character (CTRL-M or ASCII 13).  Mac OS-X is a Unix variant where a single LF character marks the end of a line (CTRL-J or ASCII 10).  Depending on how you copied them over, the end of line markers may not have been updated for the Operating system’s standards.

Ok I got it to work. It seems when I recreated the text file on the mac it solved the problem. For some reason it didn’t like the txt file that I brought over from windows. 

Good observation and that very well could be a potential issue.   Windows uses a 2 character line ending (the CR and LF characters) or sometimes just the CR character (CTRL-M or ASCII 13).  Mac OS-X is a Unix variant where a single LF character marks the end of a line (CTRL-J or ASCII 10).  Depending on how you copied them over, the end of line markers may not have been updated for the Operating system’s standards.