Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 360
  • Last Modified:

URGENT Problem with making program

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

INPUTS

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
Manderson
0
Stephen Manderson
Asked:
Stephen Manderson
  • 2
1 Solution
 
ZhaawZSoftware DeveloperCommented:
Is it something like this?


{$N+}
program prog;

uses
  wincrt;

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

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

begin
write('How many records? ');
readln(count);
clrscr;
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;
     inc(data);
     readkey;
     clrscr;
  end;
  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);
    inc(data);
  end;
end;
data := data2;
FreeMem(data, sizeof(data) * count);
end.
0
 
Stephen MandersonSoftware EngineerAuthor Commented:
Its not homework, just fiddling around with pascal, just a few problems that I am having with understanding certain aspects of it.

Many Thanks
Manderson
0
 
mlmccCommented:
That is basically what I figured from your profile.

mlmcc
0
 
ZhaawZSoftware DeveloperCommented:
Is a question answered?
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now