AmigaDOS IF question
  • Order of the Butterfly
    Order of the Butterfly
    Cool_amigaN
    Posts: 474 from 2011/11/30
    As a newbie on AmigaDOS, I am facing some difficulty with the IF command.

    I have made a search command for a specific file. If the file exists then I want to start curl, but "IF exist" should point to a specific location according to AmigaDOS manual, whereas I want o search and confirm existence of it and afterwards start curl. Should the search command be executed under "execute"? In any case, how should I format the above IF command?

    [ Edited by Cool_amigaN 24.11.2015 - 12:48 ]
    Amiga gaming Tribute: Watch, rate, comment :)
  • »24.11.15 - 09:47
    Profile Visit Website
  • Order of the Butterfly
    Order of the Butterfly
    igracki
    Posts: 315 from 2003/2/24
    From: Berlin
    Do you use wildcards in the Search command?
    If not, you can just do this:
    Code:

    IF EXISTS filename
    curl filename
    ENDIF
  • »24.11.15 - 13:28
    Profile Visit Website
  • Order of the Butterfly
    Order of the Butterfly
    Cool_amigaN
    Posts: 474 from 2011/11/30
    The search command searches for a specific file without any wildcards throughout sys: (and its sub-directories with ALL enabled).

    With IF EXISTS, to my understanding, you need to specify a certain path (whereas the file could have been installed anywhere on sys:). So, I need a structure that will correspond to: "If search finds the file, then execute curl".

    [ Edited by Cool_amigaN 24.11.2015 - 19:18 ]
    Amiga gaming Tribute: Watch, rate, comment :)
  • »24.11.15 - 16:16
    Profile Visit Website
  • MorphOS Developer
    CISC
    Posts: 616 from 2005/8/27
    From: the land with ...
    Quote:

    Cool_amigaN wrote:
    With IF EXISTS, to my understanding, you need to specify a certain path (whereas the file could have been installed anywhere on sys:). So, I need a structure that will correspond to: "If search finds the file, then execute curl".


    The Search command returns a status code (0 if file found, 5 (or WARN) otherwise) that you can test for with If, like this:

    If NOT WARN
    ...


    - CISC
  • »24.11.15 - 17:37
    Profile
  • Order of the Butterfly
    Order of the Butterfly
    igracki
    Posts: 315 from 2003/2/24
    From: Berlin
    Like CISC says, use IF WARN, so it could like like this:
    Code:

    Search FILE ALL path1 path2 filename
    IF NOT WARN
    Curl
    ELSE
    Echo "filename not found!"
    ENDIF


    This script searches for the file "filename" in path1 and path2 and all subdirs!
  • »25.11.15 - 11:52
    Profile Visit Website