WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

FAQs - Frequently Asked Questions

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

IntControl 29 and File Delimiters

Keywords: IntControl 29 File Delimiters

In order to support long file names in Windows NT and Windows 95, which can contain embedded spaces, we have changed the default file delimiter used to delimit lists of files and directories, from a space to a TAB in the 32-bit version of WIL. In the 16-bit version of WIL, the default delimiter has not changed, and remains a space.

Note that this is the "default" file delimiter. We have added the ability to change the file delimiter to a character of your own choosing, using the new IntControl 29.

If you have a script written for 32 bit WinBatch that fails on 16 bit WinBatch:

To make it work in both 16 and 32 bit WinBatch, add the following line to the top of the script:

	IntControl(29,@tab,0,0,0) 
The problem is that the 16 bit version delimits dirs and files with spaces (for compatibility with older 16 bit versions) and the new 32 bit version uses tabs as delimiters. The IntControl tells the 16 bit version to uses tabs instead of spaces (for stuff like DirItemize and FileItemize).

The most important functions affected by this change are:

which now return lists delimited by the current file delimiter character.

The following functions, which take file or directory lists as input parameters, now expect the lists to be delimited by the current file delimiter character. However, they now also accept lists delimited with a TAB or a vertical bar ("|", which may be easier to code in a WIL script):

Note that DiskFree will continue to accept space-delimited lists as input.

IntControl(29, p1, 0, 0, 0)

Changes the "default" file delimiter.

	p1	new file delimiter

The first parameter for IntControl is the new file delimiter you want to use, and must be a single character. The return value of the function is the previous file delimiter character. If you specify an empty string ("") as the first parameter, the function will return the current file delimiter character but the file delimiter will not be changed.

If you are using the 32-bit version of WIL, and want to make the file delimiter a space for compatibility with existing scripts, you can place the following line at the beginning of each of your scripts:


	IntControl(29, " ", 0, 0, 0)
Conversely, if you want to standardize on a TAB delimiter, you can use:

	IntControl(29, @TAB, 0, 0, 0)

More Details on What IntControl 29 Affects:

Question:

I need to read a file that is comma delimited. I read a line of data from the file, and then use the ParseData command to break up the line. I need to get Winbatch to recognize a comma as the delimiter. I have tried using IntControl(29, ... but have been unsuccessful thus far. I have tried:
	IntControl(29, ,, 0, 0, 0)
	IntControl(29, ",", 0, 0, 0)
	IntControl(29, ',', 0, 0, 0)
	IntControl(29, @,, 0, 0, 0)
but so far, none have them have worked. Can you give me some advice?

Answer:

  1. Don't use IntControl 29 for this. It controls the Filename separation delimiter only. Do not even consider using commas as a file delimiter. It is a legal filename character.

    The delimiter is just for FileItemIze and DirItemize and a few other functions. It's just to allow compatible 16/32 bit scripts.

  2. Try:
    	line="aaa,bbb,ccc" ; basically the data
    	line=StrReplace(line, "," , @tab
    
    that changes all commas to tabs.

    Then use ParseData to break it up, or perhaps preferably us ItemExtract to pick the pieces out.

    Or, you could use a combination of ItemCount and ItemExtract; in which you can specify the delimiter on the fly.... something along the lines of:

    	numitems=ItemCount(filevariable,`,`)
    	count=1
    	while @TRUE			 ;infinite loop until BREAK
    	   CurrentItem=ItemExtract(count,filevariable,`,`)
    	if (end of line condition) then BREAK
    	   count=count+1
    	endwhile
    

    Article ID:   W12995
    
    Filename:   IntControl 29 and File Delimiters.txt
    File Created: 1999:04:15:16:51:02
    Last Updated: 1999:04:15:16:51:02