URGENT Problem with making program

Posted on 2005-03-13
Medium Priority
Last Modified: 2010-04-16
Hi all, I am currently trying to make a program that will calculate a file size depending on the height width bit depth, and take the first 4 charachters or a description as well
 as a date and create a file name for it. The inputs are as follows


Height - 640
Width - 480
Depth - 8
Description - trees
Date - 150604

The problem comes as I use vb and I am unsure of how to create an array to hold the first 4 chars of the desc and join it with the date and add a ".bmp" Extension. Idealy what the output should be like is as follows.

Height       Width        Bit Depth     File Size        Filename
640           480           8                300kb            tree150604.bmp

Any help would be great, I will ask the question again if anyone can post a program, for double points.

Many Thanks
Question by:Stephen Manderson
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 11

Accepted Solution

ZhaawZ earned 2000 total points
ID: 13529910
Is it something like this?

program prog;


  TFileData = record
    descr  : string;
    height : word;
    width  : word;
    depth  : byte;
    date   : string[6];
    size   : string[10];
    filename : string;
  PFileData = ^TFileData;

  data2 : pointer;
  data : PFileData;
  n : byte;
  count : byte;
  fsize : double;
  funit : string[2];

write('How many records? ');
GetMem(data, sizeof(data) * count);
data2 := data;
if count > 0 then begin
   for n := 0 to count - 1 do begin
     write('Height      - '); readln(data^.height);
     write('Width       - '); readln(data^.width );
     write('Color depth - '); readln(data^.depth );
     write('Description - '); readln(data^.descr );
     write('Date        - '); readln(data^.date  );
     data^.filename := copy(data^.descr, 1, 4) + data^.date + '.bmp';
     fsize := 1/8 * data^.depth * data^.width * data^.height;
     funit := 'B';
     if fsize >= 1024 then begin fsize := fsize / 1024; funit := 'KB'; end;
     if fsize >= 1024 then begin fsize := fsize / 1024; funit := 'MB'; end;
     if fsize >= 1024 then begin fsize := fsize / 1024; funit := 'GB'; end;
     str(fsize:0:2, data^.size);
     data^.size := data^.size + funit;
  data := data2;
  writeln('Height', 'Width':10, 'Color depth':18, 'File size':15, 'Filename':15);
  for n := 0 to count - 1 do begin
    gotoxy( 0, n + 2); writeln(data^.height);
    gotoxy(12, n + 2); writeln(data^.width );
    gotoxy(24, n + 2); writeln(data^.depth );
    gotoxy(41, n + 2); writeln(data^.size  );
    gotoxy(57, n + 2); writeln(data^.filename);
data := data2;
FreeMem(data, sizeof(data) * count);
LVL 19

Author Comment

by:Stephen Manderson
ID: 13533932
Its not homework, just fiddling around with pascal, just a few problems that I am having with understanding certain aspects of it.

Many Thanks
LVL 101

Expert Comment

ID: 13536989
That is basically what I figured from your profile.

LVL 11

Expert Comment

ID: 13548064
Is a question answered?

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Learn how to use the free Acronis True Image app to easily transfer data between iPhones and Android phones.
Hey fellow admins! This time, I have a little fairy tale for you. As many tales do, it starts boring and then gets pretty gory. I hope you like it. TL;DR: It is about an important security matter, you should read it if you run or administer Windows …
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question