Yet another question...

 BBS: Inland Empire Archive
Date: 04-06-92 (12:53)             Number: 93
From: GEORGE KOCKE                 Refer#: 68
  To: JIM TANNER                    Recvd: NO  
Subj: Yet another question...        Conf: (2) Quik_Bas
In a msg on <Apr 05 23:20>, Jim Tanner of 1:19/99@fidonet.org writes:

 JT> Can someone tell me how to remove a character at the right side
 JT> (end) of a string.?

 JT> For example:
 JT>                 If a trailing back-slash (\) is placed at the end
 JT> of a path name in a sequential file, I need to know how to either
 JT> remove it or have my program ignore the back-slash yet still get
 JT> the path correct.

 JT> PathName$ = C:\SOMEDIR\OTHERDIR\

 JT> I need to remove the last "\"

I wrote a routine that converts all the back slashes to
spaces, trims all leading and trailing spaces from the
string, and converts all the spaces back to back slashes.
It will also look to see if the first character of the
string is a back slash and add it back on if needed.  I use
it when I need to get a path name from either the command
line or from within the program.

  input "Enter area path: ",path$
  IF LEFT$(Path$, 1) = "\" THEN
    putback$ = "\"
  END IF
  wdlen = LEN(Path$)
  FOR fixpath = 1 TO wdlen
    IF MID$(Path$, fixpath, 1) = "\" THEN
      MID$(Path$, fixpath, 1) = CHR$(32)
    END IF
  NEXT fixpath
  Path$ = LTRIM$(RTRIM$(Path$))
  wdlen = LEN(Path$)
  FOR fixpath = 1 TO wdlen
  IF MID$(Path$, fixpath, 1) = CHR$(32) THEN
    MID$(Path$, fixpath, 1) = "\"
  END IF
  NEXT fixpath
  Path$ = putback$ + Path$

--- msgedsq 2.0.5
 * Origin: Terminus (1:396/49)
Outer Court
Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET