Skip to content

Commit

Permalink
The sav ValueLabels are conceived to be once per several variables (i…
Browse files Browse the repository at this point in the history
…ndexes), but the library handle it one per variable, what duplicate it. So, what we have is just a list of the current variables where only the last one (the current) that create the valuelabel, is related with it. So, find if we need to convert the string to double there, because the indexes are pointing to the place where the variable will be stored, not to the variable itself.
  • Loading branch information
lestcape committed May 18, 2021
1 parent 6503258 commit e63fd5d
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/Sav/Record/ValueLabel.php
Original file line number Diff line number Diff line change
@@ -89,12 +89,8 @@ public function read(Buffer $buffer)

public function write(Buffer $buffer)
{
$convertToDouble = false;
$varIndex = reset($this->indexes);
if (false !== $varIndex && isset($this->variables[$varIndex - 1])) {
$varWidth = $this->variables[$varIndex - 1]->width;
$convertToDouble = $varWidth > 0;
}
$var = (count($this->variables) > 0) ? $this->variables[count($this->variables) - 1] : null;
$convertToDouble = (isset($var) && ($var->width > 0));

// Value label record.
$buffer->writeInt(self::TYPE);

0 comments on commit e63fd5d

Please sign in to comment.