Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Long Filenames

Status
Not open for further replies.

MIKEN

Programmer
Apr 11, 2000
3
US
I am using QBasic 1.1 (pretty old, I think!)<br><br>Is there a way to use long filenames? I have tried using variables and double quotes, but I keep getting errors. I'd like to be able to do something like:<br><br>f$=&quot;myfilenamehere.txt&quot;<br>open f$ for input as #1<br><br>Thanks!
 
Qbasic (any version) will not accept long filenames, since it was created prior, the way it works is that any filename cannot exceed 11 charaters (including the extension and period) so the naming convention for seeing Long filenames under a dos program is usally the length of the file that can be shown, followed by a ~1 (or different number if multiple files carry similar names) like &quot;My Document&quot; is seen as Mydocu~1 under dos (which technically has a . at the end, since almost all folders have no extensions) knowing exactly which ~1 number to place may be hard, but I've found that 99% of the time its a ~1, also it'll always be 11 charaters max, 5 of the original text then ~# then .ext<br>Hope that helps. <p>Karl<br><a href=mailto:kb244@kb244.8m.com>kb244@kb244.8m.com</a><br><a href= </a><br>Experienced in , or have messed with : VC++, Borland C++ Builder, VJ++6(starting),VB-Dos, VB1 thru VB6, Delphi 3 pro, Borland C++ 3(DOS), Borland C++ 4.5, HTML,Visual InterDev 6, ASP(WebProgramming), QBasic(least i didnt start with COBOL)
 
Thanks, Karl! Actually, what worked for me was the first 6 characters of the name, then &quot;~1&quot;, then the &quot;.&quot; and extension:<br><br>&quot;myfile~1.txt&quot;<br><br>but using that works great.<br><br>MikeN
 
You welcome, I would check on the file length and if spaces exist, to avoid doing that to a filename that isnt long. <p>Karl<br><a href=mailto:kb244@kb244.8m.com>kb244@kb244.8m.com</a><br><a href= </a><br>Experienced in , or have messed with : VC++, Borland C++ Builder, VJ++6(starting),VB-Dos, VB1 thru VB6, Delphi 3 pro, Borland C++ 3(DOS), Borland C++ 4.5, HTML,Visual InterDev 6, ASP(WebProgramming), QBasic(least i didnt start with COBOL)
 
i've written a code that can be used with long filename. this example show you all the long filename you have in the c:\windows\ folder and subfolders.<br><br><br>CLS<br>print &quot;wait a moment&quot;<br>DIM longfile$(2000)<br>temp$ = &quot;dir/b/s/a &quot; + &quot;c:\windows\*~1.* &quot; + &quot; &gt; dir.tmp&quot;<br>SHELL temp$<br>count = 0<br>OPEN &quot;dir.tmp&quot; FOR INPUT AS #1<br>DO WHILE NOT EOF(1)<br>&nbsp;&nbsp;&nbsp;&nbsp;count = count + 1<br>&nbsp;&nbsp;&nbsp;&nbsp;LINE INPUT #1, longfile$(count)<br>LOOP<br>CLOSE #1<br>CLS<br>FOR a = 1 TO count<br>&nbsp;&nbsp;LOCATE 1, 1: PRINT &quot;longfile in C:\Windows\&quot;<br>&nbsp;&nbsp;LOCATE 3, 1: PRINT longfile$(a)<br>&nbsp;&nbsp;DO: LOOP UNTIL INKEY$ &lt;&gt; &quot;&quot;<br>&nbsp;&nbsp;CLS<br>NEXT<br><br><br>:p <p>miguel<br><a href=mailto:migoul@hotmail.com>migoul@hotmail.com</a><br><a href= page (not been updated recently)</a><br>
 
that would just return the directory listing, but I find how you used the specific parameters of the dir command to acheive this, I assume it's a bare output , so you are only getting names and not attributes, size, datas, so on. <p>Karl<br><a href=mailto:kb244@kb244.com>kb244@kb244.com</a><br><a href= </a><br>Experienced in : C++(both VC++ and Borland),VB1(dos) thru VB6, Delphi 3 pro, HTML, Visual InterDev 6(ASP(WebProgramming/Vbscript)<br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top