
Quote from Bob Olsen on August 26, 2026, 6:19 pmI'm trying to get all the folders in a location into a ListBox, but I'm only getting the first folder. I've checked that it displays the folder variable count correctly in the debugger.
:OppdaterNotatMapper FileList "[PubDir]Data\Notater\" "Folders" "[NotatMapper]" If "[NotatMapper]" "<>" "True" ListBoxDeleteItem "Notater" "1" ListBoxSize "Notater" "[AntallMapper]" StrParse "[NotatMapper]" "[#13]" "[Mapper]" "[x]" Loop "1" "[AntallMapper]" "[i]" ListBoxAddItem "Notater" "0" "[Mapper[i]]" EndLoop .ListBoxSort "Notater" "True" EndIf Return
I'm trying to get all the folders in a location into a ListBox, but I'm only getting the first folder. I've checked that it displays the folder variable count correctly in the debugger.
:OppdaterNotatMapper
FileList "[PubDir]Data\Notater\" "Folders" "[NotatMapper]"
If "[NotatMapper]" "<>" "True"
ListBoxDeleteItem "Notater" "1"
ListBoxSize "Notater" "[AntallMapper]"
StrParse "[NotatMapper]" "[#13]" "[Mapper]" "[x]"
Loop "1" "[AntallMapper]" "[i]"
ListBoxAddItem "Notater" "0" "[Mapper[i]]"
EndLoop
.ListBoxSort "Notater" "True"
EndIf
Return
Quote from mishem on August 26, 2026, 9:30 pmFileList "[PubDir]Data\Notater\" "Folders" "[NotatMapper]" If "[NotatMapper]" "<>" "" SetObjectCaption "Notater" "[NotatMapper]" ListBoxSize "Notater" "[AntallMapper]" ListBoxSort "Notater" "True" EndIf
FileList "[PubDir]Data\Notater\" "Folders" "[NotatMapper]" If "[NotatMapper]" "<>" "" SetObjectCaption "Notater" "[NotatMapper]" ListBoxSize "Notater" "[AntallMapper]" ListBoxSort "Notater" "True" EndIf
Quote from mishem on August 26, 2026, 9:36 pmOr
FileList "[PubDir]Data\Notater\" "Folders" "[NotatMapper]" If "[NotatMapper]" "<>" "" .ListBoxDeleteItem "Notater" "1" SetObjectCaption "Notater" "" .ListBoxSize "Notater" "[AntallMapper]" StrParse "[NotatMapper]" "[#13]" "[Mapper]" "[x]" Loop "1" "[AntallMapper]" "[i]" ListBoxAddItem "Notater" "0" "[Mapper[i]]" EndLoop ListBoxSize "Notater" "[AntallMapper]" .ListBoxSort "Notater" "True" EndIf
Or
FileList "[PubDir]Data\Notater\" "Folders" "[NotatMapper]"
If "[NotatMapper]" "<>" ""
.ListBoxDeleteItem "Notater" "1"
SetObjectCaption "Notater" ""
.ListBoxSize "Notater" "[AntallMapper]"
StrParse "[NotatMapper]" "[#13]" "[Mapper]" "[x]"
Loop "1" "[AntallMapper]" "[i]"
ListBoxAddItem "Notater" "0" "[Mapper[i]]"
EndLoop
ListBoxSize "Notater" "[AntallMapper]"
.ListBoxSort "Notater" "True"
EndIf
Quote from mishem on August 27, 2026, 9:56 pm@bob-olsen
In general, the condition here is unnecessary.If "[NotatMapper]" "<>" ""
If you know for sure that there should be folders there, that's probably what you need. However, the folder might be empty, in which case the code won't work because the [NotatMapper] variable will also be empty, and the listbox will display the old values.
Therefore, it's better to write it like this:FileList "[PubDir]Data\Notater\" "Folders" "[NotatMapper]" SetObjectCaption "Notater" "[NotatMapper]" ListBoxSize "Notater" "[AntallMapper]" ListBoxSort "Notater" "True"But it's possible that the folder being checked doesn't exist at all. Therefore, it's best to first check for its existence and, if it does, continue executing the code. This will eliminate potential errors.
FolderExists "[PubDir]Data\Notater" "[Result]" If "[Result]" "=" "True" FileList "[PubDir]Data\Notater\" "Folders" "[NotatMapper]" SetObjectCaption "Notater" "[NotatMapper]" ListBoxSize "Notater" "[AntallMapper]" ListBoxSort "Notater" "True" EndIf
@bob-olsen
In general, the condition here is unnecessary.
If "[NotatMapper]" "<>" ""
If you know for sure that there should be folders there, that's probably what you need. However, the folder might be empty, in which case the code won't work because the [NotatMapper] variable will also be empty, and the listbox will display the old values.
Therefore, it's better to write it like this:
FileList "[PubDir]Data\Notater\" "Folders" "[NotatMapper]" SetObjectCaption "Notater" "[NotatMapper]" ListBoxSize "Notater" "[AntallMapper]" ListBoxSort "Notater" "True"
But it's possible that the folder being checked doesn't exist at all. Therefore, it's best to first check for its existence and, if it does, continue executing the code. This will eliminate potential errors.
FolderExists "[PubDir]Data\Notater" "[Result]" If "[Result]" "=" "True" FileList "[PubDir]Data\Notater\" "Folders" "[NotatMapper]" SetObjectCaption "Notater" "[NotatMapper]" ListBoxSize "Notater" "[AntallMapper]" ListBoxSort "Notater" "True" EndIf