Solved

how to declare fix size string variable

Posted on 2006-11-14
11
823 Views
Last Modified: 2013-12-26
i want to declare string variable of 128 char size...


how can i declare that ...

in VB i think
Dim Buffer As String * 128  is working..  good .

but what abt PB...



0
Comment
Question by:divyeshhdoshi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
11 Comments
 
LVL 8

Expert Comment

by:gajender_99
ID: 17938776
string  vls_test[128]


Gajender
0
 
LVL 14

Expert Comment

by:sandeep_patel
ID: 17953611
Hi,

what gajender said is not the exactly you want...it is array declaration in PB.

As per my knowledge, fixed size variable declaration is not possible in PB.

I think you want this to call some windows API if that is the case then in powerbuilder when you pass any string variable as reference to any external api call that time should assign memory space to that variable in advance for that you can assign space of that much length to that variable.

for example.

there is windows api getcomputername(string compname)
where, compname is string variable and passed as reference, so according to api defination you should assign value to that variable before you pass to api call.

like...

string compname = space(128)
getcomputername(compname)

Hope, this will work for you.

Regards,
Sandeep
0
 
LVL 6

Author Comment

by:divyeshhdoshi
ID: 17953791
i think space(128) is working properly...

because when we pass that string to another api function that doesn't know that variable size is 128 chars.  so that function place all chars in that variable..

finally .......
we got solution by another way....

thanks for giving hint....

Sandeepbhai mazaman choone....... FROM TMSPL Ahemdabad.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Author Comment

by:divyeshhdoshi
ID: 17953804
my previous comment is wrong

think space(128) is not working properly...

because when we pass that string to another api function that doesn't know that variable size is 128 chars.  so that function place all chars in that variable..

finally .......
we got solution by another way....

thanks for giving hint....

Sandeepbhai mazaman choone....... FROM TMSPL Ahemdabad.
0
 
LVL 14

Expert Comment

by:sandeep_patel
ID: 17954027
Hi,

i am doing good...
let me how u found the solution and what was the exact problem ?

Regards,
Sandeep
0
 
LVL 6

Author Comment

by:divyeshhdoshi
ID: 18066606
hi ,

i can't tell u solution....

sorry..



0
 
LVL 14

Expert Comment

by:sandeep_patel
ID: 18067051
Hi,

It's ok...But I am quite disappointed. Because here everyone is sharing their knowledge not code.

Anyway it's your choice.... Keep on posting your problems....

Regards,
Sandeep
0
 
LVL 6

Author Comment

by:divyeshhdoshi
ID: 18201257
hi,

we pass single line edit control and place our fixed size in limit property of sle.....

Regards,
Divyesh Doshi.
0
 
LVL 14

Accepted Solution

by:
sandeep_patel earned 20 total points
ID: 18201628
Hi,

I think you are doing the same what I said earlier. Bcoz in your API you are not passing single line edit control you are passing the value in that means....

function_name(edit_control_name.text)
NOT
function_name(edit_control_name)

It means you are passing string of some characters ( or spaces) of defined lengths (specified as in limit property). And what I told earlier is to pass the variable directly of that many characters ( or spaces)

For eg.
your edit control has limit of 1000. Then in your function you pass

string ls_test
ls_test = space(1000)
function_name(ls_test)

It must work according to my knowledge.......

Regards,
Sandeep
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question