Prolog: using tell to create another .pl - prolog

So here is a method in my program where i want to write everything to the 'currentState.pl' however when i consult the file i get this error, line 27 is the tell() method. Any help would be greatly appreciated.
.pl:27:24: Syntax error: Operator expected
saveState:-
tell(‘currentState.pl’),
listing(on),
listing(left),
listing(holding),
told,
write('Current State Saved'),nl.

I think it should be tell('currentState.pl'), instead of tell(‘currentState.pl’), ' instead of ‘ or ’

Related

How to escape a doublequote-sign inside a (tau) prolog string?

I guess there must be an easy answer to this, but I just haven't been able to find it -
I want to include double-quote signs inside tau-prolog strings.. how to do it?
When I try entering it into the Tau-Prolog sandbox (http://tau-prolog.org/sandbox/) I get the following interaction:
A = "hello there, \"world\"".
error parsing query: error(syntax_error(unknown_escape_sequence),[line(1),column(4),found('"hello there, \\"')])
Any ideas?
Where did I (stupidly) misunderstand things? :)
PS - it's not only a problem in the sandbox - if try to run a Tau-Prolog program (in the browser), and use a double-quote character anywhere inside a string I get the same parsing-problem.

Bash variable does not allow a directory name to be assigned to it

I want to create the following variable in Bash:
PATHTOMYDIR=/fshare/users/myusername/
(basically, a variable with a string inside: the path to my directory, where I have my data, that later on can be included in some scripts to generate folders inside that directory, for example).
The concrete problem is: when I typed that line of code I got the following error message:
-bash: /fshare/users/myusername: Is a directory
Hence, I wanted to ask: does Bash not allow a variable to contain the name of a path? I thought it was possible, so I assume I am missing something else here. I googled the error message but I did not find any post at any forum with this case.
I had a space between the "=" and the first "/" of the path.
This makes an error:
PATHTOMYDIR= /fshare/users/myusername/
This is correct:
PATHTOMYDIR=/fshare/users/myusername/
It seems that space makes the difference. Thank you #AIG and #Jason !
EDIT: #Jason pointed out that is good practice to use commas, so a more correct form would be:
PATHTOMYDIR="/fshare/users/myusername/"

syntax error: expression expected

I'm going through a learn Prolog tutorial. I pulled a single line from the example:
happy(yolanda).
and put it into an XGP file. When I compile it I get:
syntax error: expression expected
This same line works ok when I load it into swipl so I guess there's some difference there.
How can I run happy(yolanda) and get a Yes that she is happy in XGP?
I think there was a bad character that showed up when I copy-pasted the code from the website into the .pl file. I deleted all the whitespace and the file started to compile.
  happy(yolanda).
Once the file is saved then in the Evaluate Query box you can run happy(yolanda). and it will say 'Success' just as #lurker said.

invalid character name at (1)

I am trying to compile a fortran code. It will analyze an X file in an Y directory and then create a new file Z with the results. But there is something wrong occurring.
When I write the directory I see that it is too much for one line and then I try to continue it in the next one doing this:
namech='/home/matheus/Documents/UFABC/IC/Spectra/Elliptical/'
+ 'espec.fits'
But, when I try to compile using the command
gfortran Codigo.f -o TESTE -Lcfitsio -lcfitsio
I get this error message:
+ 'espec.fits'
1
Error: Invalid character in name at (1)
Can someone help me? Actually I do not know what this error is. The directory is 100% right. And when I move the archives to a simpler directory to be able to write everything in one line, it works! So is there something wrong with the "+"?
Thank you.
Edit1
Actually, when I add "&" in the end of the line, it gives me this error message:
namech='/home/matheus/Documents/UFABC/IC/Spectra/Elliptical/'&
1
Error: Unclassifiable statement at (1)
Codigo.f:60.7:
+ 'espec.fits'
1
Error: Invalid character in name at (1)
And with "//":
namech='/home/matheus/Documents/UFABC/IC/Spectra/Elliptical/'//
1
Error: Syntax error in expression at (1)
Codigo.f:60.7:
+ 'espec.fits'
1
Error: Invalid character in name at (1)
Edit2
Thank you so much for helping me. Well, I solved the problem switching to the ".f90" form.
Just one more question: do you know why it does not recognize the "c" for comments in the code? Thank you again! :)
This part of your compilation statement:
gfortran Codigo.f
will treat the source file, with its .f suffix, as fixed form source. This means that a continuation line is indicated by any character (other than a blank or a 0) in column 6.
However, the error message you get suggests that the + in the second line of your snippet is not in column 6 and that the compiler is treating it as the initial character in a new entity name for which it is not valid. The fact that the + is aligned, vertically, with n in the previous line strengthens my suspicion that this may the root of your problem.
Adding the ampersand, as suggested in a now-deleted answer, doesn't actually help in this case if you continue to tell the compiler that it is dealing with a fixed form source file. & is only used for continuation in free form source files. Adding the string-concatenation operator, //, doesn't help either since it is not followed by another string but a line ending. //& would help but is probably unnecessary.
I think you have 2 possible solutions, but choose only one:
Stick with fixed form and get the alignment right.
Change the file suffix to .f90 which will cause gfortran to treat the source file as free-form.
If you go for option 2 (which I would recommend) you can then either use & at the end of the continued line or you could simply merge the lines. In free-form the maximum line length is 132 characters.
Adding to High Performance Mark's answer:
If you continue with FORTRAN 77, most compilers have an option to increase the allowed line length, e.g., -ffixed-form -ffixed-line-length-none for gfortran. As already stated, Fortran >=90 has line length of 132, so you wouldn't need to split the line.
Finally, if you want to split the line in Fortran >=90, you need two ampersands. In most cases you need one, but to split a string you need two:
namech='/home/matheus/Documents/UFABC/IC/Spectra/Elliptical/&
&espec.fits'

Export data from mathematica script

I am writing a mathematica script and running it in the linux batch shell. The script gives as a result a list of numbers. I would like to write this list to a file as a one single column without the braces and commas. For this, I tried to use Export comand as
Export["file.txt", A1, "Table"]
but I get the error:
Export::infer: Cannot infer format of file test1.txt
I tried with other format but i got the same error.
Could someone please tell what is wrong and what i can do? Thank beforehand
From what I understand you are trying to export the file in TABLE, why don't you try something like this ,
Export["file.txt", A1, "Text"]
This:
A1 = {1,2,3};
Export["test.tab", Transpose[{A1}], "Table"];
produces a single column without braces and commas.

Resources