Variable loosing it's value
FearTurtles
Posts: 89
In this bit of code I'm trying to print the variable "FileOne" on the screen twice. The first time it prints just fine and the second time it seems to be ignored all together.
Pub Directory | x ,y VGAPlacement (2,0,1) VGAText.Str (String("Enter the Recipe number")) VGAPlacement (0,2,0) SD.Mount(0) 'ifnot sd.partitionMounted 'Mount(0) x := 1 repeat 2 statusVal[x] := SD.NextFileInfo("N") 'Retrieve file name Case x 0 : x++ 1 : FileOne := StatusVal[X] 'Transfering to a unique var name VGAtext.dec (x) 'print number VGAtext.str (String(" ")) VGAtext.Str (FileOne) 'Print file name ****Prints file name just fine here **** VGAtext.out ($0D) 'return x++ 'Advances x 2 : FileTwo := StatusVal[X] 'Same as 1 VGAtext.dec (x) VGAtext.str (String(" ")) VGAtext.str (FileTwo) VGAtext.out ($0D) X++ SD.Unmount Unmounts SD Repeat Ekey := Keyboard.key 'Waits for Key number 1-9 Case EKey "1" : VGAText.Str (String(">>>>")) '*****This prints**Remove later**Just to show progression***** VGAtext.Str (FileOne) 'This does not print at all. Somehow varable is loosing its value VGAText.str (String("<<<<Nothing printed ?")) '*****This prints**Remove later**Just to show progression***** 'FileName := StatusVal[1] 'LoadFile "2" : FileName := StatusVal[2] LoadFile
Comments
object you are using may interpret carriage-return as carriage-return?
The statements VGAtext.Str (FileOne) and VGAtext.str (FileTwo) attempt to print zero-terminated byte arrays.
Assuming FileOne and File two are zero-terminated strings, FileOne := StatusVal[X] and FileTwo := StatusVal[X] assigns only one byte to FileOne and FileTwo, respectively. Use bytemove to copy strings.