Author Topic: Feature request regarding string functions  (Read 1572 times)

0 Members and 1 Guest are viewing this topic.

Brian Alvarez

  • Guest
Feature request regarding string functions
« on: November 19, 2018, 08:12:29 PM »

 I just noticed that in Oxygen cannot infoke a function that returns a string without assigning it to a variable.
This is important because a lot of the existing code relies on this. Even more, some of the existing core functions
require this to be ported.

 I would like to request that doing this becomes possible.

Brian Alvarez

  • Guest
Re: Feature request regarding string functions
« Reply #1 on: November 19, 2018, 09:48:03 PM »
For the moment, i am invoking string functions as follows:

Code: [Select]
FREES STRINGFUNCTION()
Is this safe?

Charles Pegge

  • Guest
Re: Feature request regarding string functions
« Reply #2 on: November 20, 2018, 03:27:33 AM »
Hi Brian,

No, you will need to assign to a dummy variable. This applies to float returns, as well as string returns.

Can you show us an example where you need this feature?

When using string functions in an 'if' statement or as params to another function, the return value is handled transparently.

Code: [Select]
string a(){return "A"}
string b(){return "B"}
'
if a()<b() 'ok in a conditional statement
  print a() 'ok as a parameter
else
  print b()
end if

Brian Alvarez

  • Guest
Re: Feature request regarding string functions
« Reply #3 on: November 20, 2018, 09:25:12 AM »
  Of course i can show you an example, there are hundreds. Some times even i create functions
that can be used as subs. I dont always need the returned string but i need the internal mechanism
that creates the string. Take a look at this for example:

https://forum.powerbasic.com/forum/user-to-user-discussions/programming-the-internet/775653-using-pbcc-for-cgi-file-upload-adds-46kb-to-file

 Take a look at webdatastdin() function. The webdatastdin is useful,
but sometimes it is only necesary to get this data, not to use it, but to get rid of it.

 Or even system ones, for example MID$, one returns a string and the other performs a task that
doesnt require returning a string or even a value.

 I know it can be done by assigning the value to a string, but i think being able to call them without
doing so is fundamental. :) I hope you consider it.
« Last Edit: November 20, 2018, 11:25:09 AM by Brian Alvarez »

Brian Alvarez

  • Guest
Re: Feature request regarding string functions
« Reply #4 on: November 20, 2018, 09:28:23 AM »
How about converting CALL into a function that takes any parameter and handles it accordingly?

Charles Pegge

  • Guest
Re: Feature request regarding string functions
« Reply #5 on: November 20, 2018, 10:54:13 AM »
Okay, Brian.

o2 will automatically dump returned floats and returned dynamic strings if they are not assigned to a variable. Then we can withdraw that error message :)

Brian Alvarez

  • Guest
Re: Feature request regarding string functions
« Reply #6 on: November 20, 2018, 11:25:52 AM »
Thanks!!  :D