File name issues (bug)??

Linux specific questions.
Post Reply
Helium5793
Posts: 42
Joined: Jun 21, 2016 13:06

File name issues (bug)??

Post by Helium5793 »

I am using Fedora 31 64 bit. I am trying to translate some old quickbasic programs to freebasic (not qb compatible freebasic) while attempting to learn it.
Some of my old data files have dashes in the name. Linux and windows both support dashes in the name. When loading these files in freebasic I am having a problem. I have 'sort of' solved it by removing all the dashes, but this seems to be a 'bug'.

As an example the file 'element-new.data' will not load. No error is given, and the program goes on, but no data has been loaded. The file 'element.data' created just by changing the name (same data) loads the data gives no error and the data loads fine and the program goes on. It seems at the very least, if dashes are not acceptable this should throw an error. Since all the O.S.s support dashes, I would think that FB would support them.

I have tried this with several files (mostly comma separated variables) and I can post the programs and data files if needed.


John
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: File name issues (bug)??

Post by MrSwiss »

Hi,

as long as you've got library issues (libtinfo* e.t.c) you'll not know anything for certain.
Reason: you are currently having "undefined behaviour", which can be anything.
As a result, you may encouter any number of 'bugs' which are not really there.

Therefore, sort out your FBC installation first (before opening more threads).
I don't think that FBC has any (real) issues with undeline/dash characters.
(I'm using both in the very same file-name, without problems.)
badidea
Posts: 2594
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: File name issues (bug)??

Post by badidea »

This works fine here on Ubuntu Mate 18.04 64-bit, fbc 1.07.1 32-bit & fbc 1.07.1 64-bit:

Code: Select all

dim as string fileName = "-test-file-.1-2"
dim as integer fileNum = freefile

if open(fileName, for output, as fileNum) <> 0 then
	print "Error opening file for write: " & fileName
else
	print #fileNum, "This is a test"
	close #fileNum
	print "Data written to: " & fileName
end if

if open(fileName, for append, as fileNum) <> 0 then
	print "Error opening file for append: " & fileName
else
	print #fileNum, "Add another line of text"
	close #fileNum
	print "Data written to: " & fileName
end if

dim as string dataStr = ""
if open(fileName, for input, as fileNum) <> 0 then
	print "Error opening file for input: " & fileName
else
	Print "Read data from: " & fileName
	while not eof(fileNum)
		line input #fileNum, dataStr
		print " " & dataStr
	wend
	close #fileNum
end if

print "End"
while inkey = "" : sleep 1 : wend
robert
Posts: 169
Joined: Aug 06, 2019 18:45

Re: File name issues (bug)??

Post by robert »

badidea wrote:This works fine here on Ubuntu Mate 18.04 64-bit, fbc 1.07.1 32-bit & fbc 1.07.1 64-bit:

Code: Select all

dim as string fileName = "-test-file-.1-2"
dim as integer fileNum = freefile

if open(fileName, for output, as fileNum) <> 0 then
	print "Error opening file for write: " & fileName
else
	print #fileNum, "This is a test"
	close #fileNum
	print "Data written to: " & fileName
end if

if open(fileName, for append, as fileNum) <> 0 then
	print "Error opening file for append: " & fileName
else
	print #fileNum, "Add another line of text"
	close #fileNum
	print "Data written to: " & fileName
end if

dim as string dataStr = ""
if open(fileName, for input, as fileNum) <> 0 then
	print "Error opening file for input: " & fileName
else
	Print "Read data from: " & fileName
	while not eof(fileNum)
		line input #fileNum, dataStr
		print " " & dataStr
	wend
	close #fileNum
end if

print "End"
while inkey = "" : sleep 1 : wend
The code above compiles and executes as expected on my Fedora 31 X64 machine.
caseih
Posts: 2158
Joined: Feb 26, 2007 5:32

Re: File name issues (bug)??

Post by caseih »

Helium5793 wrote:As an example the file 'element-new.data' will not load. No error is given, and the program goes on, but no data has been loaded.
As always, compile with -exx so that runtime error checking is enabled. Often that will catch weird things that don't crash the program (but probably should).
Helium5793
Posts: 42
Joined: Jun 21, 2016 13:06

Re: File name issues (bug)??

Post by Helium5793 »

Thank you for all your replies. I have spent days now on the libtinfo error, and since the library is there, it is difficult to figure out why freebasic doesn't read it. I appreciate knowing the dashes work under ubuntu. That may be a clue I can use.
John
Helium5793
Posts: 42
Joined: Jun 21, 2016 13:06

Re: File name issues (bug)??

Post by Helium5793 »

Thank you for your replies. I thought that was a pretty strange error I was seeing. I was able to download the zip file from github, recompile under Fedora using the provided make file, copy the recompiled fbc program over the one installed using the method on github for fedora. Once I did the the libtinfo.so.5 error and the linking error disappeared. After doing that this file loading error disappeared also, and I can now load files with dashes.

Thank you all for your help,
John
srvaldez
Posts: 3381
Joined: Sep 25, 2005 21:54

Re: File name issues (bug)??

Post by srvaldez »

I believe that the pre-compiled FB distribution is using an older version of libtinfo.so.5 hence the problem.
Post Reply