Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search results for query: *

  1. Samohtvii

    gprolog read line.

    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.
  2. Samohtvii

    Creating a file if does not exist

    Hmm that still doesn't work. It finds it if the file exists but not if it doesn't. I am using gprolog
  3. Samohtvii

    Creating a file if does not exist

    I think that works but i need to say if the file doesn't exist create it and now do something else e.g. If(file_does_not_exist) /*do something*/ else /*extract file contents*/ right now it is creating the file but can't read anything because it's empty so i need to skip that if the file...
  4. Samohtvii

    Creating a file if does not exist

    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...
  5. Samohtvii

    PROLOG if statements

    Sorry, all good. Had to change some of my code but got it. Thanks
  6. Samohtvii

    formatted io.

    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
  7. Samohtvii

    PROLOG if statements

    That doesn't seem to work. Any other thoughts.
  8. Samohtvii

    PROLOG if statements

    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)...
  9. Samohtvii

    Can't run the simplest of programs. HELP

    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...
  10. Samohtvii

    Line length in FORTRAN

    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...
  11. Samohtvii

    Writing whole strings including whitespace?

    hmm still the same problem :S Changed the read and writes like you said but exactly the same. Maybe the full code will help a bit more CHARACTER*20 new Animal CHARACTER*50 newQuestion read *, newAnimal read '(A100)', newQuestion OPEN(7, fileName, ACCESS='APPEND') WRITE(7, '(A100)')...
  12. Samohtvii

    Avoid reading to new line

    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...
  13. Samohtvii

    Calling functions

    ahh awesome thanks.
  14. Samohtvii

    Writing whole strings including whitespace?

    hmm that seems to work kind of. IT reads the line into the txt file but the last word is always added to the next line. So if the newQuestion is: "How are you?" it will be added How are you? thoughts? Thanks for the help
  15. Samohtvii

    Calling functions

    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...
  16. Samohtvii

    Writing whole strings including whitespace?

    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'...
  17. Samohtvii

    IF statements and comparing character strings

    Got it. Thanks guys.
  18. Samohtvii

    Reading lines of text from file

    Well I have it reading in a whole question with the first (A) that was posted. The I have some possible answers like Horse:Dog:Cat So i would get them one by one and add them to a character string array. Don't have to tell me how to do the whole thing just teach me how to read until a : then do...
  19. Samohtvii

    IF statements and comparing character strings

    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) --...
  20. Samohtvii

    Reading lines of text from file

    Thanks that works perfect. How would I go about reading until a ":" is found? and does fortran have an if(!eof) if not end of file statement i can use? Sorry but I am just starting and am having a bit of trouble. Thanks

Part and Inventory Search

Back
Top