Duoas 1,025 Postaholic Featured Poster

I didn't understand this, Duoas. Please would you elaborate a bit? Terms like basic language interpreter and sandbox environment are completely new to me.

For example, you could embed a Tcl interpreter in your program (TCL or Tool Command Language is a script language). Or, you could link a Python interpreter into your application.

In either case, you can extend the interpreted language itself to provide functionality specific to your application. Once done, the end-users could write their AI scripts in the embedded language (e.g. Tcl or Python), and your program will execute the end-user's code as needed.

The end-user's code would be a simple text file (just like all code files).

However, executing code you didn't write is a security concern, so you will need to implement the interpreter such that the end-user's code cannot do anything it shouldn't (like access files, or create sockets, etc.) Such an interpreter is said to exist in a sandbox --basically a controlled environment. Sand stays in; foreign material stays out.

Fortunately, this is very easy to do in Tcl and Python (and Scheme :-).


Socket programming is a pain in C/C++. If you were to embed Tcl or Python, you could use the embedded language's facilities to open and manage the socket. Both Tcl and Python make handling sockets trivial.


Whether you choose to do this or not you've got a lot of homework ahead of you. Good …

Jishnu commented: Thanks, once again :) +2
Duoas 1,025 Postaholic Featured Poster

You could do it something like that, but it introduces more problems than it solves:

fork() doesn't work on Windows. Even if it did, you would still need to set up some IPC to make things work right (that is, keep state, avoid excessive process loads and task switching, and I/O buffering, response time, and message configuration).

The simplest, and most common way to do it is to use DLLs. That's what they were designed for.

Windows provides protected memory accesses, so one DLL cannot easily gain access to another's process. Further, doing so would require source-code knowledge of the target DLL. Finally, a game will not function well if subprocesses don't behave (and try to disrupt their bretheren).


Another option, if you intend to have a "end-user programmable" AI, is to provide a basic language interpreter (embed Tcl or Python or somesuch), and execute each AI's code in a sandbox environment.

Jishnu commented: Great help :) +2
Duoas 1,025 Postaholic Featured Poster

> I think you misunderstood the other poster.
> I don't think that word means what you think it means.
I amaze at the arrogance and rudeness some people possess. Do you really believe yourself superior to AD's intellect, and mine?

I don't really care much what you think. I know what the word inline means. Look it up yourself.

> The OP was using the way AD wasn't.
Thank you Captain Obvious.

sarehu commented: I think you misunderstood me, too. +1
Duoas 1,025 Postaholic Featured Poster

Use DLLs like AD suggested. Instead of supplying a language it should supply an AI. The functions will be the same for each AI DLL, so the only variable will be the name of the DLL opened with LoadLibrary().

Duoas 1,025 Postaholic Featured Poster

He didn't misunderstand.

There are two ways to look at "inline":
1. the OP wants to avoid using function call syntax
2. AD's code actually avoids calling a function

Either way the best solution takes multiple lines of code, as posted.

Duoas 1,025 Postaholic Featured Poster

Turbo Vision is an old "window" interface created by Borland before what we consider to be GUI's really came into existence on the PC. Before Win 2.x programs often did pretty graphics using text mode.

You can get it from the folks at Free Pascal (as already noted).

Duoas 1,025 Postaholic Featured Poster

Actually, it might be possible to some degree. VB uses a lot of bytecode and, if I remember right, Microsoft and others have VB decompilers. You'll never get back the absolute original, but if you can find the right decompiler (and can front the cash for it), you should be able to get enough back that you can reconstruct the rest.

You might be better off just writing it over again...

Alas.

Dukane commented: thank you +2
Duoas 1,025 Postaholic Featured Poster

You've misread Narue's code. You can't do this with a standalone function. It must be a member of a class.

In the first example, Amethod() was made virtual in the base class (Bird) and overloaded in the descendant class (Pidgeon). Since it is virtual (or dynamic) when you say p->Amethod() the Pidgeon's Amethod() gets called if p is a Pidgeon; and the Bird's Amethod() gets called if p is a Bird.

In the second example, Amethod() is static (or not dynamic), so even if you give Pidgeon an Amethod() member function, since p is listed as a "pointer to Bird" the Bird's Amethod() is always called. That is the reason why Narue didn't bother to give Pidgeon an Amethod() method (member function).

This is the difference between Object Oriented (the dynamic way) and Object Based (the static way).

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

Yes, please, do it the C++ way.

I think that you might expect a large number of orders to be stored? In which case a deque is a better choice than a vector.

And like Salem indicated, there is no need to create named variables (order1, order2, etc.), just use the deque or vector or whatever you choose so you can say vector_of_orders[ 0 ] vector_of_orders[ 1 ] etc.
where 0, 1, 2, etc is easily kept in a variable (like "orderNumber") that can be manipulated as needed.

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

Ah, well, then you've got yourself in a ball of mud.

One of the primary functions of the OS is to load and execute a program. How this happens is typically and entirely dependent on the OS.

For example, Win32 cannot execute a Mac program. As far as old DOS and Win16 programs, Win32 was specifically engineered to support legacy applications, but the next generation will scrub the old DOS subsystem anyway...

If you intend to execute PE32 (Win32) programs, then you'll have to do some serious reading over at MSDN and around the net.

Otherwise, you'll have to roll your own exe format, or borrow one from another OS, and write your own loader.

Good luck.

Duoas 1,025 Postaholic Featured Poster

In assembly? You can (maybe) but is it worth the effort you'll need to write the loader?

The OS exists to make complicated things simple. Just use the OS functions.

Duoas 1,025 Postaholic Featured Poster

1)When i writeing program in other language can i use dll or not?
Yes, you can use a DLL in any language. The trick is only to match the correct "calling convention". Google it and read more about it. Most Windows DLLs have "stdcall" calling convention.

2)It is his mistake or MSND ... Because he call this EXPLICITE and but msdn not.
Both are correct. The difference between explicit and implicit linking is just whether or not the compiler links for you. For example, when writing windows programs, if you include <windows.h> then you can use all kinds of functions found in Windows DLLs without having to explicitly say which DLLs you want to use.

3)MSND call load-time dyna... EXPLICIT is it mind that run-time dyna... IMPLICIT?
This is non-sequitur. If you use LoadLibrary() then that is run-time loading. Otherwise it is load-time loading. This is a fairly simple, but technical issue. You shouldn't need worry about it.

The main interest for the programmer is that if a load-time DLL is not found, your program will not run. However, a run-time DLL (loaded with LoadLibrary()) allows you to choose whether to continue execution or not.

4)When i use load-time is it mind when i load first time i do not need anymore dll?
I don't understand your question.

5)Can i use any windows XP dll's?
Sure, why not?

6)What i need to do to attach another dll with this …

Duoas 1,025 Postaholic Featured Poster

Excellent. Then the code I gave you is correct.

Have fun.

Duoas 1,025 Postaholic Featured Poster

at line 13 I think that something is wrong. I think It must be: result := xs[high( xs )];

Nice catch! (That's what I get whenever I just type something in...)

I think that must has an others ways to say this without come it to personal side (It's came frequent between You).
Everyone has your view point about a subject in agreement your know how and experience. ;-)

I didn't mean to come across as caustic.

Duoas 1,025 Postaholic Featured Poster

The line vector<RequestLog> *map; creates a pointer to a vector. Since it is a pointer, no vector yet exists, and any attempt to use it ( map->push_back( foo ); ) will fail.

I think what you want is a (vector of (pointer to RequestLog)), which is written: vector<RequestLog*> map; So your code should look something like this:

RequestLog *aMapping;
  vector<RequestLog*> mappings;

  ...

  aMapping = (RequestLog*)mmap(0, FILESIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
  ...
  mappings.push_back( aMapping );

  ...

You must be very careful to watch what type of thing you are manipulating.

Now, if I misunderstood what you are trying to do:

I don't know if you can properly mmap a vector. Vectors work by allocating and deallocating from the program's heap, which is not shared between processes. You can subclass a new vector type that allocates and deallocates from a specific mmapping, but that will require a little bit of work...

Let us know what you are trying to do...

Duoas 1,025 Postaholic Featured Poster

It appears that you are trying to do ASCII graphics. Is that right?

Duoas 1,025 Postaholic Featured Poster

No, this is C++. Refer to old files like <string.h> as <cstring>.

Microsoft's CString is older than std::string, but far more recent than the old C-style string handling routines.

Duoas 1,025 Postaholic Featured Poster

What do you mean by "include a file"?

Are you talking about source code?
Or binary data (pictures, music, etc.)?
Or just regular text (ASCII, RTF, etc.)?

How do you want it to be used at runtime? And what difference does it make whether you include one or the other?

Answer these three and we'll have an easier time answering you...

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

Ah, glad I wasn't completely off in left field. I was sure ExplainThat had a better clue here than I...

The sleep() is required to give the registry time to update (it isn't absolutely instantaneous).

Duoas 1,025 Postaholic Featured Poster

Please stop going on the offensive for stylistic concerns. All four of your arguments fail:

  • It is less compact and less readable to introduce an alias for something when used but once or twice. Particularly when that alias is limited to a specific block.
  • Typos are just as likely to occur no matter what you do.
  • No one should be using "ListBox1" as a name. A careful nomenclature should start the very instant you drop a component on your form and name it properly. However, Delphi has its defaults, and examples on the net using the "ComponentType1" idiom are well-understood as representing any component of the referenced type, as opposed to some specific user's specifically named component of that type.
    It is true that both Delphi's defaults and the careless use of them on the net encourage bad naming practices, but naming practices are not the issue here, and proper naming from the start obviates the search and replace problem.
  • As for the tens of units with 1000s of lines of code... I've written larger projects than that, and never encountered any problem. Why? Specific components should always be private to the class in which they are declared. If foreign access is desirable, it should be specifically granted through the class's published properties, by which it is properly accessible no matter how stupid a name it may have internally.
    In other words, there should ever be but one unit in which a class's component is specifically referenced. …
Duoas 1,025 Postaholic Featured Poster

Overloading only works when there is a function taking arguments of the exact same type as the things you are trying to operate on.

Since L + p1; is saying "add a Point (the type of p1) to a Linea (the type of L)" you must have an overloaded function specifically for handling these two things. For example: Linea &Linea::operator + ( Point &p ) That is, it is a function which overloads adding a Point to a Line.


I am wondering, do you mean to be adding a point to a Linea, or to a PointCollection? A Linea only has two points ("begin" and "end"), so adding a Point to it doesn't seem to make much sense. What exactly are you trying to do?

Duoas 1,025 Postaholic Featured Poster

I've done my fair share of confusing people. :$

It has always been dangerous to assume that pointers and integers are compatible, but programming practice on a PC encouraged it for so many years...

Alas.

Duoas 1,025 Postaholic Featured Poster

Yeah, 20 years ago seems like the dark ages compared to now... Used to be you could know just about everything about computers... now it is an ocean of information.

Every printer nowdays has an onboard processor that manages all incoming data --I don't think you could gain direct access even if you wanted. The only trick is just sending it the right commands to print graphics. You might have more fun with something ancient like an old dot-matrix printer.

Duoas 1,025 Postaholic Featured Poster

No, you didn't overload it. L is type Linea . p1 is type Point .
Neither of these classes overload the "+" operator.

By the way, L + p1; is read as "sum L and p1 and throw away the result."

It should be something like: L = L + p1; or: L += p1; Hope this helps.

Duoas 1,025 Postaholic Featured Poster

Rather than doing ListBox1.items inside the loop, just store a reference as AList:=ListBox1.Items and use that.

You could also use a with statement. In this particular case it all comes down personal preference, as the compiler will do the same thing either way... If I only have to type it once or twice I personally find it more unwieldy to type in a temp.

strToFloat will trigger an exception if the ListBox entry is not numeric. There are two solutions - a. Use StrToFloatDef, b. wrap the loop in a try..except block and show an error message

As for the exception, that is intentional. If the list is not composed entirely of stringified floats then it cannot be summed. (Two plus green apple makes no sense.) Hence, the exception.

However, I should have said something about the exception. (I just assumed that the OP would notice that --my bad.)

In general, exceptions should not be bound into the code that may generate them, but at an "operational boundary" (as I will call it). That is, permit exceptions to unwind as far back as is reasonable. In the case of an OnClick event procedure, a user-input error should be bound to the outermost block of the procedure itself:

procedure MyForm.SumButtonClick( Sender: TObject );
  var total: double;
  begin
  try
    total := SumListBox1;
    showMessage( 'The total is ' +floatToStr( total ) )
  except
    on EConvertError do begin
      ShowMessage(
        'All the items must be numbers if you want to add them.' …
Duoas 1,025 Postaholic Featured Poster

Yeah, I've done the same thing. Now whenever I see a thread that's "on fire" with a zillion views and only a few replies the first thing I look at is the age of the thread, then I look to see if the latest poster is adding value... :|

Duoas 1,025 Postaholic Featured Poster

I've never done it, but I think you just need to tell the tray to repaint itself.
You should be able to do it with something like the following:

var
  shelltraywnd, traynotifywnd, clockwnd: HWND;
begin
  shelltraywnd := FindWindowEx( 0, 0, 'shell_traywnd', nil );
  traynotifywnd := FindWindowEx( shelltraywnd, 0, 'traynotifywnd', nil );
  clockwnd := FindWindowEx( traynotifywnd, 0, 'trayclockwclass', nil );
  SendMessage( clockwnd, WM_PAINT, 0, 0 )
end;

Let us know if that doesn't work.

Duoas 1,025 Postaholic Featured Poster

Use a loop:

var
  total: double;
  cntr: integer;
begin
  total := 0.0;
  for cntr := 0 to ListBox1.items.count -1 do
    total := total +strToFloat( ListBox1.items[ cntr ] );
  showMessage( 'The total is ' +floatToStr( total ) )
end;
Duoas 1,025 Postaholic Featured Poster

Ah, it looks like you have a good idea of what you would like to do and where to start. Good.

The question about weather has nothing to do with not getting wet or the like. The quality of the microchips themselves can only withstand certain stresses. Something you buy at RadioShack or your local PC store wouldn't survive very long on a motorcycle. They would be shaken/frozen/heated to death. You'll have to get some military-grade computer chips. (I presume there might be something designed for use specifically with autos and motorbikes you can purchase --maybe cheaper... I don't know.)

The trick will be that, once you have the system working, you can't just plug your PC onto the bike. You'll need to build a dedicated microprocessor, without a disk drive, to put under the handlebar yoke. This means some EEPROM burning and some systems design to get all the required chips and put them together.

Good luck!

Duoas 1,025 Postaholic Featured Poster

There is nothing wrong in using pointers when you need to. Since a TStack doesn't have any idea what kind of thing you intend to store (push and pop), it must recur to the most generalized thing: a pointer. You'll just have to cast it to the proper thing when you pop or peek it.

It might be worth it to spend the twenty lines of code or so to derive from TStack something that works specifically with your data type. Thus all casting and pointer errors are confined to one spot and not spread out over your code.

For example, if you wish to handle a record:

type
  PEmployee = ^TEmployee;
  TEmployee = record
    name: string[ 128 ];
    payrate: currency
    end;

  TEmployeeStack = class( TStack )
    public
      function peek: TEmployee;
      function pop: TEmployee;
      procedure push( employee: TEmployee );
    end;

implementation

  function TEmployeeStack.peek: TEmployee;
    begin
    result := PEmployee( inherited peek )^
    end;

  function TEmployeeStack.pop: TEmployee;
    var pe: PEmployee;
    begin
    pe := PEmployee( inherited pop );
    result := pe^;
    dispose( pe )
    end;

  procedure TEmployeeStack.push( employee: TEmployee );
    var pe: PEmployee;
    begin
    new( pe );
    pe^ := employee;
    inherited push( pe )
    end;

Now when you use a stack of employees you don't need to worry about the pointers being used behind the scenes, and you can deal directly with the employee records.

This version of peek prevents you from directly modifying the last item on the stack. You must pop, modify, then push to change it. If …

Duoas 1,025 Postaholic Featured Poster

So what you want to do is create your own DLL which your application can use to do something?

What programming environment are you using (compiler/IDE)?

Duoas 1,025 Postaholic Featured Poster

Er, it doesn't go against Pascal's philosophy at all. The STL just does things from a different point of view.

If you want to push and pop, it should be easy enough to write your own procedures to do that. Keep in mind, however, that Pascal doesn't (yet) have a standardized template capability (some Pascals extend Schemata to do it --which I think is the Right Thing... but anyway):

Push/Pop an int array:

uses SysUtils;

procedure pushInt( var xs: array of integer; x: integer );
  begin
  setLength( xs, length( xs ) +1 );
  xs[ high( xs ) ] := x
  end;

function popInt( var xs: array of integer ): integer;
  begin
  if length( xs ) = 0
    then raise Exception.Create( 'popInt: nothing to pop' );
  result := high( xs );
  setLength( xs, high( xs ) )
  end;

Finally, ExplainThat, you need to stop pushing bare pointer usage on everyone. It is good to know how they work and how to use them, but they are not the answer to all questions. Their usage is deprecated in Pascal just as in every other language because:
- they are not type safe (even in Pascal, where they are more carefully typed than anywhere else!)
- they reduce the compiler's ability to use meta information that structured data contains
- they introduce programmer errors
- (there's more, but I have to go right now...)

Duoas 1,025 Postaholic Featured Poster

The OP posted this 4 years ago.

Duoas 1,025 Postaholic Featured Poster

A DLL is not very different than an EXE. (Both are PE32 files.) The primary difference is how they are expected to be used. (That is by no means the only significant difference, so you can't just rename your DLLs to EXEs and expect them to work...)

You might start out by checking out what MSDN has to say.

If by "get into a dll file" you mean that you want a list of its import and/or export tables, then google "pe32 import export table" to get started. There are system APIs to help here.

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

Further, depending on your choice of programming language, it is likely you can find free software libraries that will store all your configuration data in a structured text file format, for example: XML or even (gasp!) INI.

Salem commented: I like XML +12
Duoas 1,025 Postaholic Featured Poster

Heh, well, you are certainly jumping in by the deep end.

You might want to check out sourceforge for fingerprint software. It is by no means a simple programming exercise.

The ignition for the car is basically a simple mechanical switch on the same stator as the lock. Insert the key, the tumblers permit movement, and viola: you can turn the switch and make electrical connections. So:

Q1: Do you plan to leave the key-lock switch in place or did you want to entirely replace it with the fingerprint scanner?

Q2: How's the weather where this car will be used? Consumer computer components don't have a particularly robust range of operating temperatures (which is why military hardware costs so much, as it has to operate in extreme conditions).

Q3: How much experience do you have programming? Have you ever dealt with embedded devices?

You are going to have to do some serious research before you begin putting this all together. And it won't be particularly cheap.

Lastly, is this to be the only security on the car? For example, how do you plan to prevent access to the vehicle (by locking the doors, etc.)? What if the scanner fails? Or if the software faults?

This sounds like a really cool project. I'm sure there are people out there who have dealt with this kind of thing before. You might also get information on biometric security systems on buildings and the …

Duoas 1,025 Postaholic Featured Poster

length() returns the number of elements in an array.
low() returns the index of the first element.
high() returns the index of the last element.
setLength() changes the size of a dynamic array.

var
  xs: array of integer;
  cntr: integer;
begin
  setLength( xs, 5 );
  writeln( 'Please enter ', length( xs ), ' integers: ' );
  for cntr := low( xs ) to high( xs ) do read( xs[ cntr ] );
end.
Duoas 1,025 Postaholic Featured Poster

Most people have it on their website before you download. Some older packages you must first download and unzip to find it, but you can always learn this information before installing.

"Open Source" has been used by businesses to mean that you can access and use their software, but they retain rights to do as they will.

This is different from "Free Software" which generally has more permissive license terms.

The FSF has a webpage all about software licenses (and whether or not they approve).

Duoas 1,025 Postaholic Featured Poster

For sequential, repetitive tasks, use a loop.

Duoas 1,025 Postaholic Featured Poster

Typically you make your application match XP's visual style simply by linking the XP common-controls manifest as a resource for your application. (You must do this if you want theming capabilities either way. Also, it is better to link as a resource than to just have a manifest file in the same directory.)

That's all you need to do to make your application pretty.


It is possible, however, to use a different visual style than the one the end-user selected. Now, the end-user may not like that too much, so be sure you have good reason to do this, and that you give the end-user a way to turn it off.

You might want to take a look through the MSDN Visual Styles Reference.

Here's a little site I googled that might help get you started. The examples are in VB.

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

Assuming EBX isn't clobbered by the function, then yes, it should work.

Duoas 1,025 Postaholic Featured Poster

Not every possible flavor necessarily compiles using the default build process.

You are trying to link with the regex library that has the following features:
- multithreading support
- using debug versions of the standard and runtime support libraries

If your application doesn't use multithreading, you don't need the -mt- tag in the library name: remove it and use a smaller lib.

Also, there is really no reason you need to link to debug versions of the standard and runtime libraries. That stuff is for people developing the standard and runtime libraries. Otherwise, you can safely assume that the standard and runtime libraries won't cause any errors... Get rid of the -gd- tag. (If you are debugging your own code, you may want to leave the -d- tag in there until you compile the release version of your program.)

Most of the tags you will not need unless you are doing something pretty unusual. The most likely is the -s- tag if you want to statically link with the standard and runtime libraries on *nix systems. (Static linkage is default on Windows.)

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

Implement a simple Turing machine.

Duoas 1,025 Postaholic Featured Poster

Merging always implies some sort of collation. The idea is not to append/connect then sort, but rather to sort at the same time as you connect them together.

A naive but robust method would be to take each node from list B and insert it into list A in its proper place.

Hope this helps.

[EDIT] BTW. The Wikipedia is always a useful resource for this kind of question.

Duoas 1,025 Postaholic Featured Poster

You have failed to use the proper directives to organize your code and data. Please read TASM's documentation.

I should note also that you've got some pretty egregious errors there, particularly when calling and not returning.

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

In Qt's case, it means you can't sell your application. Qt is a commercial company, so they want you to buy a developer's license. But they've made it possible for people who do stuff for free (i.e. KDE) to use their stuff without paying anything.

Duoas 1,025 Postaholic Featured Poster

Don't forget to make yourself little subroutines to do stuff for you. In C there are the strcpy() and strcat() routines. Your routines should do the same kind of things.

That way you can use them as often as you like. If you are dealing with multiple files this will help tremendously.

Good luck.

Duoas 1,025 Postaholic Featured Poster

No, you need to compile your code into a DLL file of your own making. Windows won't let normal applications gain system-wide hooks because they can terminate anytime they like. A DLL, however, terminates only when the system is done with it. So when you set the hook, it must point to a hook procedure in a specific DLL.

So, you will need to create two projects: one to create the DLL which contains your KeyboardProc (and which you'll probably want to export other functions to give information about the hook) and one to create your EXE application which uses the DLL from the first project.

I know its a pain... but it is the only way to actually modify keyboard input when your application is not active. I'm sure there is a lot of sample code on the web to do just that...

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

The most recent trend for assembly is on embedded devices (like your cell phone, the thing under the dash in your car, GPS devices, new game systems, etc.)

Like Salem said, it is very specialized. Employers may or may not care if you know their specific machine, but they will care that you are capable with basic PC systems, like x86 and MIPS. If you are capable in several systems then you will have no problem picking up a specialized chip's architecture.

While jobs for people who know assembly are relatively rare, they do exist. They aren't necessarily glamorous though (i.e. they don't necessarily pay that much more than any other programmer job).

AFAIK.

It will only help you to know assembly. But you don't really need to spend a lot of time with it at the start if all you want is a high-paying job. People who are good at assembly are good because they enjoy it. Money is a nice side effect.

Duoas 1,025 Postaholic Featured Poster

Yeah, I was thinking of Ultimate++ also.

If you don't mind writing "open source" there is also Trolltech's Qt, which I think still comes with a GUI designer. Version 3 had it at least.

And there is GNOME's Glade (GTK+) designer.

There is also the The GUI Toolkit, Framework Page.

Hope this helps.

Jishnu commented: Thanks :) +2