BBC.SHARED.JOBI.TEMPFILE-VARA#2COLUMNS
Summary
- Object type
- JOBI
- Object Folder
- PACKAGES/BEST-BLU/BBC.SHARED/SOURCE/TEMPFILES
- Title
- Retrieves the content for a temporary file in CSV format from a VARA
- Archive Key 1
- -
- Archive Key 2
- -
- Created
- WRITER/B4A am: 2022-02-28 14:47:21
- Last Modified
- WRITER/B4A am: 2024-01-09 09:57:42 18 x
- Last Used
- -
Description
This include adds two columns of a variable object to a temporary file and separates them by a semicolon (;)
Requirements
- Unix: bash
- Windows: Powershell 7.0
Parameter
- $VARACOL$
- defines the variable object and and the columns to use
Input
Output
Unix
- $bbcs_vara_file
- script variable containing the name of the temporary file
Windows
- $bbcs_vara_file
- powershell variable containing the name of the temporary file
Example
:include BBC.SHARED.JOBI.TEMPFILE-VARA#2COLUMNS $ENTRY$ = "<variable>[:<col1>[,<col2>]]"
If no column has been specified the columns 1 and 2 is used.
:include BBC.SHARED.JOBI.TEMPFILE-VARA#2COLUMNS $ENTRY$ = "<variable>"
If one column has been specified than column 1 and the given one will be used for the second column
:include BBC.SHARED.JOBI.TEMPFILE-VARA#2COLUMNS $ENTRY$ = "<variable>:<col2>"
Process
:set &vara_data# = "$VARACOL$"
:set &colon# = str_find( &vara_data#, ":" )
:if &colon# < 1
: set &variable# = &vara_data#
: set &column1# = 1
: set &column2# = 2
:else
: set &colon# = &colon# - 1
: set &variable# = str_cut( &vara_data#, 1, &colon# )
: set &colon# = &colon# + 2
: set &columns# = str_cut( &vara_data#, &colon# )
: set &comma# = str_find( &columns#, "," )
: if &comma# < 1
: set &column1# = 1
: set &column2# = &columns#
: else
: set &comma# = &comma# - 1
: set &column1# = str_cut( &columns#, 1, &comma# )
: set &comma# = &comma# + 2
: set &column2# = str_cut( &columns#, &comma# )
: endif
:endif
:set &hnd# = prep_process_var( &variable# )
:inc BBC.SHARED.JOBI.TEMPFILE-START
:process &hnd#
: set &value1# = get_process_line( &hnd#, &column1# )
: set &value1# = str_substitute_var( &value1# )
: set &value1# = resolve_var( &value1# )
: set &value2# = get_process_line( &hnd#, &column2# )
: set &value2# = str_substitute_var( &value2# )
: set &value2# = resolve_var( &value2# )
: switch &$PLATFORM#
: case "UNIX"
"&value1#";"&value2#"
: case "WINDOWS"
"&value1#";"&value2#"
: endswitch
:endprocess
:inc BBC.SHARED.JOBI.TEMPFILE-END
:close_process &hnd#
:switch &$PLATFORM#
: case "UNIX"
bbcs_vara_file=$bbcs_temp_file
: case "WINDOWS"
$bbcs_vara_file = $bbcs_temp_file
:endswitch