Excel like grid for a version 12 dialog

Example scripts and tips (replaces Old Scripts & Tips archive)

Moderators: Dorian (MJT support), JRL, Phil Pendlebury

Post Reply
User avatar
JRL
Automation Wizard
Posts: 3501
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Excel like grid for a version 12 dialog

Post by JRL » Tue Sep 27, 2011 4:37 am

Lots of options for doing this differently. Another use for what I like to call dynamic dialogs. Dialogs that are created on the fly.

Live and learn. Just posted what I think is a better solution using HTA HERE Much faster if you have lots of cells.


Code: Select all

//Clean up leftover files
Let>DFile=%temp_dir%Dialogfile.scp
Let>CSVFile=%temp_dir%DataAcquiredFromElseWhere.csv
DeleteFile>DFile

//Using LabelToVar to create a sample csv.
//Remark or delete the next three lines
//Then call your own csv file
DeleteFile>CSVFile
LabelToVar>DataAcquiredFromElseWhere,data
WriteLn>CSVFile,wres,data

CSVFileToArray>CSVFile,item

//Reducing the Item_count variable might not be needed
//It depends on how your CSV file ends.  Test with and without.
Sub>item_count,1
Sub>item_1_count,1

WriteLn>DFile,wres,Dialog>Dialog1
WriteLn>DFile,wres,object Dialog1: TForm  Caption = 'Iowa Birds' AutoSize = true Position = poScreenCenter
Let>EBR=0
Repeat>EBR
  Add>EBR,1
  Let>EBC=-1
  Repeat>EBC
  Add>EBC,1
  WriteLn>DFile,wres,object Edit_%EBR%_%EBC%: TEdit
    Let>Value={%EBC%*120}
    WriteLn>DFile,wres,Left = %value%
    Let>Value={%EBR%*20}
    WriteLn>DFile,wres,Top = %value%
    WriteLn>DFile,wres,Width = 120
    WriteLn>DFile,wres,Height = 20
  WriteLn>DFile,wres,end
  Until>EBC=%item_1_count%
Until>EBR=%item_count%

WriteLn>DFile,wres,end
WriteLn>DFile,wres,EndDialog>Dialog1

Include>DFile

Let>Row=0
Repeat>Row
  add>Row,1
  Let>Col=-1
  Repeat>Col
    add>Col,1
    Let>value=Item_%Row%_%Col%
    SetDialogProperty>Dialog1,Edit_%Row%_%Col%,Text,value
  Until>Col=%Item_1_count%
Until>Row=%Item_count%

Show>dialog1,r


//Sample data,  use your own CSV file.
/*
DataAcquiredFromElseWhere:
Common Name,Latin Name,Sighted in Iowa
Black-bellied Plover,Pluvialis squatarola,Y
American Golden-Plover,Pluvialis dominica,Y
Snowy Plover,Charadrius alexandrinus,N
Semipalmated Plover,Charadrius semipalmatus,Y
Piping Plover,Charadrius melodus,Y
Killdeer,Charadrius vociferus,Y
*/

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts