$APPTYPE GUI $OPTIMIZE ON $TYPECHECK ON $INCLUDE "rapidq.inc" $ESCAPECHARS ON CONST FILENAME = "data.txt" DEFINT NUM_LABLE_SETS DEFINT MIN_HEIGHT CONST MIN_WIDTH = 250 DECLARE SUB Load() DECLARE SUB EnsureDataFileExists() DECLARE FUNCTION LinesInDataFile() AS INTEGER DECLARE SUB CreateLabelSets(number AS INTEGER) DECLARE SUB LoadDataIntoLabels() DECLARE SUB Form_Resize() CREATE SplashForm AS QFORM BorderStyle = bsNone Height = 25 Width = 100 Center CREATE WaitLabel AS QLABEL Caption = "Loading..." AutoSize = 1 Alignment = taCenter Layout = tlCenter Align = alClient END CREATE END CREATE CREATE Form AS QFORM Caption = "Data Labels" Width = 320 Height = 140 OnResize = Form_Resize Center END CREATE ' Begin Initalization SplashForm.Show DoEvents EnsureDataFileExists() DoEvents DEFINT numLines = LinesInDataFile() IF (numLines MOD 2 <> 0) THEN SHOWMESSAGE "The data files does not contain matched name/value pairs." END END IF DoEvents DIM StaticLabels(1 TO numLines / 2) AS QLABEL DIM DataLabels(1 TO numLines / 2) AS QLABEL DoEvents CreateLabelSets(numLines / 2) DoEvents LoadDataIntoLabels() DoEvents SplashForm.Close DoEvents ' End Initalization Form.ShowModal SUB EnsureDataFileExists() IF (FILEEXISTS(FILENAME) = 0) THEN SHOWMESSAGE "Could not locate \"" + FILENAME + "\" in the current directory." END END IF END SUB FUNCTION LinesInDataFile() EnsureDataFileExists() DIM input AS QFILESTREAM input.Open(FILENAME, fmOpenRead) Result = input.LineCount input.Close END FUNCTION SUB CreateLabelSets(number AS INTEGER) IF (number <= 0) THEN SHOWMESSAGE "Cannot create less than one label set!" END END IF NUM_LABLE_SETS = number DEFINT i FOR i = 1 TO NUM_LABLE_SETS DoEvents StaticLabels(i).Parent = Form StaticLabels(i).Left = 5 StaticLabels(i).Width = 35 StaticLabels(i).Transparent = 1 StaticLabels(i).Visible = 1 DataLabels(i).Parent = Form DataLabels(i).Left = 40 DataLabels(i).Transparent = 1 DataLabels(i).AutoSize = 1 DoEvents NEXT i MIN_HEIGHT = number * (StaticLabels(1).Height + 5) + 10 Form.Height = 1.5 * MIN_HEIGHT END SUB SUB LoadDataIntoLabels() DIM input AS QFILESTREAM input.Open(FILENAME, fmOpenRead) DEFINT i FOR i = 1 TO NUM_LABLE_SETS DoEvents StaticLabels(i).Caption = input.ReadLine() + ":" DataLabels(i).Caption = input.ReadLine() DoEvents NEXT i input.Close END SUB SUB Form_Resize() IF (Form.Width < MIN_WIDTH) THEN Form.Width = MIN_WIDTH EXIT SUB END IF IF (Form.Height < MIN_HEIGHT) THEN Form.Height = MIN_HEIGHT EXIT SUB END IF DEFINT availLabelHeight = Form.ClientHeight - 10 DEFINT labelSpacing = (availLabelHeight ) / NUM_LABLE_SETS DEFINT i FOR i = 1 TO NUM_LABLE_SETS StaticLabels(i).Top = (i - 1) * labelSpacing + 5 DataLabels(i).Top = (i - 1) * labelSpacing + 5 NEXT i END SUB