Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Determining if variable or static string is passed to a Sub
#5
Hi Dano
Code: (Select All)

Dim GlobalString$, GlobalFixedString$7

GlobalString$ = "123456789012345"
GlobalFixedString$7 = "1234567890"
Print "Global variable", "In function variable" + "  Kind 0=fixed/ -1=variable"
Print GlobalString$, WhatKindOfString%(GlobalString$)
Print GlobalFixedString$7, , WhatKindOfString%(GlobalFixedString$7)
End

Function WhatKindOfString% (FunctionString$5)
    '-1 = Fixed lenght, 0 = variable lenght
    Print FunctionString$5, ;
    If Len(FunctionString$5) > 7 Then WhatKindOfString% = -1 Else WhatKindOfString% = 0
End Function

here screenshot that confirms affirmations of Bplus

I dunno if compiler must control this kind of data type with distinguish between fixed string and string.
In the same manner if you declare into the Function a SHARED variable, the compiler doesn't test if there is a same variable into main, but I dunno if this is a must for the compile... surely you can bypass this problem using Option _explicit at top of your code.

[Image: String-parameters-to-funciton-issue-by-Bplus.jpg]

So for now you cannot have this information directly from parameters of function!

Please say me:
I have 2 question for you:
 1. if it is difficult to add a parameter to the SUB/FUNCTION , is it difficult too to add a SHARED variable into it?
2. what is the goal to distinguish between Fixed and Variable lenght ?
Reply


Messages In This Thread
RE: Determining if variable or static string is passed to a Sub - by TempodiBasic - 05-21-2025, 11:42 PM



Users browsing this thread: 1 Guest(s)