Computer Hope

Microsoft => Microsoft DOS => Topic started by: J-ho on July 05, 2004, 05:12:11 PM

Title: How to create infinite variables in batch files?
Post by: J-ho on July 05, 2004, 05:12:11 PM
hi, i'm using DOS (net send)to chat with my flatmate on my LAN, and i've made a simple .bat file that looks like this, so that i don't have to write everything out everytime:

@echo off
net send name %1 %2 %3 %4 %5 %6 %7 %8 %9

the problem is that i can't get any more than 9 variables because if i type %10, it just sends the first one and adds a zero, and i can't write more than nine words! Is there a solution to this, or a better way of doing it? My DOS skills are ten years old, and I don't remember anything on how to write code. Please help!
Title: Re: How to create infinite variables in batch file
Post by: 2k dummy on July 05, 2004, 06:38:08 PM
Use the shift command. %0 through %9 are the first ten variables. Using shift, all variables after the tenth are shifted into %9. There is no backward shift, so make sure to type them correctly or create a notepad file with all the names typed in. Save it to the desktop, then copy/paste into the command line for the batch file.  You can use the shift command with less than ten variables.
Title: Re: How to create infinite variables in batch file
Post by: Yenz on July 13, 2004, 06:51:33 AM
use quotes
this way all your text will be in the first variable