inno setup - Get strings from ini file and use multiple times -


i want store text ini file variable , use var many times along setup pages,

for instace lets have ini file named-"datatxt", ini section -[txtdata], section key-"htxt", key value - "hello world". want store text value in var named - "hivar" , use here-

title :=      tnewstatictext.create(mopage);     title.parent := mopage.surface;     title.font.name := 'verdana';     title.caption := hivar;  

for declaring variables there 2 scopes available. local , global. locally declared variables visible within body of procedure or method declared. used temporary storage intermediate operations, or holding object references (as do):

procedure dosomething; var   s: string; // <- locally declared variable begin   // inside procedure s variable can accessed end; 

globally declared variables (which question about) visible in scope of procedures , methods within whole code scripting section. used holding references of objects used across script code, passing results of operations between event methods, or holding permanent values (which case):

var   s: string; // <- globally declared variable  procedure dosomething; begin   // inside procedure s variable can accessed end;  procedure dosomethingelse; begin   // inside procedure s variable can accessed end; 

answer question example quite hard, since haven't desribed context in want read ini file, it's hard tell in event should read it. in following example ini file value read when wizard form initialized. can see there access global variable method well:

[setup] appname=my program appversion=1.5 defaultdirname={pf}\my program  [files] source: "datatxt"; flags: dontcopy  [code] var   hivar: string; // <- globally declared variable  procedure initializewizard; begin   // extract file setup temporary folder   extracttemporaryfile('datatxt');   // assign read value global variable   hivar := getinistring('txtdata', 'htxt', '', expandconstant('{tmp}\datatxt'));   // on variable should contain key value end;  procedure curpagechanged(curpageid: integer); begin   // random code showing can access global   // variables across methods   if curpageid = wpwelcome     msgbox(hivar, mbinformation, mb_ok); end; 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -