Kinook Software Forum

Kinook Software Forum (https://www.kinook.com/Forum/index.php)
-   [VBP] General Discussion (https://www.kinook.com/Forum/forumdisplay.php?f=2)
-   -   Issue-Reading a file with vbld_GetFileContents (https://www.kinook.com/Forum/showthread.php?t=3573)

teognost 04-22-2008 01:15 PM

Issue-Reading a file with vbld_GetFileContents
 
I need to read the contents of some sql script files one by one and put the content into a separate file.In order to do this I have a step which sets the macro CURR_SQL_SCRIPT_CONTENT to
[vbld_GetFileContents("%PROCFILES_FULLPATH%")]
and then I have another step which writes into the target file the macro CURR_SQL_SCRIPT_CONTENT
SQL scripts contains brackets like :
IF NOT EXISTS (SELECT * FROM [sm].[DefaultSetting] WHERE [ApplicationType] = 1 AND [ValueId] = 111)

and I see when reading the SQL file everything inside the brackets is just ignored and therefore is not appearing in the target file.
I do not understand what is wrong as in the help it is written vbld_GetFileContents should read everything ok:
"vbld_GetFileContents(Filename): Retrieve the contents of a file and double up characters that are treated specially by Visual Build Pro. Bracket characters [ ] and percent sign % characters are normally interpreted by Visual Build Pro as referencing script code and macros within a field. When retrieving the contents of a file into a field, using this function will cause these characters to be treated as literals by VBP.
"
Any idea how to read everything from SQL script ,including the parts between brackets?

kinook 04-22-2008 01:51 PM

1 Attachment(s)
That works as expected in my tests w/ VBP v6.7. The attached sample appends

IF NOT EXISTS (SELECT * FROM [sm].[DefaultSetting] WHERE [ApplicationType] = 1 AND [ValueId] = 111)

to %TEMP%\test2.sql each time it is built.

teognost 04-22-2008 02:17 PM

1 Attachment(s)
Ok,I tried exactly as in your example and it is fine.The problem was using that intermediate macro CURR_SQL_SCRIPT_CONTENT,the data between macros was lost that way(not sure why).When writing the data directly as you did -works fine.Can you tell me why the macro lost the data?Maybe in the future I would need to store content of such a file in a macro...
see the attachment

kinook 04-22-2008 02:24 PM

Use

[vbld_EscapeString(vbld_GetFileContents("%TEMP%\test.sql"))]

in the Set Macro step so that the macro value gets stored with special VBP chars escaped.

http://www.visualbuild.com/Manual/sysscriptmisc.htm
http://www.visualbuild.com/Manual/specialchars.htm

teognost 04-23-2008 01:19 AM

Works perfect,thanks for clarification!


All times are GMT -5. The time now is 05:34 PM.


Copyright © 1999-2023 Kinook Software, Inc.