On Apr 24, 2007, at 1:39 PM, Sven E Olsson wrote: > > On 2007-04-24, at 19:21, Charles Yeomans wrote: > >>> >>> >>> if prefs.WordWrap" then >>> Dim TextWindow as TextWnoScroll >>> else >>> Dim TextWindow as TextWHscroll >>> end if >>> >>> >>> That is not hard to do at all, but it just not works.. >> >> >> How does it not work? It looks like valid code to me. >> >> Charles Yeomans >> _______________________________________________ > > > 1 - That was an example to declare TextWindow as global, so the > compiler not shows error and stop (because TextWindow do not exist) > > So I wrote I wanted something like this: > > if prefs.Wordwrap = true then > dim global TextWindow as TextWnoScroll > else > dim global TextWindow as TextWHScroll > end if > > And this is impossible to do as "global", the compiler would always > stop, because all declarations must be done before the app is opened > And in this case it would not be global, because it is in the app > open event.. > > > 2 - Then I found this code using inside a method > > if prefs.Wordwrap = true then > dim global TextWindow as TextWnoScroll > TextWindow = new TextWnoScroll > else > dim global TextWindow as TextWHScroll > TextWindow = new TextWHscroll > end if > > TextWindow.Title = "text.txt" > TextWindow.Document = f > TextWindow.EditField1.text = "Hello" > > > And this do not work, because the declarations is inside a block.. > > It have to be like this: > > if prefs.Wordwrap = true then > dim global TextWindow as TextWnoScroll > TextWindow = new TextWnoScroll > TextWindow.Title = "text.txt" > TextWindow.Document = f > TextWindow.EditField1.text = "Hello" > > else > dim global TextWindow as TextWHScroll > TextWindow = new TextWHscroll > TextWindow.Title = "text.txt" > TextWindow.Document = f > TextWindow.EditField1.text = "Hello" > end if > > The code have to be rewritten twice..
Right. This is a sign that you need to do one of two things. 1) Have TextWHScroll and TextWnoScroll inherit from a common superclass; 2) Have both classes TextWHScroll and TextWnoScroll implement a common interface. Then you declare TextWindow to be of this common type and proceed. I believe this has already been pointed out by others. Charles Yeomans _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives: <http://support.realsoftware.com/listarchives/lists.html>
