Using a Directory Alias with @iniwrite fails

Code:
c:\users\jlc\documents\dosbox\utils>ver

TCC  22.00.41 x64   Windows 7 [Version 6.1.7601]

I have a directory alias;
Code:
c:\users\jlc\documents\dosbox\utils>alias db:
c:\users\jlc\Documents\dosbox

Using this directory alias with @iniwrite causes it to fail;
Code:
echo %@iniwrite[db:\utils\vdos.ini,vDos,cmd,pause]
-1

Using the actual directory succeeds;
Code:
echo %@iniwrite[c:\users\jlc\documents\dosbox\utils\vdos.ini,vDos,cmd,pause]
0

Is this WAD?

Joe
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,446
88
Albuquerque, NM
prospero.unm.edu
I suspect these functions call WritePrivateProfileString() and GetPrivateProfileString() under the hood. These functions are old and funky: if they are passed a filename without a path, Windows assumes the file is in %WINDIR%, not the current directory. Which is why Rex does not canonicalize the filename he passes to them — it would break the documented, longstanding ... weird ... behavior.
 
Apr 13, 2010
301
7
61
The Hague
I suspect these functions call WritePrivateProfileString() and GetPrivateProfileString() under the hood. These functions are old and funky: if they are passed a filename without a path, Windows assumes the file is in %WINDIR%, not the current directory. Which is why Rex does not canonicalize the filename he passes to them — it would break the documented, longstanding ... weird ... behavior.

That is an illuminating explanation, Charles. Do you also happen to know why TC doesn't support dir-aliases in other places? One that always surprises me is

GOSUB "alias:\fname[.EXT]" Routine

But there are others - should have kept a list. ;-)

DJ
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,446
88
Albuquerque, NM
prospero.unm.edu
That is an illuminating explanation, Charles. Do you also happen to know why TC doesn't support dir-aliases in other places? One that always surprises me is

GOSUB "alias:\fname[.EXT]" Routine

That I don't know. But I'm pretty sure that GOSUB %@TRUENAME[alias:fname.exe] should work.
 
Apr 13, 2010
301
7
61
The Hague
Sure, you can @search @expand, or @full, @truename or even just @alias it yourself. But that's no fun. In that case a dir-alias is just another syntax for the string concatenation we already have.

I remember something called "logical devices" (on DEC VMS machines) which were envars with a special status. Quite similar to dir-aliases in use. When you defined them there was string expansion but also a validity check. After that you had a certain convidence that you could safely use it. Like a guaranteed part of a path you could trust. That's how I use them. And its a fruitfull practice --- until its not.

I sound like a very old man. :oldman:

Dirk Jan Spits.
 
May 20, 2008
11,379
98
Syracuse, NY, USA
I remember something called "logical devices"
Windows has "DOS Devices". There's SUBST.EXE and TCC's PSUBST to manage the ones which act as drive names. The names are limited to single characters but not to A-Z. On Windows 7, these (maybe more) also work: 0, 1, ... 9, !, #, $, +, -. And at least 4: can be made permanent.
Code:
v:\> psubst
* P:\ => L:\projects
* S:\ => C:\Windows\system32
* T:\ => H:\temp
* U:\ => G:\uty
* V:\ => H:\work
* 4:\ => G:\tc22
 
Apr 13, 2010
301
7
61
The Hague
Windows has "DOS Devices". There's SUBST.EXE and TCC's PSUBST to manage the ones which act as drive names. The names are limited to single characters but not to A-Z. On Windows 7, these (maybe more) also work: 0, 1, ... 9, !, #, $, +, -. And at least 4: can be made permanent.

Good point.

1) Use PSUBST on a sub-path to make it *protected*, besides if not persistent.
2) Assign the root of the virtual drive to a descriptive dir-alias to clarify its use.

The PSUBST part isn't strictly necessary but it certainly hardens the validity of your dir-alias.
I guess the appropriateness depends on how long the dir-alias will live.

A great example would be the root directory of larger standard environments like develop-, test and production trees.
Code:
copy /y develop:\product\module\*.cpp test:\product\module
BTW your idea of virtual drives could be of interest to Joe too, couldn't it?
Thanks.
 
Last edited:
Apr 13, 2010
301
7
61
The Hague
I suspect these functions call WritePrivateProfileString() and GetPrivateProfileString() under the hood. These functions are old and funky: if they are passed a filename without a path, Windows assumes the file is in %WINDIR%, not the current directory. Which is why Rex does not canonicalize the filename he passes to them — it would break the documented, longstanding ... weird ... behavior.

A thought.

Lately Rex seems to invest in backward compatibility with CMD. It sounds like he does that by burdening a perfectly healthy product with the quirks from the past. Burdening, as in: actually rebuilding quirks and adding them as an alternative. If we could have a switch to toggle from compatibility mode to "way less weird" mode we go ahead and canonicalize all weird behavior out of TC. Have a separate DLL or something. Wouldn't that be nice?
 
Similar threads
Thread starter Title Forum Replies Date
Jesse Heines Using Regular Expressions with the REN commanc Support 8
R WAD Unusable state when using Chinese characters Support 3
Joe Caverly Using TYPE with non-English text Support 22
L Using TCC.exe through an SSH connection Support 3
Joe Caverly Using @PSHELL from @EVAL Support 8
Jay Sage Command Will Not Run Using Short Name of Path Support 5
Jay Sage Cannot Postion Cursor in Command Line Using Mouse Support 7
MikeBaas Using the debugger Support 2
Joe Caverly Multiple Text Searches at once using FFIND or TPIPE Support 4
Dick Johnson Using the @instr function Support 5
Joe Caverly Using this CMD technique from TCC Support 17
Joe Caverly What version and Windows OS are you using? Support 3
Craig Fitzgerald Problems using tcstart.btm Support 3
R How to? Append files in multiple subfolders using copy? Support 8
M Ctrl-C when using command line history does nothing Support 2
C French accents using msgbox Support 4
C "Failed to update the system registry. Please try using REGEDIT" Support 3
x13 Problem listing repository files using DIR http(s)://... Support 8
R Regex using ^ Support 2
cxxl WAD Mouse movement sluggish when using TCC list Support 3
jfalch WAD internal "which" should check for FILEEXIST when using AppPaths entry Support 8
D How to? Scale font in TCC using wheel mouse or other means Support 2
fpefpe Documentation copy/move using /c or /u Support 2
gschizas Fixed Using codepage 65001 (UTF-8) breaks non-ASCII characters Support 8
D How to? Use typed envars using regex. Support 3
epement Using "everything" Support 10
U Installing the Compaq Visual Fortran 6.0 compiler using Take Command Support 8
Alexander WAD The number of files and dirs are multiplied when using multiple wildcards Support 6
T using bottom line for status bar Support 3
A How to? How do you launch TCC/LE using the already-open instance? Support 5
rps Fixed Using last argument variable ! Support 5
M Incorrect ARGV1 when using linux-style paths Support 4
D How to? Using a custom ini file with TCC from Take Command Support 7
thedave WAD Unable to type various characters using Windows 8's onscreen keyboard Support 7
D Documentation Using "send all input to other tabs" Support 11
Joe Caverly Word Count using TPIPE Support 10
Phileosophos Fixed Option Dialog Hangs when Using Help Support 7
MickeyF problem using COM object in VBScript from v16 x64 TCC but not from v15 32-bit TCC Support 4
S How to? How do I distinguish missing source file from download error when using HTTP? Support 6
Jay Sage Using EVERYTHING Command in TCMD15 Support 5
Charles Dye Odd behavior after using OPTION "Advanced" tab Support 2
T How to? Using FOLDERMONITOR 1 event causes multiple trigger(ing)s Support 8
samintz WAD FILEWRITE using SMOPEN Support 1
ehab aboudaya How to? 2 GUI questions and return HWND using TakeCommandIPC Support 3
R Fixed Using %~dp1 for paths with unavailable drives Support 6
C Using dif. sending addresses with sendmail Support 11
R TC 13 / Using TCDIALOG to exit commands Support 4
epement Video tutorials of using Take Command Support 2
electrotype Error using TCC: "Label not found" Support 6
Phileosophos unzip not using specified path Support 5

Similar threads