Thanks for your feedback to both of you.
Paul:
My first trial was based on your presentation of ]CreateProject during Dyalog'18 user meeting but it doesn't react as you did. Now, it is asking me confirmation for the creation and opens the cider_config file. Not suitable in my case for running in batch mode and I gave up with this option. Can you tell if ]Link is a better option than ]CreateProject?
At least, it is sure that I have better results using ]Link that I had with ]SNAP.
So, I have adapted my code as follows:
Code: Select all
#!/bin/bash
INDIR="$PWD/_SANDBOX_"
OUTDIR="$PWD/_SANDBOX_UNICODE_"
LOGFILE="$PWD/link_all.log"
TEMPFILE="$PWD/link_temp.log"
ERRFILE="$PWD/link_err.log"
rm -r $OUTDIR
rm $LOGFILE $ERRFILE
OIFS="$IFS"
IFS=$'\n'
for ws in `find $INDIR -type f \( -name "*.dws" -o -name "*.DWS" \)`
do
echo "WS: $ws"
echo "WS: $ws" >> $LOGFILE
NEWDIR=$(dirname -- "$ws")
NEWDIR=${NEWDIR/$INDIR/$OUTDIR}
echo $NEWDIR
mkdir $NEWDIR
cd $NEWDIR
filename=$(basename -- "$ws")
extension="${filename##*.}"
WS_name="${filename%.*}"
/usr/bin/dyalog -tty << END_OF_FILE > $TEMPFILE
⎕PW←256
)xload "$ws"
]Link.export # "./WS_$WS_name" -arrays
)OFF
END_OF_FILE
if grep -q "File name case clash" "$TEMPFILE"; then
echo "-> Force casecode" >> $LOGFILE
echo " Issue for $(grep "^#." $TEMPFILE | tr -d ' ' | tr '\n' ' ')" >> $LOGFILE
/usr/bin/dyalog -tty << END_OF_FILE2 > $TEMPFILE
⎕PW←256
)xload "$ws"
]Link.export # "./WS_$WS_name" -arrays -casecode
)OFF
END_OF_FILE2
fi
if grep -q "ERROR" "$TEMPFILE"; then
echo "WS: $ws" >> $ERRFILE
cat $TEMPFILE >> $ERRFILE
echo "-> Error for $(grep "^#." $TEMPFILE | tr '\n' ' ')" >> $LOGFILE
echo " Retry without these objects..." >> $LOGFILE
rm -r ./WS_$WS_name
/usr/bin/dyalog -tty << END_OF_FILE3 > $TEMPFILE
⎕PW←256
)xload "$ws"
)erase $(grep "^#." $TEMPFILE | tr '\n' ' ')
]Link.export # "./WS_$WS_name" -arrays -casecode
)OFF
END_OF_FILE3
if grep -q "ERROR" "$TEMPFILE"; then
echo "WS: $ws" >> $ERRFILE
cat $TEMPFILE >> $ERRFILE
echo " Still not working..." >> $LOGFILE
fi
else
cat $TEMPFILE >> $LOGFILE
fi
/usr/bin/dyalog -tty << END_OF_FILE4
⍝ ⎕SE.Link.Import # ''WS_$WS_name'' -overwrite not working
⍝ #.⎕FX'∆WS_LX' '⎕SE.Link.Import # ''WS_$WS_name'''
⍝ #.⎕FX'∆WS_LX' '⎕SE.Link.Import # (⎕WSID,WS_$WS_name)'
#.⎕FX'∆WS_LX' '⎕SE.Link.Import # ''$NEWDIR/WS_$WS_name'''
)SAVE $WS_name
)OFF
END_OF_FILE4
done
IFS="$OIFS"
rm $TEMPFILE
grep -v "Opening in existing browser session." $LOGFILE
grep -v "Opening in existing browser session." $ERRFILE
The shell script looks for all workspaces in the tree in input folder and creates a new WS_<migated> folder at the same location in the output folder with all the content saved at separate files.
Now, I tried to generate a workspace file linked to the folder but it works only on the command line. It seems that there is currently an issue with Create (
https://github.com/Dyalog/link/issues/654). So I tried to use import instead. For backward compatibility with the current setup, the idea was to create an "empty" workspace with one unique function ∆WS_LX used when I open the workspace.
I have two issues with this:
- I would like to use relative paths. It works if I do interactively:
]CD 'my/path'
⎕SE.Link.Import # 'WS_<myworkspace>'
But I tried to concatenate for linking the ressource folder based on location of the current workspace and it doesn't seem to work. The expression
⎕SE.Link.Import #(⎕WSID,'/<myworkspace>')
says that the path is not correct even it looks ok.
If I hardcode the path, it works. I can open the workspace and everything is reimported. This is mainly due to my inexperience in APL but I didn't manage to have something dynamic.
- My second issue is that the overwrite option seems not to work properly. As soon as save my workspace, it fails afterwards to open because the objects are already in the workspace. We can supposedly overcome this issue using overwrite option but it seems not be recognized as a valid option.
On the general strategy, this is indeed my goal to merge them into one workspace with separated namespaces if possible. But as they are interlinked somehow, I need to process step by step. Merging them from will break all the dependencies.
Andy:
The original project in production is running on Dyalog 17 Classic on Windows. I have created a sandbox on Ubuntu with Dyalog 19 to try to extract the content. I don't know what exactly you mean by not looking to wfs files but my files are wfs files. There is no other type of file and your command gives me the same output. But it helps me for giving you more details on the original files: They are all 32-bit classic little-endian version 17.8. I am attending to recreate them into 64-bit unicode little-endian version 19.9 with code managed in a git.