Forum .LRN Q&A: slash and tcl

Collapse
Posted by Douillard David on
Hi

I use Redhat 7.3, Openacs4.6 and dotlrn1.0.
"/" in tcl program are not interpreted.
Example :
user_new -param1 x /
-param2 y /
-param3 v

But
user_new -param1 x -param2 y -param3 v works fine.

Collapse
2: Re: slash and tcl (response to 1)
Posted by Peter Marklund on
What you are looking for is the backslash (\) not the slash. The backslash works fine in Tcl to break long lines.
Collapse
3: Re: slash and tcl (response to 2)
Posted by Douillard David on
Thanks,
Exact backslash, not slash.

But it doesn't work !

element create add_user first_name
- label "Fist Names" \
- datatype text
- .........

error invalid command name "-label"

no error if it is on the same line.

Collapse
4: Re: slash and tcl (response to 1)
Posted by Peter Marklund on
Could you copy and paste into this thread the exact OpenACS code that you are using along with the full error stack trace please? In your example you are missing backslashes on some lines.
Collapse
5: Re: slash and tcl (response to 1)
Posted by Neophytos Demetriou on
Douillard, you need to add a backslash at the end of the first line.
Collapse
6: Re: slash and tcl (response to 5)
Posted by Douillard David on
In user_add.tcl /packages/dotlrn/www

element create add_user target_user_id \
    -label "User ID" \
    -datatype integer \
    -widget hidden \
    -value $target_user_id

My error

Request Error
invalid command name "-label"
    while executing
"-label "User ID" -datatype integer -widget hidden -value $target_user_id
"
    ("uplevel" body line 56)
    invoked from within
"uplevel {
          #
#  Copyright (C) 2001, 2002 MIT
#
#  This file is part of dotLRN.
#
#  dotLRN is free software; you can redistribute it and/or..."
    (procedure "code::tcl::/web/elearning/packages/dotlrn/www/user-add" line 2)
    invoked from within
"code::tcl::$__adp_stub"
    invoked from within
"if { [file exists $__adp_stub.tcl] } {

      # ensure that data source preparation procedure exists and is up-to-date
      adp_init tcl $__adp_stub
..."
    ("uplevel" body line 3)
    invoked from within
"uplevel {

    if { [file exists $__adp_stub.tcl] } {

      # ensure that data source preparation procedure exists and is up-to-date
      adp_init t..."
    (procedure "adp_prepare" line 2)
    invoked from within
"adp_prepare "
    (procedure "template::adp_parse" line 30)
    invoked from within
"template::adp_parse [file root [ad_conn file]] {}"
    (procedure "adp_parse_ad_conn_file" line 7)
    invoked from within
"$handler"
    ("uplevel" body line 2)
    invoked from within
"uplevel $code"
    invoked from within
"ad_try {
    $handler
      } ad_script_abort val {
    # do nothing
      }"
    invoked from within
"rp_serve_concrete_file [ad_conn file]"
    (procedure "rp_serve_abstract_file" line 60)
    invoked from within
"rp_serve_abstract_file "$root/$path""
    ("uplevel" body line 2)
    invoked from within
"uplevel $code"
    invoked from within
"ad_try {
    rp_serve_abstract_file "$root/$path"
    set tcl_url2file([ad_conn url]) [ad_conn file]
    set tcl_url2path_info([ad_conn url]) [ad_conn path_inf..."

Ok if i put my parameters on the same line

Collapse
7: Re: slash and tcl (response to 1)
Posted by Andrew Grumet on
I have occasionally run into a problem where multi-line commands with correct-looking syntax simply don't work.  In these cases the file had been editing on a Windows system introducing Windows linebreaks, which are different from Unix linebreaks in some way that just happens to break Tcl's multi-line parsing.

If you suspect this could be a factor, you have two options: a) put everything on one line; b) remove windows linebreaks using Emacs (C-x RET F undecided-unix) or some other means.

Collapse
8: Re: slash and tcl (response to 7)
Posted by Douillard David on
I'm afraid it's that.
I downloaded the files under Windows with Wincvs.
Collapse
9: Re: slash and tcl (response to 8)
Posted by Tilmann Singer on
Some other means to convert the file to unix line breaks would be the command fromdos - many distributions have it installed by default.

Another reason for the error might be that the backslash is not the last character on the line, e.g. when you have another space behind it.

Collapse
10: Re: slash and tcl (response to 1)
Posted by Jon Griffin on
Also, it will break if there is a space after the backslash.
Collapse
11: Re: slash and tcl (response to 10)
Posted by Douillard David on
I didn't modify the program source.

I just downloaded it with wincvs on Winnt and then
copy the files to my server.

Does Tcl have a config file somewhere ?

Collapse
12: Re: slash and tcl (response to 1)
Posted by Don Baccus on
This won't help you today but AOLserver 4.0 will shortly (in the next couple of months, I believe) support Win32 natively.

Which means it will treat thost nasty <cr><lf> pairs that windows uses instead of the Unix world's <lf> as a single character, fixing this problem.

I believe Tcl's interpreting the <cr> as whitespace because it's running as a Unix program (under Cygwin, I imagine) not as a Win32 program, and has no way of knowing that you've in essence converted the source file to Windows.

Search for Jamie Rassmussen - he's our most experienced Win32 person (he's doing the AOLserver 4.0 Win32 support) and he can probably tell you the simplest way to make sure you get the files downloaded to your system in a way that the current Tcl environment will support.

Collapse
13: Re: slash and tcl (response to 1)
Posted by Jamie Rasmussen on
Andrew Piskorski suggested this one-liner to me to batch convert files from Windows to Unix line endings (in a Unix env): find . -type f -print | xargs fromdos

If you are going to edit Unix files from Windows, I recommend Emacs, which gracefully handles the line ending issue.

It doesn't sound like Douillard actually wants to run dotLRN on Windows, but since Don brings it up... 😊 Win32 support should be going into the AOLserver 4 branch soon, but probably after the next beta release is tagged. I've also sent the ACT information on the AD13 commands 4.0 needs to fully support OpenACS. I don't expect those in the upcoming beta either, but presumably for 4.0 final.

Collapse
14: Re: slash and tcl (response to 13)
Posted by Douillard David on
Small precision :
I use a red hat server not a windows server.
I have just downloaded my files with wincvs under windows at home because my server is behind a firewall at work.
Collapse
15: Re: slash and tcl (response to 13)
Posted by Douillard David on
Thanks a lot,

It works fine