Announcement

Collapse
No announcement yet.

Playing with paths/strings

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Playing with paths/strings

    hi,
    i use in my programs predefined directories defined as strings, like

    Code:
    $WorkDIR  "C:\work\*.*"
    $DestDIR  "D:\yourwork\"
    when i want to copy file called "xyz.txt" using FILECOPY command from WorkDIR, how it is going to be???
    Code:
    FILECOPY $WorkDIR\xyz.tx, $yourwork
    i get errors.
    how to write the path with variable part?

  • #2
    You need to use the string concatenation character "+", also any literals need to be enclosed with quotes:

    Code:
    FILECOPY $WorkDIR + "\xyz.tx", $yourwork
    kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me

    Comment


    • #3
      Originally posted by Kev Peel View Post
      You need to use the string concatenation character "+", also any literals need to be enclosed with quotes:

      Code:
      FILECOPY $WorkDIR + "\xyz.tx", $yourwork
      hi
      still doesnt work,
      i also read that the source and destination should be file names not directories . i tried this and it didnt work as well
      Code:
      FILECOPY $WorkDIR + "\xyz.tx", $yourwork +"abc.txt"

      Comment


      • #4
        It's because you need to use proper folder path names (no wildcards etc):
        Code:
        $WorkDIR  "C:\work\"
        $DestDIR  "D:\yourwork\"
         
        FILECOPY $WorkDIR + "xyz.tx", $yourwork + "abc.txt"
        If you need to see the outcome then use:

        Code:
        ? $WorkDIR + "xyz.tx" + $CRLF + $yourwork + "abc.txt"
        kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me

        Comment


        • #5
          ? $WorkDIR + "xyz.tx" + $CRLF + $yourwork + "abc.txt"
          It's different coding styles but I think it was Lance Edmonds that got me into using the & to append text instead of the + sign...

          So you could also do this to eliminate any potential future confusion when mathmatical values come up...

          Just a different style is all...

          Code:
          ? $WorkDIR & "xyz.tx" & $CRLF & $yourwork & "abc.txt"
          Scott Turchin
          MCSE, MCP+I
          http://www.tngbbs.com
          ----------------------
          True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

          Comment


          • #6
            Not for me, I hate that nonstandard VB-style syntax
            kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me

            Comment


            • #7
              Kev,
              + and & in VB are equally well known.
              & is just less used

              good thing its not boolean, or
              the "+" would be an "OR"
              the "&" wound be an "AND"
              (god forbid what NOR, ExOR, and etc would be)
              Engineer's Motto: If it aint broke take it apart and fix it

              "If at 1st you don't succeed... call it version 1.0"

              "Half of Programming is coding"....."The other 90% is DEBUGGING"

              "Document my code????" .... "WHYYY??? do you think they call it CODE? "

              Comment


              • #8
                I know, I used to be a VB programmer before I saw the light

                The & operator was for VB 5/6 only and M$ changed the way + worked since it used variants internally. PB does not have this problem so using + is fine (& was probably included for compatibility).

                VB Example:

                Code:
                Private Sub Form_Load()
                 
                  s1 = 1 ' Default variable type is VARIANT
                  s2 = 2
                  MsgBox s1 + s2  ' Adds values to make "3"
                  MsgBox s1 & s2  ' Combines 1+2 to make "12"
                 
                End Sub
                kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me

                Comment


                • #9
                  Code:
                    s1 = 1 ' Default variable type is VARIANT
                    s2 = 2
                    MsgBox s1 + s2  ' Adds values to make "3"
                    MsgBox s1 & s2  ' Combines 1+2 to make "12"
                  And I thought "GOTO" facilitated bad programming habits.
                  Michael Mattias
                  Tal Systems (retired)
                  Port Washington WI USA
                  [email protected]
                  http://www.talsystems.com

                  Comment

                  Working...
                  X