All my inputs only work if i put a full stop at the end of them. Is there anyway to make it so i can just input something and press enter. Also those inputs can only be one word so i can't make and spaces.
Thanks for the help.
I have my program reading in data from a file but i want it to create a file if the given filename does not exist.
read(File),
open(File, read, S),
read(S, X),
close(S),
doStuff(X).
I have found that in the open line I should be able to have | open(File, readwrite, S),
but that doesn't work...
I am using swi-prolog and I can't get formatted io to work.
I have been taught: fmt_read() and fmt_write()
are those correct?
Why isn't it working?
Thanks
Ok I haven't really found any clear way of doing an If statement in PROLOG. I want to read a word into a variable and then run either one of 2 functions if the answer is yes or no.
Bare in mind I am very new to PROLOG so here is what I have:
read(Var),
yesVar :-
Var="Yes", yesFunction(Var)...
I am simply trying to set-up my prolog environment and ii have a simply program.
write(a).
that's it...
It always tells me "No permission to modify static procedure `write/1'"
Also does the same for read. As i have never used prolog is it something wrong with how i have set it up or do i need...
Is there a set length you of line you can put code on?
Eventually if a line goes too long i get an error and it clearly just stops mid line and outputs a random error.
It's really annoying when i want a line of text on one line
so is there a way i can say print this on one line:
print *, 'This...
If i have a text file say:
"dog cat mouse elephant"
and i want to read those into an char array the reader always just reads dog and then moves to a new line.
I don't know how many 'animals' will be in the text file so i can't just
read (7,*) animal(1), animal(2) etc, but i do know there isn't...
I thought calling a function seemed easy enough until i tried to write one.
I though it was as easy as:
program test
testFunction()
end program test
FUNCTION testFunction()
print *, "Hello World"
END
EDIT:
ok so why does below work. I just want a function that makes my code cleaning. No...
Can someone tell me how to write whole lines to text files. Here is what I have tried but got just the first word 'do'.
is has opened unit 7 as append for an existing file
CHARACTER*50 newQuestion
read *, newQuestion
write(7, '(A)') newQuestion
say i type "do you want to?" it only adds the 'do'...
I have tried everything to get a simple bit of code to work but nothing has worked.
pseudocode:
get user answer (yes/no)
if answer = yes
print yes
I always get the same error "Cannot assign to a named constant"
i have tried
--
t = LGT(answer, 'yes')
IF(t)
--
if(answer .eq. 'yes)
--...
Hi all just wondering how to get a line of text into a character string.
What i have now gets the first word but I want the whole line
character*50 data
open (7, FILE = 'animals')
read (7, *) data
print *, data
thanks
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.