Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. xBase question

xBase question

Scheduled Pinned Locked Moved Database
questioncssdata-structures
10 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    David Crow
    wrote on last edited by
    #1

    In a PRG file, a character array is declared as:

    char(1) myvar[11]

    and is initialized like:

    myvar[1] = Chr(32)
    myvar[2] = Chr(45)
    ...
    myvar[10] = Chr(124)

    My question is, since myvar[11] was never assigned a value, what value would I get? I don't have access to a compiler/interpreter, only the source code. Thanks. - DC

    "One man's wage rise is another man's price increase." - Harold Wilson

    "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

    "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

    K 1 Reply Last reply
    0
    • D David Crow

      In a PRG file, a character array is declared as:

      char(1) myvar[11]

      and is initialized like:

      myvar[1] = Chr(32)
      myvar[2] = Chr(45)
      ...
      myvar[10] = Chr(124)

      My question is, since myvar[11] was never assigned a value, what value would I get? I don't have access to a compiler/interpreter, only the source code. Thanks. - DC

      "One man's wage rise is another man's price increase." - Harold Wilson

      "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

      "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

      K Offline
      K Offline
      Kevin Marois
      wrote on last edited by
      #2

      False. All variables in xBase are False by default. At least in FoxPro, that it.

      If it's not broken, fix it until it is

      D 1 Reply Last reply
      0
      • K Kevin Marois

        False. All variables in xBase are False by default. At least in FoxPro, that it.

        If it's not broken, fix it until it is

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        Kevin Marois wrote:

        All variables in xBase are False by default.

        Regardless of type?

        "One man's wage rise is another man's price increase." - Harold Wilson

        "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

        "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

        K 1 Reply Last reply
        0
        • D David Crow

          Kevin Marois wrote:

          All variables in xBase are False by default.

          Regardless of type?

          "One man's wage rise is another man's price increase." - Harold Wilson

          "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

          "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

          K Offline
          K Offline
          Kevin Marois
          wrote on last edited by
          #4

          xBase langauges are loosley typed, so it will get its type when assigned to.

          If it's not broken, fix it until it is

          D 1 Reply Last reply
          0
          • K Kevin Marois

            xBase langauges are loosley typed, so it will get its type when assigned to.

            If it's not broken, fix it until it is

            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #5

            Kevin Marois wrote:

            ...so it will get its type when assigned to.

            But if there was no explicit assignment?

            "One man's wage rise is another man's price increase." - Harold Wilson

            "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

            "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

            K 1 Reply Last reply
            0
            • D David Crow

              Kevin Marois wrote:

              ...so it will get its type when assigned to.

              But if there was no explicit assignment?

              "One man's wage rise is another man's price increase." - Harold Wilson

              "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

              "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

              K Offline
              K Offline
              Kevin Marois
              wrote on last edited by
              #6

              Each element in the array that is not assigned to will be False It's important to remember that xBase languages are loosely typed, so this will compile and run

              char(1) myvar[11]
              myvar[1] = Chr(32)
              myvar[2] = Chr(45)
              myvar[3] = "Hello"
              myvar[3] = DATETIME()
              myvar[10] = Chr(124)

              See this[^] Note that it says:

              VFP is a weakly typed language, that is, the compiler allows operations such as assignment and comparison among variables of different types. For example, VFP allows the value of a variable to be cast to another type. The ability to use variables of different types in the same expression promotes flexibility as well as efficiency.

              and

              Note: Strong typing in Visual FoxPro 7/8/9 SP2 is not enforced at compile or run time, but is used primarily at design time.

              This is true for Visual FoxPro, and for FoxBase and dBase, all of which are xBase languages. Do you know what language this code was written in?

              If it's not broken, fix it until it is

              D 1 Reply Last reply
              0
              • K Kevin Marois

                Each element in the array that is not assigned to will be False It's important to remember that xBase languages are loosely typed, so this will compile and run

                char(1) myvar[11]
                myvar[1] = Chr(32)
                myvar[2] = Chr(45)
                myvar[3] = "Hello"
                myvar[3] = DATETIME()
                myvar[10] = Chr(124)

                See this[^] Note that it says:

                VFP is a weakly typed language, that is, the compiler allows operations such as assignment and comparison among variables of different types. For example, VFP allows the value of a variable to be cast to another type. The ability to use variables of different types in the same expression promotes flexibility as well as efficiency.

                and

                Note: Strong typing in Visual FoxPro 7/8/9 SP2 is not enforced at compile or run time, but is used primarily at design time.

                This is true for Visual FoxPro, and for FoxBase and dBase, all of which are xBase languages. Do you know what language this code was written in?

                If it's not broken, fix it until it is

                D Offline
                D Offline
                David Crow
                wrote on last edited by
                #7

                Kevin Marois wrote:

                Do you know what language this code was written in?

                Not exactly. I heard it was xBase III, but I've seen signs of xBase V. The files have PRG extensions.

                "One man's wage rise is another man's price increase." - Harold Wilson

                "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

                K 1 Reply Last reply
                0
                • D David Crow

                  Kevin Marois wrote:

                  Do you know what language this code was written in?

                  Not exactly. I heard it was xBase III, but I've seen signs of xBase V. The files have PRG extensions.

                  "One man's wage rise is another man's price increase." - Harold Wilson

                  "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                  "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

                  K Offline
                  K Offline
                  Kevin Marois
                  wrote on last edited by
                  #8

                  Ya, most xBase languages are pretty similar in their syntax. If it compiles in one, it should in another with minimal work.

                  If it's not broken, fix it until it is

                  D 1 Reply Last reply
                  0
                  • K Kevin Marois

                    Ya, most xBase languages are pretty similar in their syntax. If it compiles in one, it should in another with minimal work.

                    If it's not broken, fix it until it is

                    D Offline
                    D Offline
                    David Crow
                    wrote on last edited by
                    #9

                    Kevin Marois wrote:

                    If it compiles in one, it should in another with minimal work.

                    The problem is I'm converting a portion of it to C.

                    "One man's wage rise is another man's price increase." - Harold Wilson

                    "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                    "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

                    K 1 Reply Last reply
                    0
                    • D David Crow

                      Kevin Marois wrote:

                      If it compiles in one, it should in another with minimal work.

                      The problem is I'm converting a portion of it to C.

                      "One man's wage rise is another man's price increase." - Harold Wilson

                      "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                      "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

                      K Offline
                      K Offline
                      Kevin Marois
                      wrote on last edited by
                      #10

                      Lucky you :) The thing to remember is that you really don't know what's in a variable until runtime. In FoxPro you can do

                      Customer = "Smith"
                      Customer = CreateObject("Excel.Application")
                      Customer = .T.

                      Now a later version of FoxPro added the 'AS' keyword:

                      LOCAL CustomerName AS String

                      but this is for intellisense only and doesn't constrain the variable to a type, so you can still do

                      LOCAL CustomerName AS String
                      CustomerName = 10+5

                      It's not uncommon in older apps to see a variable declared as Public in the startup program, then see its value changed all over the place. This is hell on earth. Here's a FoxPro forum [^]you can use. I'v been a member there for many years, and most people there are very knnowledegable.

                      If it's not broken, fix it until it is

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups