Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Assign print using to a string.
#2
(03-30-2024, 03:29 AM)eoredson Wrote: An interesting code snippet to get a string variable from print using:

Code: (Select All)
'sample assigning formatted string from print using to a variable:
Rem x$ = Print Using "###"; 100
X = FreeFile
F$ = "tempfile.bak"
Print "Enter value";
Input Z#: If Z# = 0# Then Z# = 100#
Print "Enter format";
Input Z$: If Z$ = "" Then Z$ = "###"
'write print using value
Open F$ For Output As #X
Print #X, Using Z$; Z#
'read print using value
Close
Open F$ For Input As #X
If EOF(X) = 0 Then
  Line Input #X, S$
  Print S$ ' this is the output value
End If
Close
End
Although I cannot find a more efficient way to do this..

Erik.
Hmmm, that's interesting. In other words what you are looking for would be something like this:

Num = 100
use$ = "This is a test -> ###"
s$ = USING use$, Num

s$ would then contain: This is a test -> 100

I've always used USING to format output to a printer or file but I never gave any thought to USING being utilized in this manner. It's an interesting concept though. The only way I see to do this (besides the method you showed above) would be to create functions and/or subs to preformat strings for you.
New to QB64pe? Visit the QB64 tutorial to get started.
QB64 Tutorial
Reply


Messages In This Thread
Assign print using to a string. - by eoredson - 03-30-2024, 03:29 AM
RE: Assign print using to a string. - by TerryRitchie - 03-30-2024, 04:17 AM
RE: Assign print using to a string. - by SMcNeill - 03-30-2024, 04:55 AM
RE: Assign print using to a string. - by eoredson - 03-31-2024, 11:23 PM
RE: Assign print using to a string. - by eoredson - 04-01-2024, 02:54 AM
RE: Assign print using to a string. - by SMcNeill - 04-01-2024, 06:04 AM
RE: Assign print using to a string. - by eoredson - 04-02-2024, 12:52 AM
RE: Assign print using to a string. - by SMcNeill - 04-02-2024, 01:36 AM
RE: Assign print using to a string. - by eoredson - 04-02-2024, 01:49 AM
RE: Assign print using to a string. - by SMcNeill - 04-02-2024, 02:56 AM



Users browsing this thread: 1 Guest(s)