Duoas 1,025 Postaholic Featured Poster

Why the bile, jwenting?

I agree with your sentiment, but QuickBasic/QBasic/FreeBasic is far from dead. Perhaps something a little more useful to the OP would be in order?

Duoas 1,025 Postaholic Featured Poster

An identifier and a string are different because a string is surrounded by double-quotes.

Movie a(
  "Scorcese",
  "the Departed",
  "Drama",
  151,
  "Leonardo diCaprio",
  "5 Stars",
  "2006"
  );

Formatted for readability...

Have fun!

Duoas 1,025 Postaholic Featured Poster

Ah, the loop ends at the space because the string ends at the space. scanf stops reading input at spaces. So when you enter "1234 432" the userString gets "1234", and " 432" is left waiting to be read.

If you want to get a string from the user try using fgets().

Good luck.

Duoas 1,025 Postaholic Featured Poster

Ah, I understand what happened.

Sorry RossSCann, I thought you had done the edit. (And I had flagged the post as "bad".)

Duoas 1,025 Postaholic Featured Poster

Those links don't work for you?

[EDIT]
Don't you dare put words in my mouth. If you want to edit your own posts again have fun.

Duoas 1,025 Postaholic Featured Poster

After some googling, the best answer is that you are getting the message when trying to compile your program, and it is because you have one or more modules that are too large.

For example, if you have all your code in a single .dpr then you need to add some units and move code out of the .dpr.

The same goes for units. Each unit must compile all its code and data to fit in a 32K segment. Figure out which unit is giving the 'too large' error and split it into two smaller units.

You can also save some space by disabling things like range checking and overflow checking. (Don't disable stack checking though.)

Good luck!

Duoas 1,025 Postaholic Featured Poster

What do you mean by "static" and "dynamic" instructions?

I don't see anything there worth 60,000 bytes.

I also don't know how you could make a bubble sort any smaller...

Duoas 1,025 Postaholic Featured Poster

Show your professor my post, ask him what we have misunderstood about your assignment, and post back with the response. :yawn:

Duoas 1,025 Postaholic Featured Poster

Surely your professor has given you more information than you have given us?

Is your application supposed to be text or GUI?
Are you supposed to click on the keys?
If so, what is supposed to happen if you do?
Is this strictly Win32 or are you using some sort of graphics library?
Are you supposed to draw the keyboard yourself, or just to display some keyboard image?

Let us know.

Duoas 1,025 Postaholic Featured Poster

That would work, but it is not recommended.

The purpose of overloading a function is to allow the same operation to be done on different data.

For example, if you want to print a string you might have a couple of overloaded functions: void print( const char *s ); void print( const std::string s ); This allows you to account for the different ways in which you may think of a "string".

However, no matter how the string is represented the underlying operation is the same: the string is printed. That is to say that the purpose of overloading a function is not to give functions that do different things the same name. The functions may have to accomplish their goal differently, because the data given them are different, but the end result is the same: something gets printed.


In your case, then, I don't think you ought to overload anything. You are doing four distinct things: 1) depositing to checking, 2) withdrawing from checking, 3) depositing to savings, 4) withdrawing from savings. Since you are doing four things, make four functions.

Given that the only variance between depositing and withdrawing is the sign of the amount of money added, you could combine the checking functions into one, and the saving functions into another: double calculate_checking_balance( double capital, double principal ); double calculate_savings_balance( double capital, double principal ); So to deposit $12.00 into savings, you would say: savings = calculate_savings_balance( savings, 12.00 );

Duoas 1,025 Postaholic Featured Poster

For a simple mathematical equation (in other words, something that can be done in one or two lines), why do you need a function?

To overload a function you have to have at least one of the following

  • a different number of parameters
  • at least one corresponding parameter of different types

(The result type doesn't make a difference.)

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

No. How close to the edge you can get is entirely dependent on the printer model.

Many modern home ink-jet printers can get to 1/2 inch of the edge.

You can get information about the printing area using the Win32 DocumentProperties function.

Good luck!

Duoas 1,025 Postaholic Featured Poster

Hey there. I just wanted to update my answer a little (I've looked it up to be sure).

It is actually a little easier than I thought it would be. Make your RC file

whizzing_fizzbang WAVE "whizzfizz.wav"
pop_rockets       WAVE "poprockets.wav"

etc.

Here's a little snippit of how to use it:

#include <string>
#include <windows.h>

...

void play_wav_resource( std::string resname, bool is_loop ) {
  HANDLE hfound, hsound;
  LPVOID data;

  hfound = FindResource( NULL, resname, "WAVE" );
  if (hfound != 0) {

    hsound = LoadResource( NULL, hfound );
    if (hsound != 0) {
      data = LockResource( hsound );

      if (data != NULL) SndPlaySound(
        (char *)data,
        SND_ASYNC | SND_MEMORY | (is_loop ? SND_LOOP : 0)
        );

      UnlockResource( hsound );
      }

    }
  FreeResource( hfound );
  }

void stop_wave_sound() {
  SndPlaySound( NULL, 0 );
  }

This code snippit is from this page on embedding resources (in Delphi). You can learn more stuff there. (The About.com pages have a lot of great stuff like this.)

Keep in mind that you don't actually have to free the resource until you are done with it. This routine does so because it uses the resource then it is done with it. Hence, the resource is re-loaded each time it is needed. If you plan to use the sound often, it would be better to load it once, then just use it as oft as you want. (You don't ever have to actually free it explicitly, since Windows will do that …

Duoas 1,025 Postaholic Featured Poster

You only said that the app was made with Delphi. That doesn't mean you have access to the source.

In any case, I'll see if I can find you some good message IPC links and/or code.

Duoas 1,025 Postaholic Featured Poster

What do you mean by "upload"?

If you just want to display the picture, you will have to get a JPEG decompression library (QBasic can interface with DLLs that do this), and you will need to switch to a GUI mode to display it.

Duoas 1,025 Postaholic Featured Poster

I don't know about .NET, but the Win32 functions are all listed here: Console Functions (MSDN).

You will need to enable mouse input with SetConsoleMode.
You can read it using ReadConsoleInput.

Use GetStdHandle to get a windows handle for the console input.
Use GetNumberOfConsoleInputEvents to poll for any console input, or use the console input handle with one of the wait functions.

Hope this helps.

[EDIT] Alas, AD, the cursor info is for the little blinking square or underline in the output console display.

Duoas 1,025 Postaholic Featured Poster

Yes, like AD said, if you don't have access to the Delphi code then you are pretty much out of luck.

The best way is to set up some form of IPC.

  1. You can create a parent-child pipe.
  2. You can use windows messages.
  3. You can create server/client sockets.

Those are your choices on Windows.

Duoas 1,025 Postaholic Featured Poster

Add writeln( ShortDateFormat ); to your code and see if it reads something like yyyy/m/d .

Also please look again at this thread, down at the bottom of the first post where it says "Convert From A String".

Sorry I've been so busy, altzaportu. I'll respond to you more later...

Duoas 1,025 Postaholic Featured Poster

It works just fine.

Make sure your RC file looks something like

MySound1 RCDATA "spiff.wav"
MySound2 RCDATA "bloink.wav"

etc.

Compile it to a resource file (*.res) using whatever program you have to do that (like windres.exe that comes with GNU stuff).

Inside your program, you'll need to use the windows API to access the resources.
First, get the resource with HRSRC MySound1_rsrc = FindResource( NULL, "MySound1", RT_RCDATA ); Then, load the resource with HANDLE MySound1_handle = LoadResource( NULL, MySound1_rsrc ); If either of these functions fail the return value is 0. You do not need to call FreeResource on the MySound1_handle at any time (but you can if you are sure you are done with it).
(For those of you who are paying attention, the returned handle is not global.)

Now you have a Windows handle you can pass to ReadFile.

Hope this helps.

Ancient Dragon commented: Excellent info! :) +21
Duoas 1,025 Postaholic Featured Poster

You've got a type problem. Always make sure you are handling the same type of things.

An int *foo; is the same as an int foo[]; But it is very different from an int *foo[]; (which is the same as an int **foo; )

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

Don't bother to save stuff you don't want. For example, if you only want the first and fifth items in a ten-item line:

string line;  // we'll read whole lines at a time

while (inFile) {
  // get a whole line
  getline( inFile, line );

  // skip blank lines
  if (line.empty()) continue;

  stringstream ss( line );  // stream to parse the line
  string first;
  string fifth;

  // get the first elt
  getline( ss, first, ',' );

  // skip elts 2..4
  for (int i = 1; i < 4; i++)
    if (!ss.ignore( 50, ',' )) {
      cout << "The line has less than ten elements" << endl;
      continue;  // next line
      }

  // get the fifth elt
  getline( ss, fifth, ',' );

  // Show the user what we've got
  cout << "The first and fifth elements are "
       << first << " and " << fifth << endl;
  }

How exactly you handle things like blank or misformatted lines is up to you. Also, I just used a maximum 'skip' value of 50. You might want to use something larger or smaller as appropriate.

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

Change line 160 back to currentWord->head = NULL; You know that is correct, so if something breaks then there is an error elsewhere. (It compiles fine for me with the correct assignment.)

For line 267, surely you don't mean to say that a std::string and a wordList* are the same kind of thing?
You'd have to say something like letter[ index ]->head->newWord = getWord; because (word*)->newWord is a std::string.

Since I've a headache and I'm tired I haven't bothered to examine your code too closely, and since it is not too obvious what it does (nor is it documented what it does) I can't say more than "are you sure what you are doing with an array of linked lists?"

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

Yes. Try it out. :)

Duoas 1,025 Postaholic Featured Poster

TThread is an abstract class. You must override all purely virtual functions in the descendant class --in this case, you must override the Execute method.

Place the cursor over the word "TThread" and press F1 to read more and find an example.

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

It is a read-only property so it will not be listed in the Object Inspector.

You can read the docs by placing the cursor over the word "TForm1" and pressing F1.

Duoas 1,025 Postaholic Featured Poster

I too fail to see how complaining about the OP's tools helps him answer his question. There is no need to give him/her a hard time.

In the real world of capitalism, choice of toolset is entirely dictated by business concerns. Nothing else. Business [or school] issues dominate technical issues. Period.


stackOverflow
There are three answers to your problem --two that you have already found.

  1. Use outtext and/or outtextxy along with setviewport to draw the text graphically on the screen but keep it bounded into an area. You will probably also find the textwidth and textheight functions useful.
  2. Switch to text mode to display it, and return when done.
  3. Use the BIOS functions to dump the text onto the screen. Even though you are in a graphics mode, the video BIOS can still write to the screen as if it were a TTY.

For option 1, you might want to check out this thread, where that OP had a similar question.

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

There is a form property called 'handle'. It is the HWND of your form.

Duoas 1,025 Postaholic Featured Poster

Sorry, I must have been asleep when I thought you were using TP. Delphi 1 is a 16-bit compiler, so the same restrictions apply. But it doesn't provide overlays I don't think.

I don't remember how to fix it so let me look at it and see what I can come up with (unless someone else here knows)...

Duoas 1,025 Postaholic Featured Poster

That has nothing to do with it. The problem is how objects are stored and managed internally. A particular vendor's language suite may manipulate objects the same way, but not necessarily. Different vendors almost always differ.

If you have access to the source code of the MS-object, you can port it to Delphi, but your options are technically limited otherwise.

Duoas 1,025 Postaholic Featured Poster

You can't. Sorry.

Duoas 1,025 Postaholic Featured Poster

16-bit x86 processors divide memory into "segments". Typically, all your code must fit in one segment. The way around this is to use "overlays". Good luck.

Duoas 1,025 Postaholic Featured Poster

You've actually hit on the right idea. You've just made a couple of simple mistakes.

Firstly, you have a full point object

TYPE
    point = RECORD
          x: real;  { This is the abscissa }
          y: real;  { This is the ordinate }
    END;

Remember, the word "abscissa" means the same as the x-coordinate; likewise "ordinate" means the y-coordinate.

You have opened the file correctly, and your file I/O is technically correct, but your confusion over the coordinate pairs has tripped you up. Try:

var
    output_file:         file of point;
    a_point:             point;
    number_of_points, i: integer;

begin
    ...
    for i := 1 to number_of_points do begin
        writeln( 'Enter the ', i, 'th coordinate as: X Y' );
        readln( a_point.x, a_point.y );
        write( output_file, a_point )
    end;
    ...
end.

Reading a point from file is just the opposite:

read( input_file, a_point );
writeln( 'The point just read is (', a_point.x, ',', a_point.y, ')' );

A linked list is always of the form:

type
    pNode = ^tNode;
    tNode = record
        ...           { my data goes here }
        next: pNode   { the next node in the list, or nil }
    end;

var
    head_node: pNode;
    { The head node always points to the very beginning of the linked list. }
    { If there aren't any nodes, then it should have the value: nil }

I recommend that you also have some functions which help you add (and/or append) and remove nodes from the list.

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

The fact that that works is fluke.

What is the pixel format for your image? (pf1bit, pf4bit, pf8bit, pf15bit, pf16bit, pf24bit, pf32bit, something else?)

If it is pf24bit then every three bytes are a tuple (blue, green, red) --in that order.

If you need to learn more about the different formats then see efg's technical notes on manipulating scanline data.

You might also want to peruse efg's Color Reference page.

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

No, you've completely missed the concept of argv.

argv is an array of strings (where a string is a pointer to char). It is not safe to change argv.
argc is the number of items in the argv array.

argv[0] is the program name.
argv[1] is the first argument.
etc.

This might help you.

#include <stdlib.h>
#include <stdio.h>

int main( int argc, char *argv[] ) {
  int i;

  printf( "My name is: %s\n", argv[ 0 ] );

  for (i = 1; i < argc; i++)
    printf( "arg %d: %s\n", i, argv[ i ] );

  return 0;
  }

You can test it:

D:\prog> a
My name is: a

D:\prog> a Hello world!
My name is: a
arg 1: Hello
arg 2: world!

D:\prog> ren a.exe carlos.exe

D:\prog> Carlos de la Paz Gutieres-Hernandez
My name is: Carlos
arg 1: de
arg 2: la
arg 3: Paz
arg 4: Gutieres-Hernandez

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

I feel like a total geek. I always use python straight from the command-line.

Duoas 1,025 Postaholic Featured Poster

I think it would be helpful to know a little more about the Lidar data record. Presumably it is some large number and two coordinates (elevation, longitude, latitude)?

What do you mean by "sorted"? Sorted by elevation?

In any case, you need a divide-and-conquer algorithm for sorting.

Duoas 1,025 Postaholic Featured Poster

For option number two, google Resource Hacker. That'll do it.

Duoas 1,025 Postaholic Featured Poster

You may be trying to allocate too large a chunk of memory at once.

Have you considered using an STL std::deque, or a std::list (or other linked list)?

Is it absolutely necessary to load the entire list at once?

I presume you are doing some post-processing on the lidar data (that this isn't some sort of real-time system)?

Duoas 1,025 Postaholic Featured Poster

I don't have Vista, so I can't exactly identify what part of the OS is giving you the problem.

IDLE uses a feedback loop socket. This is a weird thing to do, so antivirus and internet access filters (like ZoneAlarm and the like) complain. Vista has a lot of protocol built-in about what can connect to the internet and how. Even though IDLE isn't actually dialing out...

Find your internet connection wizard/control panel/whatever Vista uses and make sure that IDLE is permitted to access the internet any way it darn well pleases...

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

Bluetooth was designed as a C and C++ API, but you can use the Windows Sockets interface directly to make a Bluetooth application. (People also sell components you can use with Delphi, but they aren't cheap.)

You might want to check out these MSDN articles:
Bluetooth Programming with Windows Sockets
Bluetooth Reference

That's the best I could google with a short attention span. Good luck!

Duoas 1,025 Postaholic Featured Poster

It looks like an old Turbo variant to me. Did you try asm move dh, [y] ?

This is just a guess...

Duoas 1,025 Postaholic Featured Poster

The first is local data you can edit (since the array is local data).

The second is a local pointer to global, static (constant) data. You are not allowed to modify constant data.

If you have GNU C, you can compile with -fwritable-strings to keep the global string from being made constant, but this is not recommended.

Duoas 1,025 Postaholic Featured Poster

you could put std:: (code) before every line to specify that the following code is from the standard library, but this method would be cumbersome and would waste time.

That's a pretty powerful, self-assured opinion you've got there.

It is neither cumbersome nor does it waste time. What it does is prevent obnoxious namespace errors and mistakes. IMO, no library code should ever have a using namespace [I]foo[/I]; statement, unless you can guarantee that it stays in local blocks. Which namespaces are visible, and where, is for the person programming the application to decide, not the libraries he is using.

In other words, portable, well-written, library code doesn't dump namespaces together without your OK.

It's not just my opinion.

Duoas 1,025 Postaholic Featured Poster

printf() and cout both send data to the same place.

C++ only knows of the standard input, output, and error channels, and any other files/sockets/devices/etc. you explicitly open.

If you want to display things differently on Windows, you have to go through the Win32 API. For example:

#include <windows.h>

int main() {
  MessageBox( NULL, TEXT( "Hello world!" ), TEXT( "A greeting" ), MB_OK );
  return EXIT_SUCCESS;
  }

There are all kinds of ways to display textual data in Windows: message dialogues, labels, edit boxes, etc.

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

Well, you can do it the portable way (there is more than one way to do it the portable way; this is only my latest variation for y'all):

#include <iostream>
#include <limits>

namespace console {
  void pause() {
    std::cout << "Press ENTER to continue...";
    std::cin.ignore( std::numeric_limits<std::streamsize>::max(), '\n' );
    }
  }

Or, since all the other things you want to do (like clear the screen) are non-portable anyway, you can do it the Windows way:

#include <iostream>
#include <windows.h>

namespace console {
  void pause() {
    DWORD        mode;
    HANDLE       hin;
    INPUT_RECORD inrec;
    DWORD        count;

    // Instruct the user
    std::cout << "Press the 'any' key...";

    // Set the console mode to no-echo, raw input,
    // and no window or mouse events.
    hin = GetStdHandle( STD_INPUT_HANDLE );
    GetConsoleMode( hin, &mode );
    SetConsoleMode( hin, 0 );

    // Wait for and get a single key press
    do ReadConsoleInput( hin, &inrec, 1, &count );
    while (inrec.EventType != KEY_EVENT);

    // Restore the original console mode
    SetConsoleMode( hin, mode );
    }
  }

You can use it the usual way:

int main() {

  std::cout << "Hello world!\n" << std::endl;

  console::pause();

  std::cout << "\n\nThank you!" << std::endl;

  return EXIT_SUCCESS;
  }

Enjoy!

Duoas 1,025 Postaholic Featured Poster

After you start the new application (who's caption is in the variable NewAppTitle, and whose icon is in the variable NewAppIconImage), you will have to use something like the following

Me.MyMenuStrip.Items.Add( _
    NewAppTitle, _
    NewAppIconImage, _
    New EventHandler( AddressOf MyMenuStrip_OnClick ) _
    )

You will have to define a Sub named MyMenuStrip_OnClick:

Private Sub MyMenuStrip_OnClick( _
    ByVal sender As System.Object, _
    ByVal e As System.EventArgs _
    ) Handles MyMenuStripMenuItem.Click   
        'do stuff here
    End Sub

This procedure handles clicks for every button on the taskbar that minimizes/restores a running application. Inside the sub you'll have to check the sender to see which application is supposed to be manipulated.

I am not sure about the name following the 'handles' keyword. I don't have VB and I haven't used it since .NET was introduced. Perhaps someone else here can fix any syntax errors I made...

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

Actually, for the answer to (1), you can make the window text bigger by adjusting the font, but you'll need to do it in a shortcut.

  1. Create a shortcut that starts your gwbasic application.
  2. Use the shortcut to start the program.
  3. Right click on the console window's menubar to get a pop-up menu. Choose "Properties".
  4. Make all the changes you like until you are satisfied with the result.
  5. Click "OK" and then select the option to modify the shortcut that started the program.

If you mean that you want more columns/lines than 80x25, then you will have to poke around in memory to do it (as XP still supports the old DOS subsystem). You will probably have to use some assembly language routines to change the display mode (it has been a while, so I don't remember how, exactly...). You are most likely to have success if you use 80x50.

You might also want to look through "Running GW-BASIC under Windows".

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

Supply a different .h file to people using the library than the one used to compile it.

Duoas 1,025 Postaholic Featured Poster

I'm not sure what else to say.

You have indicated that your "taskbar" is actually implemented as a tear-off menubar.

Menubars have menu items. How did you put the "start" button/menu on it?

Do the same thing to put more buttons on the bar whenever you start a new program. The only difference is that each new menu item doesn't have a sub-menu (so if you were to click it no sub-menu would pop up).

You will have to keep track of which menu item is associated with each running program, so that when it is clicked you can minimize or restore the correct program.

Duoas 1,025 Postaholic Featured Poster

Don't worry about it.

I'm not sure exactly why the problem occurs either. But the type was being mangled incorrectly without the explicit cast.

I added a tellg() statement after the seekg() to see where the fp was, and I was getting some really large number, which showed me that it was not seeking from eof properly. So I checked the type of sizeof() against what the function wanted in order to find the error. I think that the problem is one of those "gotchas" from using templated objects.

Alas.


For the namespace problem, it sounds like you have already used something like using namespace fooey; or using namespace std; or one of the headers you imported did it for you, so if you try to say using namespace std; again it looks in the local namespace and says, basically, "std doesn't have any namespace called 'std'".

You can fix it by explicitly referring to the global namespace: stfile.seekg( -([B]::[/B]std::streamoff(sizeof(item))), [B]::[/B]ios::end ); or by (if you are using std) just stfile.seekg( -(streamoff(sizeof(item))), ios::end ); That could fix it. (Of course, your solution, by using an intermediate/temporary int works as well [obviously], because the compiler could properly promote the int type to streamoff.)


For the binary stuff, try running your program without the binary I/O and entering the number 10 in answer to either price and/or stock. You'll see that it doesn't write 40 bytes, but 41 or 42. This is …

Karkaroff commented: thanks! that clears things a bit +1