Indigo Rose Software

Professional Software Development Tools

 
Results 1 to 12 of 12
  1. #1
    Join Date
    Oct 2003
    Posts
    49

    How to put a variabele in a WriteFromString

    TextFile.WriteFromString("d:\\check_password.sql", [[
    bla bla bla bla
    want to put var in text file from SF7:

    %var% or ..var.. or .......

    quit
    ]], false);

    Some one can help?

  2. #2
    Join Date
    Oct 2001
    Location
    Norway
    Posts
    939
    Hi,

    The string can have the content of a LUA variable. If the text is assigned to a Session Variable, you first have to expand it.

    Code:
    strMyText = SessionVar.Expand("%ProductName%".. " is installed in ".."%AppFolder%");
    TextFile.WriteFromString("C:\\MyFile.txt", strMyText, false);	
    Dialog.Message("C:\\MyFile.txt","The text '"..strMyText.."' is now written to the file", MB_OK, MB_ICONNONE);
    Session Variables are used for DISPLAYING purposes in the screens.

  3. #3
    Join Date
    Oct 2003
    Posts
    49
    i want to use a LUA var in a write.string thing (multiline). how to do then?

  4. #4
    Join Date
    Oct 2001
    Location
    Norway
    Posts
    939
    Something like this?

    Code:
    strMyText = SessionVar.Expand("This text has".."\r\nbe displayed".."\r\non severel lines:".."\r\n".."\r\n%ProductName%".."\r\nis installed in".."\r\n%AppFolder%");
    TextFile.WriteFromString("C:\\MyFile.txt", strMyText, false);
    But now you have a very LONG code line. I prefer to break it up like this:

    Code:
    strMyText = SessionVar.Expand("This text has"
    	.."\r\nbe displayed"
    	.."\r\non severel lines:"
    	.."\r\n"
    	.."\r\n%ProductName%"
    	.."\r\nis installed in"
    	.."\r\n%AppFolder%");
    Was this an answer to your question?

  5. #5
    Join Date
    Oct 2003
    Posts
    49
    Nope, i have the following code:

    In this code cq text file, i want to use LUA vars...

    Code:
    		
    TextFile.WriteFromString(strAppSqlDir.."\\check_password.sql", [[
    			WHENEVER OSERROR  EXIT 32767 
    			WHENEVER SQLERROR EXIT SQL.SQLCODE
    		
    			SET pause off
    			SET heading off
    			SET feedback off
    			SET timing off
    			SET termout off
    			SET echo off
    			SET verify off
    			SET linesize 1000
    			SET pagesize 1000
    			TRIMSPOOL on
    			
    			connect sys/oracle1@%DatabaseNaam%;
    			spool %AppSqlDir%\check_dbsyspass.txt
    			select 'Ja' from dual;
    			spool off
    			connect system/oracle1@%db_naam%;
    			spool %AppSqlDir%\check_dbsystempass.txt
    			select 'Ja' from dual;
    			spool off
    			connect impulse/%ImpPass%@%db_naam%;
    			spool %AppSqlDir%\check_dbimpulsepass.txt
    			select 'Ja' from dual;
    			spool off
    		
    			quit
    			]], false);

  6. #6
    Join Date
    Oct 2001
    Location
    Norway
    Posts
    939
    Nope?

    You have another string than I have in my simple example, but the principle is the same.

    Just edit your string, be aware of quotation marks, and add some "\r\n" [=CR|LF].

  7. #7
    Join Date
    Feb 2001
    Location
    Indigo Rose Software
    Posts
    2,728
    Quote Originally Posted by brianlesker
    Nope, i have the following code:

    In this code cq text file, i want to use LUA vars...
    If I understand you correctly, you want to use lua variables instead of those session variables?

    It looks to me like it would be easier just to use the session variables, and expand the whole string like this:

    Code:
    		
    TextFile.WriteFromString(strAppSqlDir.."\\check_password.sql", SessionVar.Expand([[
    			WHENEVER OSERROR  EXIT 32767 
    			WHENEVER SQLERROR EXIT SQL.SQLCODE
    		
    			SET pause off
    			SET heading off
    			SET feedback off
    			SET timing off
    			SET termout off
    			SET echo off
    			SET verify off
    			SET linesize 1000
    			SET pagesize 1000
    			TRIMSPOOL on
    			
    			connect sys/oracle1@%DatabaseNaam%;
    			spool %AppSqlDir%\check_dbsyspass.txt
    			select 'Ja' from dual;
    			spool off
    			connect system/oracle1@%db_naam%;
    			spool %AppSqlDir%\check_dbsystempass.txt
    			select 'Ja' from dual;
    			spool off
    			connect impulse/%ImpPass%@%db_naam%;
    			spool %AppSqlDir%\check_dbimpulsepass.txt
    			select 'Ja' from dual;
    			spool off
    		
    			quit
    			]]), false);
    ...but if you want to use lua variables instead, you can do so like this:

    Code:
    		
    TextFile.WriteFromString(strAppSqlDir.."\\check_password.sql", [[
    			WHENEVER OSERROR  EXIT 32767 
    			WHENEVER SQLERROR EXIT SQL.SQLCODE
    		
    			SET pause off
    			SET heading off
    			SET feedback off
    			SET timing off
    			SET termout off
    			SET echo off
    			SET verify off
    			SET linesize 1000
    			SET pagesize 1000
    			TRIMSPOOL on
    			
    			connect sys/oracle1@]]..strDatabaseNaam..[[;
    			spool ]]..strAppSqlDir..[[\check_dbsyspass.txt
    			select 'Ja' from dual;
    			spool off
    			connect system/oracle1@]]..db_naam..[[;
    			spool ]]..strAppSqlDir..[[\check_dbsystempass.txt
    			select 'Ja' from dual;
    			spool off
    			connect impulse/]]..strImpPass.."@"..db_naam..[[;
    			spool ]]..strAppSqlDir..[[\check_dbimpulsepass.txt
    			select 'Ja' from dual;
    			spool off
    		
    			quit
    			]], false);
    --[[ Indigo Rose Software Developer ]]

  8. #8
    Join Date
    Oct 2001
    Location
    Norway
    Posts
    939
    Lorne, I didn't know about the double angle brackets
    [[
    to create
    a block of text
    ]]

    Is it covered in the help doc? (I can't find it.)

  9. #9
    Join Date
    Feb 2001
    Location
    Indigo Rose Software
    Posts
    2,728
    It's on page 273 in the user's guide.
    --[[ Indigo Rose Software Developer ]]

  10. #10
    Join Date
    Oct 2003
    Posts
    49

    Lightbulb

    csd214: that's easier than your "\r\n" [=CR|LF]

  11. #11
    Join Date
    Oct 2001
    Location
    Norway
    Posts
    939
    Quote Originally Posted by brianlesker
    csd214: that's easier than your "\r\n" [=CR|LF]
    Yes, indeed (in your case). Once again Lorne had something to teach me; this forum is indispensable.

    (But the "\r\n" is working! I just tried to help you.)

  12. #12
    SUF6NEWBIE Guest
    You can also use the methods described to 'write-create' INI files
    'on the fly'

Similar Threads

  1. Re: How do I put a shortcut in startup menu
    By RickJ in forum Setup Factory 6.0
    Replies: 3
    Last Post: 07-03-2003, 08:17 AM
  2. how can i put custom variables to the file ?
    By scottlee in forum Setup Factory 6.0
    Replies: 4
    Last Post: 04-28-2003, 09:42 AM
  3. Put custom splash screen???
    By mandark in forum Setup Factory 6.0
    Replies: 1
    Last Post: 12-23-2002, 08:07 AM
  4. How do i put backgound music for my cd launcher ?
    By Flea in forum AutoPlay Media Studio 4.0
    Replies: 1
    Last Post: 10-31-2002, 07:44 AM
  5. How to put a shortcut in quick launch bar?
    By liviolee in forum Setup Factory 6.0
    Replies: 2
    Last Post: 03-19-2002, 09:37 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts