How to store integer array in dialog box

Hello,

I am trying to write a dxl script which takes integer array (Absolute Numbers of DOORS) that entered into a dialog box and modifies a particular attribute of that object for each Absolute Number.

 

Module m = current
load view "Some View"
Object ob
 
int a[]={1281, 1280, 1282, 748, 189, 134, 2234, 232, 234,235, 236, 237, 238, 
239, 2226, 240, 241, 1330, 1331, 1332, 242, 243, 1333, 1334, 1335, 244, 245,
246, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 256, 266, 260, 261, 262,
263, 264, 265, 744, 266, 745, 2004, 267, 268, 1962, 316, 2277}
int i
for i in 0:((sizeof a)-1) do
{
ob = object(a[i], m)
ob."Some Status" = "Something Complete"
}

I want dxl to take integer array a[] from a dialog box, and when I press OK button, then 'Some Status' attribute shall be filled with "Something Complete" for those objects IDs of array a.

Any help will be greatly appreciated.

 

Thanks in advance

Ashok Anumula


ashokanumula - Thu Nov 09 06:42:40 EST 2017

Re: How to store integer array in dialog box
Mike.Scharnow - Thu Nov 09 07:49:53 EST 2017

Hello Ashok,

 

Well, one idea would be to take the string "1281, .... 227" from the dialog box, enclose it with "int a[] ={" and "}" and use the trick mentioned in https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014873958 to read the array, but I think it would be way easier to parse the string.

EIther like this https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014959868 or with one of the methods mentioned in https://stackoverflow.com/questions/1043604/string-split-in-dxl or write your own code that goes through the string characterwise and collect all digits  in a string. Whenever the next character is not a string, you have a number and can use "intOf (stringvariable)" to get the number and push it to your array.

 

Re: How to store integer array in dialog box
ashokanumula - Thu Nov 09 09:17:50 EST 2017

Mike.Scharnow - Thu Nov 09 07:49:53 EST 2017

Hello Ashok,

 

Well, one idea would be to take the string "1281, .... 227" from the dialog box, enclose it with "int a[] ={" and "}" and use the trick mentioned in https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014873958 to read the array, but I think it would be way easier to parse the string.

EIther like this https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014959868 or with one of the methods mentioned in https://stackoverflow.com/questions/1043604/string-split-in-dxl or write your own code that goes through the string characterwise and collect all digits  in a string. Whenever the next character is not a string, you have a number and can use "intOf (stringvariable)" to get the number and push it to your array.

 

Thanks for reply Mike.

 

DB splitBox = create "Text splitter" 

DBE objTextElem = text(splitBox, "Object text:", 
                         " ", 200, false) 
void getSelection(DB splitBox) {

        string ot = get objTextElem

        print ot    
            

} // getSelection 
apply(splitBox, "OK", getSelection) 
show splitBox

 

print ot

is printing below string

2140
3137
3167
3138
127
422
1214
1344
1345
472
2348
3270
2128
2144
3244
2134
2138

I want a dxl code to convert each number string into number integer and use further

If I get dxl code direclty, it will be great Mike.

 

Thanks,

Ashok

Re: How to store integer array in dialog box
Mike.Scharnow - Thu Nov 09 11:40:04 EST 2017

ashokanumula - Thu Nov 09 09:17:50 EST 2017

Thanks for reply Mike.

 

DB splitBox = create "Text splitter" 

DBE objTextElem = text(splitBox, "Object text:", 
                         " ", 200, false) 
void getSelection(DB splitBox) {

        string ot = get objTextElem

        print ot    
            

} // getSelection 
apply(splitBox, "OK", getSelection) 
show splitBox

 

print ot

is printing below string

2140
3137
3167
3138
127
422
1214
1344
1345
472
2348
3270
2128
2144
3244
2134
2138

I want a dxl code to convert each number string into number integer and use further

If I get dxl code direclty, it will be great Mike.

 

Thanks,

Ashok

Hi Ashok,

sorry, I don't have a function for this in my library and don't have the time to program it, but the links I sent contain enough code to reuse and to get you started

Re: How to store integer array in dialog box
ashokanumula - Fri Nov 10 06:56:51 EST 2017

Mike.Scharnow - Thu Nov 09 11:40:04 EST 2017

Hi Ashok,

sorry, I don't have a function for this in my library and don't have the time to program it, but the links I sent contain enough code to reuse and to get you started

Hi Mike,

Finally I developed the dxl script, it is working fine. Thanks a lot for your help

================================================================

DB splitBox = create "Text splitter" 

DBE objTextElem = text(splitBox, "Object text:", 
                         " ", 200, false) 
int star=0
void getSelection(DB splitBox) {

        string ot = get objTextElem 
Skip fileLines = create

int str_index

void str_split(string splitter, string str, Skip fileLines)
{
    Buffer buf = create;
    int str_index;

    buf = "";

    for(str_index = 0; str_index < length(str); str_index++)
{
        if( str[str_index:str_index] == splitter )
{
        
             put(fileLines, star, buf"");
             star++             
             buf = "";
        }
else
{
            buf += str[str_index:str_index];
            
        }
    }
   
    delete buf;
}

string str
str_split("\n", ot,fileLines )

for str in fileLines do
{
Module m = current
load view "Some View"
Object ob

ob = object(intOf(str), m)
print identifier ob"\n"

}

delete fileLines            

apply(splitBox, "OK", getSelection) 
show splitBox

===========================================================

 

 

 

Re: How to store integer array in dialog box
Mike.Scharnow - Fri Nov 10 07:09:52 EST 2017

ashokanumula - Fri Nov 10 06:56:51 EST 2017

Hi Mike,

Finally I developed the dxl script, it is working fine. Thanks a lot for your help

================================================================

DB splitBox = create "Text splitter" 

DBE objTextElem = text(splitBox, "Object text:", 
                         " ", 200, false) 
int star=0
void getSelection(DB splitBox) {

        string ot = get objTextElem 
Skip fileLines = create

int str_index

void str_split(string splitter, string str, Skip fileLines)
{
    Buffer buf = create;
    int str_index;

    buf = "";

    for(str_index = 0; str_index < length(str); str_index++)
{
        if( str[str_index:str_index] == splitter )
{
        
             put(fileLines, star, buf"");
             star++             
             buf = "";
        }
else
{
            buf += str[str_index:str_index];
            
        }
    }
   
    delete buf;
}

string str
str_split("\n", ot,fileLines )

for str in fileLines do
{
Module m = current
load view "Some View"
Object ob

ob = object(intOf(str), m)
print identifier ob"\n"

}

delete fileLines            

apply(splitBox, "OK", getSelection) 
show splitBox

===========================================================

 

 

 

Great. Thanks for the update!