Recurring function

Discussion in 'Rebol' started by MaxV, Sep 1, 2010.

  1. MaxV

    MaxV Member

    :confused: I worte the following script to list all the directories. It doesn't work, why?
    Code:
    elenco: copy [ ]
    funz_cerca: func [ /local a ] [
    	a: read %.
    	foreach file a [
    		if dir? file [
    			append elenco (to-string file)
    			change-dir file
    			funz_cerca
    			]
    		]
    	]
    funz_cerca
    write %listadir.txt elenco
    
  2. MaxV

    MaxV Member

    EUREKA!!! I resolved.
    Code:
    elenco: copy [ ]
    funz_cerca: func [ /local a ] [
    	a: read %.
    	foreach file a [
    		if dir? file [
    			append elenco (to-string file)
    			change-dir file
    			funz_cerca
                            change-dir %..
    			]
    		]
    	]
    funz_cerca
    write %listadir.txt elenco
    
  3. Sunanda

    Sunanda New Member

    You do not seem to be specifying the folder name in a way REBOL is happy with.

    This should work:

    Code:
    elenco: copy [ ]
    funz_cerca: func [curr-dir [file!] /local a ] [
    	a: read curr-dir
    	foreach file a [
    		if dir? file [
                print file
    			append elenco (to-string file)
    			attempt [funz_cerca join curr-dir file]
    			]
    		]
    	]
    funz_cerca what-dir
    probe elenco

Share This Page