AddElement(List()) = "Value"

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

it is almost always useless, because it can't be used with structured lists. :roll:
oh... and have a nice day.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

But it CAN.

Code: Select all

; Suggestion
AddElement(StructuredList())\Field1 = Value1
StructuredList()\Field2 = Value2

; Current
AddElement(StructuredList())
StructuredList()\Field1 = Value1
StructuredList()\Field2 = Value2

; Suggestion saves 1 line per added item for structured lists.

; Suggestion
AddElement(List()) = Value

; Current
AddElement(List())
List() = Value

; Suggestion saves 1 line per added item for unstructured list

; Since it saves the same amount of lines per added item for both
; unstructred and structured lists it is just as useful for structured lists.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

Oh, a endless loop, is this a bug :lol:
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

AddElement() is a regular Function.
You cannot have a function on the left hand side of an assignment,
and changing this just for this special case does not make much sense imho.
Last edited by freak on Thu Aug 23, 2007 12:29 pm, edited 1 time in total.
quidquid Latine dictum sit altum videtur
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Code: Select all

Procedure FunctionOnTheLeftSide()
  ProcedureReturn 1
EndProcedure

Dim Array(10)
Array(FunctionOnTheLeftSide()) = 1
In pascal you can access the structure members of functions that returns pointers to structures. That's very handy.
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

Trond wrote:

Code: Select all

Dim Array(10)
Array(FunctionOnTheLeftSide()) = 1
I see a problem with your reasoning: this is not a chicken.
oh... and have a nice day.
Post Reply