1. Arnaud Bailly
  2. PowerBuilder
  3. Friday, 15 May 2020 06:54 AM UTC

Hello,

I have a question about powerscript usage. I would like to define several structures in the same place (eg. same file) and use them outside of the defining file, so I am doing something like the following in the source code n_cst_api_supplies:

forward
global type n_cst_api_supplies from n_cst_api
end type

global type st_supply from structure
end type

global type st_process_doc from structure
end type

global type st_product_ref from structure
end type

global type st_legal_entity_ref from structure
end type

global type st_user_ref from structure
end type

end forward

global type st_supply from structure
string guid
string commercial_code
string commercial_denomination
string main_origin
st_product_ref product
st_legal_entity_ref legal_entity
st_user_ref monitored_by
st_process_doc supply_process_docs[]
end type

global type st_process_doc from structure
string name
string value
end type

global type st_product_ref from structure
string guid
string code
end type

global type st_legal_entity_ref from structure
string guid
string code
end type

global type st_user_ref from structure
string guid
string name
end type

global type n_cst_api_supplies from n_cst_api
end type

... rest of the functions/events of n_cst_api_supplies follow

 

But when I try to define a variable of type st_supply outside of this context (in another custom class), compiler gives me error.

Can I make this work or do I have to define each structure in its own file/structure object? 

John Fauss Accepted Answer Pending Moderation
  1. Friday, 15 May 2020 14:23 PM UTC
  2. PowerBuilder
  3. # 1
0
Votes
Undo

Greetings, Amaud -

I'm not quite sure I fully understand the gist of what you are wanting to accomplish. I think you are trying to define one or more structures within an object (i.e., object structures), then declare instances of those object structures within other objects?

An object structure type is known only to the object in which it is defined. In order for the compiler to resolve an object type reference, it has to be either a system type or an object that is defined and resides in a library (PBL) in the target's library list. If it were otherwise, how would another developer working on this app find the definition for structure st_supply without having to resort to a source code search?

If you are wanting to keep a set of related structure definitions logically grouped, one way to do this would be by assigning them related names,, such as st_supply, st_supply_productref, st_supply_processdoc, st_supply_legalentity, etc., and/or organize then into separate libraries (that might be unmanageable for larger apps, I know).

Regards, John

Comment
There are no comments made yet.
  1. Friday, 15 May 2020 07:13 AM UTC
  2. PowerBuilder
  3. # 2
1
Votes
Undo

Hi Arnaud

If I have understood what you are trying to do I would do the following:

Declare the structures separately (yes each in a sperarate file) then declaue a userobject with the structure arrays declared as instance variables. You could then declare this userobject as a global variable and access the structure arrays with dot notation of userobject.structurename[n].

Hope that helps

David

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.