Severity: Warning
Message: Undefined variable $page
Filename: front/Articles.php
Line Number: 91
Backtrace:
File: /opt/bitnami/projects/celticproductions.net/application/controllers/front/Articles.php
Line: 91
Function: _error_handler
File: /opt/bitnami/projects/celticproductions.net/index.php
Line: 315
Function: require_once
Severity: Warning
Message: Undefined variable $pages
Filename: front/Articles.php
Line Number: 110
Backtrace:
File: /opt/bitnami/projects/celticproductions.net/application/controllers/front/Articles.php
Line: 110
Function: _error_handler
File: /opt/bitnami/projects/celticproductions.net/index.php
Line: 315
Function: require_once
Severity: Warning
Message: Undefined variable $page
Filename: front/Articles.php
Line Number: 111
Backtrace:
File: /opt/bitnami/projects/celticproductions.net/application/controllers/front/Articles.php
Line: 111
Function: _error_handler
File: /opt/bitnami/projects/celticproductions.net/index.php
Line: 315
Function: require_once
Severity: Warning
Message: Undefined variable $category
Filename: front/Articles.php
Line Number: 113
Backtrace:
File: /opt/bitnami/projects/celticproductions.net/application/controllers/front/Articles.php
Line: 113
Function: _error_handler
File: /opt/bitnami/projects/celticproductions.net/index.php
Line: 315
Function: require_once
Severity: Warning
Message: Undefined variable $articles
Filename: front/Articles.php
Line Number: 114
Backtrace:
File: /opt/bitnami/projects/celticproductions.net/application/controllers/front/Articles.php
Line: 114
Function: _error_handler
File: /opt/bitnami/projects/celticproductions.net/index.php
Line: 315
Function: require_once
set /a command, e.g.
set /a myCounter=myCounter+1
set /a myCounter=myCounter+1.5, you'll get a missing operator error. So, in our CSV file, we want to create an extra column which is the sum of the two relevant floating point columns. Here's the code:
@echo off
cscript.exe //H:cscript
setLocal EnableDelayedExpansion
if exist "eval.vbs" goto script
@echo Set objArgs = WScript.Arguments>"eval.vbs"
@echo wscript.echo eval(objArgs(0))>>"eval.vbs"
:script
for /f "tokens=1-3* delims=." %%a in (%1) do (
set newfile=%%a_after_script.%%b
)
if exist "%newfile%" del "%newfile%"
set linecounter=0
for /f "tokens=1-7* delims=," %%a in ('type %1') do (
for /f %%i in ('eval //nologo %%d+%%f') do (
set var=%%i
)
echo %%a,%%b,%%c,%%d,%%e,%%f,!var! >> "%newfile%"
set /a linecounter=linecounter+1
)
linecounter which will just tell us how many lines we've processed at the end. Then we set up a for loop which will divide up our columns based on the comma, it being a comma separated values file. The in statement of the for loop is a little trick which is covered in a different article on Celtic Productions. It is used, again, to deal with spaces in the filename. The outer for loop loops through each line in the file. The inner for loop then performs the arithmetic.
var.
linecounter variable and outside of our for loops we just echo a status message.
echo Processed %linecounter% line(s)
%%d+%%f, you could pass in %%d^%%f to raise %%d to the power of %%f. In fact, anything that you can eval in VB Script, you can pass in to that "eval.vbs" file, just make sure it's valid! Here's the complete code:
@echo off
cscript.exe //H:cscript
setLocal EnableDelayedExpansion
if exist "eval.vbs" goto script
@echo Set objArgs = WScript.Arguments>"eval.vbs"
@echo wscript.echo eval(objArgs(0))>>"eval.vbs"
:script
for /f "tokens=1-3* delims=." %%a in (%1) do (
set newfile=%%a_combined.%%b
)
if exist "%newfile%" del "%newfile%"
set linecounter=0
for /f "tokens=1-7* delims=," %%a in ('type %1') do (
for /f %%i in ('eval //nologo %%d+%%f') do (
set var=%%i
)
echo %%a,%%b,%%c,%%d,%%e,%%f,!var! >> "%newfile%"
set /a linecounter=linecounter+1
)
echo Processed %linecounter% line(s)