Home   Archive   Permalink



Strange behave when read files

Hi people
how can I force rebol not to add my home-path to the file-name, when
the script is started from a batch-file?
    
This comes out:
#########################
%C:/reb2bat/make_frame.r
** Access Error: Cannot open /C/Dokumente und Einstellungen/Administrator/C:/reb2bat/make_frame.r
** Near: fin: read to-file input
forever
>>
#########################
    
    
printed by the following commands:
#########################
probe to-file input
fin: read to-file input
forever []
#########################
    
    
As you can see the homepath "/C/Dokumente und Einstellungen/Administrator/" is automatically added to the file %C:/reb2bat/make_frame.r
    
any idea?
Best rgds,
Holger
    
Ps.: I'm still new in Rebol


posted by:   Holger     23-Feb-2012/15:40:50-8:00



OK,
I fixed this my self:
    
arg: to-string system/options/args
replace/all arg "\" "/"
replace/all arg ":" ""
replace/all arg ".r" ""
filen: last parse/all arg {/}
path: to-file join "/" replace arg filen ""
    
system/options/path: path
system/script/path: path
system/script/parent/path: path


posted by:   Holger     23-Feb-2012/20:19:16-8:00



ok thats what it is all about:
    
save this as "rebol2bat.bat"
@rem #######################################################################
@echo off
echo R E B O L []>go.r
echo do decompress>>go.r
echo #{>>go.r
echo 789C7D50416E033108BCF30AE47BE3FB7E25CDC1DDB0892B8A2D2055A3AA7F2F>>go.r
echo EB6C15A5957A4168661806945E1AE3FE0050F434A1B72773AD7242BB9AD35B6E>>go.r
echo DD6B13CBC11A28752E33E5C28C01607A4E9872FA8B4F8127582A934CC8C51C7B>>go.r
echo 51BB0B3EF317F4E2E7B17095E16BABB27AE1E63564C36075825F696EB36BFD61>>go.r
echo 6CD6DAFD3F42491E78A8D22F7E4F705B06EDE20FF008B605D905B9F30F8F404B>>go.r
echo 8DCB94CA317315321C66B0B480E633724CC81E7A7CD291E1B075E9D884D250BD>>go.r
echo 93C6D3BF01088F827D7E010000>>go.r
echo }>>go.r
rebol -s go.r %1
del go.r
@rem #######################################################################
    
    
save this as "print.r"
;###########################################################################
R E B O L []
arg: to-string system/options/args
replace/all arg "\" "/"
replace/all arg ":" ""
filen: last parse/all arg {/}
path: to-file join "/" replace arg filen ""
system/options/path: path
system/script/path: path
system/script/parent/path: path
input: to-file filen
fin: read/lines input
foreach l fin[
print l
]
print "done"
forever[]
;###########################################################################
    
you need to have rebol.exe somewhere in a place, that it can run from anywhere
    
drag "print.r" to "rebol2bat.bat" don't care about anything.
You'll get print.bat, that just runs from everywhere (you drag any file onto "print.bat" no "print.r" needed any more!)
    
follow the rules:
    
arg: to-string system/options/args
replace/all arg "\" "/"
replace/all arg ":" ""
filen: last parse/all arg {/}
path: to-file join "/" replace arg filen ""
system/options/path: path
system/script/path: path
system/script/parent/path: path
    
makes it possible for you to get the arguments (usualy files) by drag them onto the bat-file
    
have fun.
Holger


posted by:   Here the result     23-Feb-2012/20:51:10-8:00



If the leading % in a file! value is followed by a /, the filepath is taken to be absolute. If not it is taken to be a relative path.
    
You cold solve your problem by using the following:
    
%/C/reb2bat/make_frame.r

posted by:   Peter Wood     24-Feb-2012/21:14:41-8:00



Sounds good.
I'll do some tests using this.
    
Thanx a lot
:)

posted by:   Holger     27-Feb-2012/16:38:29-8:00