I'm trying to read a .MEM file using Delphi. It's a FoxPro Memory Variable Files. I've tried to read using TFileStream and load into TStringList. But, it only returns the first word.
The reason is because I want to migrate some useful .MEM values from an old program to my new program. Thanks for any help.
How do I configure a Windows desktop folder to display only icons? Ask Question 0. I have created a folder on the Windows desktop that I want to display only icons, short cuts to programs. Browse other questions tagged windows-7 display desktop-icons or ask your own question.
KS.KS.
2 Answers
If it's a one-time affair and you have access to a VFP installation - i.e. the IDE, not only the runtime - then David Heffernan's suggestion is certainly the most sensible way. In this case you can load and inspect the .MEM via
However,
LIST MEMORY
(and DISPLAY MEMORY
) also include all the system variables - the things that start with an underscore - which would need to be parsed off.If it's an ongoing affair - repeated imports necessary - and you know which variables you need then there are two fairly clean and easy ways.
The first is only valid if a VFP IDE is installed on the computer on which the Delphi program is to be run. In this case you can instantiate VFP from Delphi (leave it invisible), have it read the .MEM and then query individual variables:
I glossed over some details, like that
CoInitialize()
needs to be called on the thread somewhere before calling this, and I assumed suitable definitions for the variable list (a list/collection of hypothetical CFoo objects), but the sketched outline works - even in 64-bit Delphi.The advantage is that things like datetime values arrive as TDateTime by virtue of the COM infrastructure and the use of variants.
The second easy way is applicable if an IDE is not available on the machine where the Delphi program is to be used but you have access to an IDE somewhere, so that you can build a small COM server:
This can then be used instead of 'VisualFoxPro.Application.9' in the example above. Note: for 64-bit Delphi you need to build this as an out-of-process server (i.e. an EXE). Also, this may run afoul of the VFP licence conditions.
For accessing the data directly, here's some quick & dirty Delphi code that I modelled after some FoxPro stuff that I coded eons ago and updated for VFP9. This is proof-of-principle code with simplified array handling and other compromises for the sake of exposition; it lacks all the production-quality noise necessitated by Delphi's half-assed language definition and its quarter-assed runtime.
For reading a .MEM, create a
TFileStream
and a TMEMVarInfo
variable, then read variables one by one until var_info.ReadFromStream(stream)
returns false
.Note: the byte at offset 19h (shown as 3 in the structure comment) is a code page identifier. The values are the same as those found in .DBF headers, i.e. 1 for DOS 437, 3 for Windows 1252 and so on. However, even though VFP stores these identifiers when writing a .MEM, all the newer versions of VFP that I tested completely ignore these code page marks when loading a .MEM. A self-written importer could put the code page marks to good use, though.
DarthGizkaDarthGizka2,66311 gold badge1212 silver badges3030 bronze badges
Reading the binary .mem files is not the correct way to proceed. The correct solution is to get VFP to export the data. It knows how to read it. Get VFP to export to a known format, and read that. This is the standard approach to data migration.
David HeffernanDavid Heffernan528k3535 gold badges861861 silver badges12531253 bronze badges
Not the answer you're looking for? Browse other questions tagged delphivariablesfoxpro or ask your own question.
display command help to display the single current record in adatabase where as list command helps to display all the currentrecord which are present in a data base.
What is the difference between list and display all in foxpro?
List and Display in FoxPro are almost the same exact thing, the only difference being that List will show all of the records continuously, while display will only show the records until the screen is filled, with a button at the bottom prompting you to, 'press any key to continue'. Read More
What is the difference between the ls and ls -al commands?
ls --> will list the files and directories but ls -a --> will list the hidden files too, by Dhanush M Read More
Difference between arrays and linked list?
Difference between arrays and linked list? Read More
What is the difference between cost and list price?
whats the difference between cost and list? Read More
What is the complete list of commands for the Command Prompt?
Enter 'HELP' at the command prompt for a complete list. Enter 'HELP command' or 'command /?' to display help information on that command. E.g., 'HELP ATTRIB' or 'ATTRIB /?' to display help on the ATTRIB command. Read More
W difference between a linear linked list and a circular linked list?
what is the difference between a linear linked list and a circular linked list? Read More
What is the difference between the cat and more commands in Unix?
Both the 'more' and the 'cat' commands will list the contents of one or more files. In that case, the main difference between the two commands is that 'more' is a 'pager' program, meaning that it stops at the end of every page and waits for the user. The 'cat' command will list everything in the file without stopping. One other thing that 'cat' does that 'more' does not is to concatenate (add/merge) files together… Read More
List of additional commands?
a list of additional commands is a sub-menu Read More
What is the difference between dynamic implementation and linked list implemention?
compare difference between static and dynamic implementation of linked list. Read More
Is any intructions that tells a computer what to do?
They are commands. If you put a list of commands together to carry out a more detailed task, the list of commands are referred to as a program. Read More
What is the difference between echo cat and cat echo commands in Linux?
echo cat will print out the word 'cat' on the command line. cat echo will attempt to list the contents of a file called 'echo'. Read More
What is the difference between a numbered list and an outlined list?
The outlined number list has a hiearchy. Read More
How do you open the counter strike command list?
there is no list persay but help in the consel (press ~ key) should give you commands but for a list of commands and what they do just google css consel commands Read More
What is the difference between the weather of Pakistan and UK what differences are there list them?
difference between the weather of pakistan and uk Read More
What is a is a list of additional commands associated with the selected command?
DOES A dialog box contains a list of commands from which you make selections?
A dialog box contains a list of commands from which you make selections Read More
Where can you find a full list of keyboard commands for Windows Vista?
Just search on the internet for full list of keyboard commands Read More
What are all the commands in Minecraft?
Each server as its own set of commands. There is not a list of all commands available as they are different from server to server. If you want to know the commands you can use on a single player world, just use /help you the list. Read More
Main difference between Array List and Vector in Java?
What is the difference between a list and an outline?
What is the difference between a list and an outlin? Read More
What is an additional list of commands?
What is a list of related commands?
What contains a list of commands?
Contains a list of commands?
A group or list of commands?
Displays a list of commands?
What is the difference between a bibliography and a reference list?
The difference between a bibliography and a reference list is in a bibliography, all the works that is accessed in the course of the research is needed to list down regardless of whether they are cited within the paper or not. On the contrary, a reference list only contains the list of sources that were mentioned in the paper. Read More
How many commands are there in AutoCad?
Billions and billions :) are you asking for the commands list or commands which are important and basic one......around 259= basic commands are their for autocad. and for the list please go with this link: http://academics.triton.edu/faculty/fheitzman/commands.html Read More
The difference between the greatest and least numbers in a list of data?
The range is the difference between the greatest and least numbers. Read More
What are the commands that you must enter at the command prompt?
Type HELP for a complete list of available commands. Read More
True or false A demoted menu is a list of additional commands associated with the selected command?
A demoted menu is a list of additional commands associated with the selected command. Read More
Is Luca Perinuzzi on Santa Claus's list?
everyone is on his list. if you're 'naughty or nice' is the only difference between everyone on the list. Read More
List of additional commands in word?
With computers what is a list of related commands?
What displays a list of commands on a computer?
What is a list of commands that you can choose from in excel?
In excel what is a list of commands that you can choose from?
Powerpoint contains the list of commands?
What is the difference between commercial farming and organic farming?
theres so much difference that its impossible to list them Read More
How do you enable cheats for oblivion?
on PC hit the '~' key and then get a list of commands. Just search 'list of commands in oblivion' in your search engine and you've got it. Read More
Does the CLI have help commands?
Typing help will give you a list of all commands available. Read More
What is the difference between the greatest and least numbers in a list of a data?
The difference between the greatest and least numbers in a list of numbers?
What contains a list of commands in a word document?
What are the list of commands that appear on the screen in windows?
What is the difference between a numbered list and a numbered outline in Microsoft Word?
The difference between the greatest and least number in a list of data?
What do you call The difference between the greates and least numbers in a list of data?
List of commands in the Citizenship Advancement Training?
There are several commands one must learn in the Citizenship Advancement Training. Some of the commands are ready front, fall in line, and as you were. Read More
What is the difference between listing the factors of a number and lising the multiples of a number?
The factor list will be finite, the multiple list will be infinite. Read More